Ejemplo n.º 1
0
 void createMaskFromThreshold(ImagePlus imp) {
   ImageProcessor ip = imp.getProcessor();
   if (ip.getMinThreshold() == ImageProcessor.NO_THRESHOLD) {
     IJ.error("Create Mask", "Area selection or thresholded image required");
     return;
   }
   double t1 = ip.getMinThreshold();
   double t2 = ip.getMaxThreshold();
   IJ.run("Duplicate...", "title=mask");
   ImagePlus imp2 = WindowManager.getCurrentImage();
   ImageProcessor ip2 = imp2.getProcessor();
   ip2.setThreshold(t1, t2, ImageProcessor.NO_LUT_UPDATE);
   IJ.run("Convert to Mask");
 }
Ejemplo n.º 2
0
 void createSelectionFromMask(ImagePlus imp) {
   ImageProcessor ip = imp.getProcessor();
   if (ip.getMinThreshold() != ImageProcessor.NO_THRESHOLD) {
     IJ.runPlugIn("ij.plugin.filter.ThresholdToSelection", "");
     return;
   }
   if (!ip.isBinary()) {
     IJ.error(
         "Create Selection",
         "This command creates a composite selection from\n"
             + "a mask (8-bit binary image with white background)\n"
             + "or from an image that has been thresholded using\n"
             + "the Image>Adjust>Threshold tool. The current\n"
             + "image is not a mask and has not been thresholded.");
     return;
   }
   int threshold = ip.isInvertedLut() ? 255 : 0;
   ip.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE);
   IJ.runPlugIn("ij.plugin.filter.ThresholdToSelection", "");
 }