Search in sources :

Example 16 with Workspaces

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);
}
Also used : Modules(io.github.mianalysis.mia.module.Modules) Workspaces(io.github.mianalysis.mia.object.Workspaces) Image(io.github.mianalysis.mia.object.Image) ImagePlus(ij.ImagePlus) Workspace(io.github.mianalysis.mia.object.Workspace) Test(org.junit.jupiter.api.Test) ModuleTest(io.github.mianalysis.mia.module.ModuleTest)

Example 17 with Workspaces

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);
}
Also used : Modules(io.github.mianalysis.mia.module.Modules) Workspaces(io.github.mianalysis.mia.object.Workspaces) Image(io.github.mianalysis.mia.object.Image) ImagePlus(ij.ImagePlus) Workspace(io.github.mianalysis.mia.object.Workspace) Test(org.junit.jupiter.api.Test) ModuleTest(io.github.mianalysis.mia.module.ModuleTest)

Example 18 with Workspaces

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);
}
Also used : Modules(io.github.mianalysis.mia.module.Modules) Workspaces(io.github.mianalysis.mia.object.Workspaces) Image(io.github.mianalysis.mia.object.Image) ImagePlus(ij.ImagePlus) Workspace(io.github.mianalysis.mia.object.Workspace) Test(org.junit.jupiter.api.Test) ModuleTest(io.github.mianalysis.mia.module.ModuleTest)

Example 19 with Workspaces

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);
}
Also used : Modules(io.github.mianalysis.mia.module.Modules) Workspaces(io.github.mianalysis.mia.object.Workspaces) Workspace(io.github.mianalysis.mia.object.Workspace) Test(org.junit.jupiter.api.Test) ModuleTest(io.github.mianalysis.mia.module.ModuleTest)

Example 20 with Workspaces

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);
}
Also used : Modules(io.github.mianalysis.mia.module.Modules) Workspaces(io.github.mianalysis.mia.object.Workspaces) Workspace(io.github.mianalysis.mia.object.Workspace) Test(org.junit.jupiter.api.Test) ModuleTest(io.github.mianalysis.mia.module.ModuleTest)

Aggregations

Workspaces (io.github.mianalysis.mia.object.Workspaces)421 Workspace (io.github.mianalysis.mia.object.Workspace)418 Image (io.github.mianalysis.mia.object.Image)341 ImagePlus (ij.ImagePlus)323 ModuleTest (io.github.mianalysis.mia.module.ModuleTest)304 Test (org.junit.jupiter.api.Test)304 Modules (io.github.mianalysis.mia.module.Modules)233 Objs (io.github.mianalysis.mia.object.Objs)112 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)112 EnumSource (org.junit.jupiter.params.provider.EnumSource)112 Obj (io.github.mianalysis.mia.object.Obj)108 Objects3D (io.github.mianalysis.mia.expectedobjects.Objects3D)79 Parameters (io.github.mianalysis.mia.object.parameters.Parameters)36 File (java.io.File)26 SpatCal (io.github.sjcross.common.object.volume.SpatCal)23 Disabled (org.junit.jupiter.api.Disabled)19 CropImage (io.github.mianalysis.mia.module.images.transform.CropImage)18 Status (io.github.mianalysis.mia.object.Status)13 CalculateNearestNeighbour (io.github.mianalysis.mia.module.objects.measure.spatial.CalculateNearestNeighbour)10 Objects2D (io.github.mianalysis.mia.expectedobjects.Objects2D)7