/** * Fill in the horizontal line define by y-coordinate and the two x * coordinate extremities (inclusive), with the specified integer value. the * value x1 must be lower than or equal the value x2. */ private final static void fillLineInt(ImageStack ip, int x1, int x2, int y, int z, int value) { for (int x = x1; x <= x2; x++) ip.setVoxel(x, y, z, value); }
private ImageStack createLeveledCubeGraphImage() { ImageStack stack = createCubeGraphImage(); stack.setVoxel(5, 1, 1, 224); stack.setVoxel(9, 5, 1, 192); stack.setVoxel(9, 9, 5, 160); stack.setVoxel(9, 5, 9, 128); stack.setVoxel(5, 1, 9, 96); stack.setVoxel(1, 5, 9, 64); stack.setVoxel(1, 9, 5, 32); return stack; }
private ImageStack createLeveledCubeGraphImage() { ImageStack stack = createCubeGraphImage(); stack.setVoxel(5, 1, 1, 224); stack.setVoxel(9, 5, 1, 192); stack.setVoxel(9, 9, 5, 160); stack.setVoxel(9, 5, 9, 128); stack.setVoxel(5, 1, 9, 96); stack.setVoxel(1, 5, 9, 64); stack.setVoxel(1, 9, 5, 32); return stack; }
private void fillStack(ImageStack stack, int value) { for (int z = 0; z < stack.getSize(); z++) { for (int y = 0; y < stack.getHeight(); y++) { for (int x = 0; x < stack.getWidth(); x++) { stack.setVoxel(x, y, z, value); } } } } }
private final void invertGray8Stack(ImageStack image) { int sizeX = image.getWidth(); int sizeY = image.getHeight(); int sizeZ = image.getSize(); for (int z = 0; z < sizeZ; z++) { for (int y = 0; y < sizeY; y++) { for (int x = 0; x < sizeX; x++) { image.setVoxel(x, y, z, 255 - image.getVoxel(x, y, z)); } } } }
private ImageStack invertGray8Image(ImageStack image) { ImageStack result = image.duplicate(); for(int z = 0; z < image.getSize(); z++) { for(int y = 0; y < image.getHeight(); y++) { for(int x = 0; x < image.getWidth(); x++) { result.setVoxel(x, y, z, 255 - image.getVoxel(x, y, z)); } } } return result; }
@Test public final void test_reconstructByDilation_CubicMeshC26() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); ImageStack result = Reconstruction3D.reconstructByDilation(marker, mask, 26); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testCubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstructionByDilation3DScanningGray8 algo = new GeodesicReconstructionByDilation3DScanningGray8(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationThinCubicMeshC6() { ImageStack mask = createThinCubicMeshImage(); ImageStack marker = ImageStack.create(5, 5, 5, 16); marker.setVoxel(0, 0, 0, 0x00FFFF); GeodesicReconstruction3DHybrid0Gray16 algo = new GeodesicReconstruction3DHybrid0Gray16(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(0x00FFFF, result.getVoxel(0, 4, 0), .01); }
@Test public final void testDilationThinCubicMeshC6() { ImageStack mask = createThinCubicMeshImage(); ImageStack marker = ImageStack.create(5, 5, 5, 8); marker.setVoxel(0, 0, 0, 255); GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(0, 4, 0), .01); }
@Test public final void testDilationThinCubicMeshC26() { ImageStack mask = createThinCubicMeshImage(); ImageStack marker = ImageStack.create(5, 5, 5, 8); marker.setVoxel(0, 0, 0, 255); GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(0, 4, 0), .01); }
@Test public final void testCubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstructionByDilation3DScanning algo = new GeodesicReconstructionByDilation3DScanning(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationCubicMeshC26() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 16); marker.setVoxel(5, 5, 5, 0x00FFFF); GeodesicReconstruction3DHybrid0Gray16 algo = new GeodesicReconstruction3DHybrid0Gray16(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(0x00FFFF, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationThinCubicMeshC26() { ImageStack mask = createThinCubicMeshImage(); ImageStack marker = ImageStack.create(5, 5, 5, 16); marker.setVoxel(0, 0, 0, 0x00FFFF); GeodesicReconstruction3DHybrid0Gray16 algo = new GeodesicReconstruction3DHybrid0Gray16(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(0x00FFFF, result.getVoxel(0, 4, 0), .01); }
@Test public final void testCubicMeshC26() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstructionByDilation3DScanningGray8 algo = new GeodesicReconstructionByDilation3DScanningGray8(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationCubicMeshC26() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstruction3DHybrid1Image3D algo = new GeodesicReconstruction3DHybrid1Image3D(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationThinCubicMeshC26() { ImageStack mask = createThinCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstruction3DHybrid1Image3D algo = new GeodesicReconstruction3DHybrid1Image3D(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testCubicMeshC26() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstructionByDilation3DScanning algo = new GeodesicReconstructionByDilation3DScanning(); algo.setConnectivity(26); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
@Test public final void testDilationCubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 16); marker.setVoxel(5, 5, 5, 1000); GeodesicReconstruction3DHybrid0Gray16 algo = new GeodesicReconstruction3DHybrid0Gray16(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(1000, result.getVoxel(5, 15, 5), .01); assertEquals(1000, result.getVoxel(15, 15, 15), .01); }
@Test public final void testDilationCubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8(); algo.setConnectivity(6); ImageStack result = algo.applyTo(marker, mask); assertEquals(255, result.getVoxel(5, 15, 5), .01); assertEquals(255, result.getVoxel(15, 15, 15), .01); }