Exemplo n.º 1
0
 void scale(ImageProcessor ip) {
   if (newWindow) {
     Rectangle r = ip.getRoi();
     ImagePlus imp2 = imp.createImagePlus();
     imp2.setProcessor(title, ip.resize(newWidth, newHeight));
     Calibration cal = imp2.getCalibration();
     if (cal.scaled()) {
       cal.pixelWidth *= 1.0 / xscale;
       cal.pixelHeight *= 1.0 / yscale;
     }
     imp2.show();
     imp.trimProcessor();
     imp2.trimProcessor();
     imp2.changes = true;
   } else {
     if (processStack && imp.getStackSize() > 1) {
       Undo.reset();
       StackProcessor sp = new StackProcessor(imp.getStack(), ip);
       sp.scale(xscale, yscale, bgValue);
     } else {
       ip.snapshot();
       Undo.setup(Undo.FILTER, imp);
       ip.setSnapshotCopyMode(true);
       ip.scale(xscale, yscale);
       ip.setSnapshotCopyMode(false);
     }
     imp.killRoi();
     imp.updateAndDraw();
     imp.changes = true;
   }
 }
Exemplo n.º 2
0
 public void run(ImageProcessor ip) {
   int fg = Prefs.blackBackground ? 255 : 0;
   foreground = ip.isInvertedLut() ? 255 - fg : fg;
   background = 255 - foreground;
   ip.setSnapshotCopyMode(true);
   if (arg.equals("outline")) outline(ip);
   else if (arg.startsWith("fill")) fill(ip, foreground, background);
   else if (arg.startsWith("skel")) {
     ip.resetRoi();
     skeletonize(ip);
   } else if (arg.equals("erode") || arg.equals("dilate")) doIterations((ByteProcessor) ip, arg);
   else if (arg.equals("open")) {
     doIterations(ip, "erode");
     doIterations(ip, "dilate");
   } else if (arg.equals("close")) {
     doIterations(ip, "dilate");
     doIterations(ip, "erode");
   }
   ip.setSnapshotCopyMode(false);
   ip.setBinaryThreshold();
 }