CameraImageMosaic { static RenderedImage create(RenderedImage... sourceImages) { double[][] sourceThresholds = new double[sourceImages.length][1]; sourceThresholds[0][0] = determineSourceThreshold(sourceImages[0]); int t = 0; for (int i = 1; i < sourceImages.length; i++) { t += sourceImages[i - 1].getWidth(); sourceImages[i] = TranslateDescriptor.create(sourceImages[i], (float) t, 0.0f, INTERPOLATION, null); sourceThresholds[i][0] = determineSourceThreshold(sourceImages[i]); } return MosaicDescriptor.create(sourceImages, MosaicDescriptor.MOSAIC_TYPE_OVERLAY, null, null, sourceThresholds, null, null); }  static MultiLevelImage create(final MultiLevelImage... sourceImages);  }
@Test public void testCreateMosaicImage() throws Exception { final RenderedImage image1 = createRenderedImage(1); final RenderedImage image2 = createRenderedImage(2); final RenderedImage image3 = createRenderedImage(3); final RenderedImage image4 = createRenderedImage(4); final RenderedImage image5 = createRenderedImage(5); final RenderedImage mosaicImage = CameraImageMosaic.create(image1, image2, image3, image4, image5); assertNotNull(mosaicImage); assertEquals(50, mosaicImage.getWidth()); assertEquals(100, mosaicImage.getHeight()); final Raster data = mosaicImage.getData(); for (int x = 0; x < mosaicImage.getWidth(); x++) { assertEquals(x / 10 + 1, data.getSample(x, 0, 0)); } }
@Test public void testCreateMosaicMultiLevelImage() throws Exception { final MultiLevelImage image1 = createMultiLevelImage(1, 2); final MultiLevelImage image2 = createMultiLevelImage(2, 2); final MultiLevelImage image3 = createMultiLevelImage(3, 2); final MultiLevelImage image4 = createMultiLevelImage(4, 2); final MultiLevelImage image5 = createMultiLevelImage(5, 2); final MultiLevelImage mosaicImage = CameraImageMosaic.create(image1, image2, image3, image4, image5); assertNotNull(mosaicImage); assertEquals(50, mosaicImage.getWidth()); assertEquals(100, mosaicImage.getHeight()); assertEquals(2, mosaicImage.getModel().getLevelCount()); final Raster dataL0 = mosaicImage.getImage(0).getData(); for (int x = 0; x < mosaicImage.getImage(0).getWidth(); x++) { assertEquals(x / 10 + 1, dataL0.getSample(x, 0, 0)); } final Raster dataL1 = mosaicImage.getImage(1).getData(); for (int x = 0; x < mosaicImage.getImage(1).getWidth(); x++) { assertEquals(x / 5 + 1, dataL1.getSample(x, 0, 0)); } }