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 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)); } } } }
@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 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 test_reconstructByDilation_CubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); ImageStack result = Reconstruction3D.reconstructByDilation(marker, mask, 6); assertEquals(255, result.getVoxel(5, 15, 5), .01); }
/** * Default settings are 4 connectivity, 16 bits image. */ @Test public void testFloodFillComponentsLabeling_Default() { ImageStack image = createNineCubesImage(); FloodFillComponentsLabeling3D algo = new FloodFillComponentsLabeling3D(); ImageStack result = algo.computeLabels(image); assertEquals(16, result.getBitDepth()); assertEquals(9, result.getVoxel(7, 7, 7), .1); }
/** * Using 6 connectivity should result in nine connected components. */ @Test public void testFloodFillComponentsLabeling_C6_Byte() { ImageStack image = createNineCubesImage(); FloodFillComponentsLabeling3D algo = new FloodFillComponentsLabeling3D(6, 8); ImageStack result = algo.computeLabels(image); assertEquals(8, result.getBitDepth()); assertEquals(9, result.getVoxel(7, 7, 7), .1); }
/** * Using 26 connectivity should result in one connected component. */ @Test public void testFloodFillComponentsLabeling_C26_Short() { ImageStack image = createNineCubesImage(); FloodFillComponentsLabeling3D algo = new FloodFillComponentsLabeling3D(26, 16); ImageStack result = algo.computeLabels(image); assertEquals(16, result.getBitDepth()); assertEquals(1, result.getVoxel(7, 7, 7), .1); }
@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 testDilationCubicMeshC6() { ImageStack mask = createCubicMeshImage(); ImageStack marker = ImageStack.create(20, 20, 20, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstruction3DHybrid1Image3D algo = new GeodesicReconstruction3DHybrid1Image3D(); 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, 8); marker.setVoxel(5, 5, 5, 255); GeodesicReconstruction3DHybrid0Gray8 algo = new GeodesicReconstruction3DHybrid0Gray8(); 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); 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 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); }