Skip to content

Commit

Permalink
plugins/MorphologicalReconstruction(2D/3D): terminate plugin when ima…
Browse files Browse the repository at this point in the history
…ge size do not match
  • Loading branch information
dlegland committed Mar 2, 2022
1 parent 7a67ba9 commit 8ca9f1a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public void run(String arg) {
if (!Images3D.isSameSize(marker, mask))
{
IJ.error("Image Size Error", "Both marker and mask images must have same size");
return;
}

long t0 = System.currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,22 +194,27 @@ public void run(String arg)
Connectivity2D conn = Connectivity2D.fromLabel(gd.getNextChoice());

// Extract image procesors
ImageProcessor markerProc = markerImage.getProcessor();
ImageProcessor maskProc = maskImage.getProcessor();

ImageProcessor marker = markerImage.getProcessor();
ImageProcessor mask = maskImage.getProcessor();
if (marker.getWidth() != mask.getWidth() || marker.getHeight() != mask.getHeight())
{
IJ.error("Image Size Error", "Both marker and mask images must have same size");
return;
}

long t0 = System.currentTimeMillis();

// Compute geodesic reconstruction
ImageProcessor recProc = op.applyTo(markerProc, maskProc, conn);
// Compute morphological reconstruction
ImageProcessor res = op.applyTo(marker, mask, conn);

// Keep same color model
recProc.setColorModel(maskProc.getColorModel());
res.setColorModel(mask.getColorModel());

// create resulting image
String newName = createResultImageName(markerImage);
ImagePlus resultImage = new ImagePlus(newName, recProc);
resultImage.copyScale(maskImage);
resultImage.show();
ImagePlus resPlus = new ImagePlus(newName, res);
resPlus.copyScale(maskImage);
resPlus.show();

long t1 = System.currentTimeMillis();
IJUtils.showElapsedTime(op.toString(), t1 - t0, markerImage);
Expand Down

0 comments on commit 8ca9f1a

Please sign in to comment.