use of io.github.mianalysis.mia.object.Workspaces in project mia by mianalysis.
the class BinaryOperations2DTest method testRunWithErode2DOperationHundredIters3DStackWhiteBG.
/**
* This test is designed to check that nothing goes astray when all objects have
* been eroded away
*
* @throws Exception
*/
@Test
public void testRunWithErode2DOperationHundredIters3DStackWhiteBG() throws Exception {
// Creating a new workspace
Workspaces workspaces = new Workspaces();
Workspace workspace = workspaces.getNewWorkspace(null, 1);
// Loading the test image and adding to workspace
String pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryobjects/BinaryObjects3D_8bit_whiteBG.zip").getPath(), "UTF-8");
ImagePlus ipl = IJ.openImage(pathToImage);
Image image = new Image("Test_image", ipl);
workspace.addImage(image);
pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryoperations/BinaryObjects3D_8bit_whiteBG_erode100.zip").getPath(), "UTF-8");
Image expectedImage = new Image("Expected", IJ.openImage(pathToImage));
// Initialising BinaryOperations
BinaryOperations2D binaryOperations = new BinaryOperations2D(new Modules());
binaryOperations.updateParameterValue(BinaryOperations2D.INPUT_IMAGE, "Test_image");
binaryOperations.updateParameterValue(BinaryOperations2D.APPLY_TO_INPUT, false);
binaryOperations.updateParameterValue(BinaryOperations2D.NUM_ITERATIONS, 100);
binaryOperations.updateParameterValue(BinaryOperations2D.OUTPUT_IMAGE, "Test_output");
binaryOperations.updateParameterValue(BinaryOperations2D.OPERATION_MODE, BinaryOperations2D.OperationModes.ERODE);
binaryOperations.updateParameterValue(BinaryOperations2D.BINARY_LOGIC, BinaryOperations2D.BinaryLogic.WHITE_BACKGROUND);
// Running Module
binaryOperations.execute(workspace);
// Checking the images in the workspace
assertEquals(2, workspace.getImages().size());
assertNotNull(workspace.getImage("Test_image"));
assertNotNull(workspace.getImage("Test_output"));
// Checking the output image has the expected calibration
Image outputImage = workspace.getImage("Test_output");
assertEquals(expectedImage, outputImage);
}
use of io.github.mianalysis.mia.object.Workspaces in project mia by mianalysis.
the class BinaryOperations2DTest method testRunWithFillHoles2DOperation5DStackWhiteBG.
@Test
public void testRunWithFillHoles2DOperation5DStackWhiteBG() throws Exception {
// Creating a new workspace
Workspaces workspaces = new Workspaces();
Workspace workspace = workspaces.getNewWorkspace(null, 1);
// Loading the test image and adding to workspace
String pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryobjects/BinaryObjects5D_8bit_whiteBG.zip").getPath(), "UTF-8");
ImagePlus ipl = IJ.openImage(pathToImage);
Image image = new Image("Test_image", ipl);
workspace.addImage(image);
pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryoperations/BinaryObjects5D_8bit_whiteBG_fillHoles2D.zip").getPath(), "UTF-8");
Image expectedImage = new Image("Expected", IJ.openImage(pathToImage));
// Initialising BinaryOperations
BinaryOperations2D binaryOperations = new BinaryOperations2D(new Modules());
binaryOperations.updateParameterValue(BinaryOperations2D.INPUT_IMAGE, "Test_image");
binaryOperations.updateParameterValue(BinaryOperations2D.APPLY_TO_INPUT, false);
binaryOperations.updateParameterValue(BinaryOperations2D.NUM_ITERATIONS, 1);
binaryOperations.updateParameterValue(BinaryOperations2D.OUTPUT_IMAGE, "Test_output");
binaryOperations.updateParameterValue(BinaryOperations2D.OPERATION_MODE, BinaryOperations2D.OperationModes.FILL_HOLES);
binaryOperations.updateParameterValue(BinaryOperations2D.BINARY_LOGIC, BinaryOperations2D.BinaryLogic.WHITE_BACKGROUND);
// Running Module
binaryOperations.execute(workspace);
// Checking the images in the workspace
assertEquals(2, workspace.getImages().size());
assertNotNull(workspace.getImage("Test_image"));
assertNotNull(workspace.getImage("Test_output"));
// Checking the output image has the expected calibration
Image outputImage = workspace.getImage("Test_output");
assertEquals(expectedImage, outputImage);
}
use of io.github.mianalysis.mia.object.Workspaces in project mia by mianalysis.
the class BinaryOperations2DTest method testRunWithDilate2DOperation2DStackWhiteBG.
@Test
public void testRunWithDilate2DOperation2DStackWhiteBG() throws Exception {
// Creating a new workspace
Workspaces workspaces = new Workspaces();
Workspace workspace = workspaces.getNewWorkspace(null, 1);
// Loading the test image and adding to workspace
String pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryobjects/BinaryObjects2D_8bit_whiteBG.zip").getPath(), "UTF-8");
ImagePlus ipl = IJ.openImage(pathToImage);
Image image = new Image("Test_image", ipl);
workspace.addImage(image);
pathToImage = URLDecoder.decode(this.getClass().getResource("/images/binaryoperations/BinaryObjects2D_8bit_whiteBG_dilate1.zip").getPath(), "UTF-8");
Image expectedImage = new Image("Expected", IJ.openImage(pathToImage));
// Initialising BinaryOperations
BinaryOperations2D binaryOperations = new BinaryOperations2D(new Modules());
binaryOperations.updateParameterValue(BinaryOperations2D.INPUT_IMAGE, "Test_image");
binaryOperations.updateParameterValue(BinaryOperations2D.APPLY_TO_INPUT, false);
binaryOperations.updateParameterValue(BinaryOperations2D.NUM_ITERATIONS, 1);
binaryOperations.updateParameterValue(BinaryOperations2D.OUTPUT_IMAGE, "Test_output");
binaryOperations.updateParameterValue(BinaryOperations2D.OPERATION_MODE, BinaryOperations2D.OperationModes.DILATE);
binaryOperations.updateParameterValue(BinaryOperations2D.BINARY_LOGIC, BinaryOperations2D.BinaryLogic.WHITE_BACKGROUND);
// Running Module
binaryOperations.execute(workspace);
// Checking the images in the workspace
assertEquals(2, workspace.getImages().size());
assertNotNull(workspace.getImage("Test_image"));
assertNotNull(workspace.getImage("Test_output"));
// Checking the output image has the expected calibration
Image outputImage = workspace.getImage("Test_output");
assertEquals(expectedImage, outputImage);
}
use of io.github.mianalysis.mia.object.Workspaces in project mia by mianalysis.
the class DistanceMapTest method testRunWithWhiteObjects2DBlackBackgroundSvensonUnmatchPixels.
@Test
public void testRunWithWhiteObjects2DBlackBackgroundSvensonUnmatchPixels() throws Exception {
// Creating a new workspace
Workspaces workspaces = new Workspaces();
Workspace workspace = workspaces.getNewWorkspace(null, 1);
// Loading the test image and adding to workspace
TestUtils.addImageToWorkspace(workspace, "/images/binaryobjects/BinaryObjects2D_8bit_blackBG.zip", inputImageName);
// Initialising BinaryOperations
DistanceMap distanceMap = new DistanceMap(new Modules());
distanceMap.updateParameterValue(DistanceMap.INPUT_IMAGE, inputImageName);
distanceMap.updateParameterValue(DistanceMap.OUTPUT_IMAGE, outputImageName);
distanceMap.updateParameterValue(DistanceMap.WEIGHT_MODE, DistanceMap.WeightModes.WEIGHTS_3_4_5_7);
distanceMap.updateParameterValue(DistanceMap.MATCH_Z_TO_X, false);
distanceMap.updateParameterValue(DistanceMap.SPATIAL_UNITS_MODE, DistanceMap.SpatialUnitsModes.PIXELS);
distanceMap.updateParameterValue(DistanceMap.BINARY_LOGIC, DistanceMap.BinaryLogic.BLACK_BACKGROUND);
// Running Module
distanceMap.execute(workspace);
// Checking the images in the workspace
String expectedImagePath = "/images/distancemap3D/DistanceMap3D_insideObjects_svensson_unmatch_pixels_2D.tif.zip";
testImage(workspace, expectedImagePath);
}
use of io.github.mianalysis.mia.object.Workspaces in project mia by mianalysis.
the class DistanceMapTest method testRunWithWhiteObjects5DBlackBackgroundSvensonMatchCalibrated.
@Test
public void testRunWithWhiteObjects5DBlackBackgroundSvensonMatchCalibrated() throws Exception {
// Creating a new workspace
Workspaces workspaces = new Workspaces();
Workspace workspace = workspaces.getNewWorkspace(null, 1);
// Loading the test image and adding to workspace
TestUtils.addImageToWorkspace(workspace, "/images/binaryobjects/BinaryObjects5D_8bit_blackBG_diffC.zip", inputImageName);
// Initialising BinaryOperations
DistanceMap distanceMap = new DistanceMap(new Modules());
distanceMap.updateParameterValue(DistanceMap.INPUT_IMAGE, inputImageName);
distanceMap.updateParameterValue(DistanceMap.OUTPUT_IMAGE, outputImageName);
distanceMap.updateParameterValue(DistanceMap.WEIGHT_MODE, DistanceMap.WeightModes.WEIGHTS_3_4_5_7);
distanceMap.updateParameterValue(DistanceMap.MATCH_Z_TO_X, true);
distanceMap.updateParameterValue(DistanceMap.SPATIAL_UNITS_MODE, DistanceMap.SpatialUnitsModes.CALIBRATED);
distanceMap.updateParameterValue(DistanceMap.BINARY_LOGIC, DistanceMap.BinaryLogic.BLACK_BACKGROUND);
// Running Module
distanceMap.execute(workspace);
// Checking the images in the workspace
String expectedImagePath = "/images/distancemap3D/DistanceMap3D_insideObjects_svensson_match_cal_5D.tif.zip";
testImage(workspace, expectedImagePath);
}
Aggregations