Ejemplo n.º 1
0
  /**
   * Prepare for processing; also called at the very end with argument 'final' to show any newly
   * created output image.
   */
  public int setup(String arg, ImagePlus imp) {
    if (arg.equals("final")) {
      showOutput();
      return DONE;
    }
    this.imp = imp;
    // 'arg' is processing type; default is 'EDM' (0)
    if (arg.equals("watershed")) {
      processType = WATERSHED;
      flags += KEEP_THRESHOLD;
    } else if (arg.equals("points")) processType = UEP;
    else if (arg.equals("voronoi")) processType = VORONOI;

    // output type
    if (processType != WATERSHED) // Watershed always has output BYTE_OVERWRITE=0
    outImageType = outputType; // otherwise use the static variable from setOutputType
    if (outImageType != BYTE_OVERWRITE) flags |= NO_CHANGES;

    // check image and prepare
    if (imp != null) {
      ImageProcessor ip = imp.getProcessor();
      if (!ip.isBinary()) {
        IJ.error("8-bit binary image (0 and 255) required.");
        return DONE;
      }
      ip.resetRoi();
      // processing routines assume background=0; image may be otherwise
      boolean invertedLut = imp.isInvertedLut();
      background255 =
          (invertedLut && Prefs.blackBackground) || (!invertedLut && !Prefs.blackBackground);
    }
    return flags;
  } // public int setup
Ejemplo n.º 2
0
 public void run(String arg) {
   ImagePlus imp = WindowManager.getCurrentImage();
   if (imp == null) {
     IJ.noImage();
     return;
   }
   if (imp.getStackSize() > 1) {
     IJ.error("This command requires a montage");
     return;
   }
   GenericDialog gd = new GenericDialog("Stack Maker");
   gd.addNumericField("Images_per_row: ", w, 0);
   gd.addNumericField("Images_per_column: ", h, 0);
   gd.addNumericField("Border width: ", b, 0);
   gd.showDialog();
   if (gd.wasCanceled()) return;
   w = (int) gd.getNextNumber();
   h = (int) gd.getNextNumber();
   b = (int) gd.getNextNumber();
   ImageStack stack = makeStack(imp.getProcessor(), w, h, b);
   new ImagePlus("Stack", stack).show();
 }
Ejemplo n.º 3
0
 /**
  * Called by the PlugInFilterRunner after setup. Asks the user in case of a stack and prepares a
  * separate ouptut stack if required
  */
 public int showDialog(ImagePlus imp, String command, PlugInFilterRunner pfr) {
   this.pfr = pfr;
   int width = imp.getWidth();
   int height = imp.getHeight();
   // ask whether to process all slices of stack & prepare stack
   // (if required) for writing into it in parallel threads
   flags = IJ.setupDialog(imp, flags);
   if ((flags & DOES_STACKS) != 0 && outImageType != BYTE_OVERWRITE) {
     outStack = new ImageStack(width, height, imp.getStackSize());
     maxFinder.setNPasses(imp.getStackSize());
   }
   return flags;
 } // public int showDialog
Ejemplo n.º 4
0
 /** add work done in the meanwhile and show progress */
 private void addProgress(double deltaProgress) {
   if (nPasses == 0) return;
   progressDone += deltaProgress;
   IJ.showProgress(progressDone / nPasses);
 }