public int setup(String arg, ImagePlus imp) {
   this.arg = arg;
   this.imp = imp;
   IJ.register(ParticleAnalyzer.class);
   if (imp == null) {
     IJ.noImage();
     return DONE;
   }
   if (imp.getBitDepth() == 24 && !isThresholdedRGB(imp)) {
     IJ.error(
         "Particle Analyzer",
         "RGB images must be thresholded using\n" + "Image>Adjust>Color Threshold.");
     return DONE;
   }
   if (!showDialog()) return DONE;
   int baseFlags = DOES_ALL + NO_CHANGES + NO_UNDO;
   int flags = IJ.setupDialog(imp, baseFlags);
   processStack = (flags & DOES_STACKS) != 0;
   slice = 0;
   saveRoi = imp.getRoi();
   if (saveRoi != null && saveRoi.getType() != Roi.RECTANGLE && saveRoi.isArea())
     polygon = saveRoi.getPolygon();
   imp.startTiming();
   nextFontSize = defaultFontSize;
   nextLineWidth = 1;
   return flags;
 }
Example #2
0
 public void run(String arg) {
   imp = IJ.getImage();
   Roi roi = imp.getRoi();
   if (roi != null && !roi.isArea()) imp.killRoi(); // ignore any line selection
   ImageProcessor ip = imp.getProcessor();
   if (!showDialog(ip)) return;
   if (ip.getWidth() > 1 && ip.getHeight() > 1) ip.setInterpolate(interpolate);
   else ip.setInterpolate(false);
   ip.setBackgroundValue(bgValue);
   imp.startTiming();
   try {
     if (newWindow && imp.getStackSize() > 1 && processStack) createNewStack(imp, ip);
     else scale(ip);
   } catch (OutOfMemoryError o) {
     IJ.outOfMemory("Scale");
   }
   IJ.showProgress(1.0);
 }
Example #3
0
  /*------------------------------------------------------------------*/
  public void run(String arg) {
    ImagePlus imp = WindowManager.getCurrentImage();
    this.imp = imp;
    if (imp == null) {
      IJ.noImage();
      return;
    }
    if ((1 < imp.getStackSize()) && (imp.getType() == imp.COLOR_256)) {
      IJ.error("Stack of color images not supported (use grayscale)");
      return;
    }
    if (1 < imp.getStackSize()) {
      if (imp.getStack().isRGB()) {
        IJ.error("RGB color images not supported (use grayscale)");
        return;
      }
    }
    if (1 < imp.getStackSize()) {
      if (imp.getStack().isHSB()) {
        IJ.error("HSB color images not supported (use grayscale)");
        return;
      }
    }
    if (imp.getType() == imp.COLOR_256) {
      IJ.error("Indexed color images not supported (use grayscale)");
      return;
    }
    if (imp.getType() == imp.COLOR_RGB) {
      IJ.error("Color images not supported (use grayscale)");
      return;
    }

    differentialsDialog dialog =
        new differentialsDialog(IJ.getInstance(), "Differentials", true, operation);
    GUI.center(dialog);
    dialog.setVisible(true);
    cancel = dialog.getCancel();
    operation = dialog.getOperation();
    dialog.dispose();
    if (cancel) {
      return;
    }

    imp.startTiming();
    if (1 < imp.getStackSize()) {
      if (!(imp.getProcessor().getPixels() instanceof float[])) {
        new StackConverter(imp).convertToGray32();
      }
    } else {
      if (!(imp.getProcessor().getPixels() instanceof float[])) {
        new ImageConverter(imp).convertToGray32();
      }
    }
    ImageStack stack = imp.getStack();
    stackSize = stack.getSize();
    Undo.reset();

    setupProgressBar();
    resetProgressBar();

    for (int i = 1; (i <= stackSize); i++) {
      ImageProcessor ip = stack.getProcessor(i);
      doIt(ip);
      imp.getProcessor().resetMinAndMax();
      imp.setSlice(i);
      imp.updateAndRepaintWindow();
    }
    imp.getProcessor().resetMinAndMax();
    imp.setSlice(1);
    imp.updateAndRepaintWindow();
    cleanUpProgressBar();
    IJ.showTime(imp, imp.getStartTime(), "Differentials: ");
    ImageWindow win = imp.getWindow();
    if (win != null) {
      win.running = false;
    }
  } /* end run */