/** Mask central offset / low freq spike to better use display range. */
 private void maskCentralRegion(ImagePlus imp) {
   int w = imp.getWidth();
   double d = this.maskDiameter * w;
   if (w % 2 == 0) {
     d += 1; // tweak to centre the mask about zero freq stripes
   }
   // N.B. we assume the image is square! (FFT result)
   OvalRoi mask = new OvalRoi(w / 2 - d / 2 + 1, w / 2 - d / 2 + 1, d, d);
   imp.setRoi(mask);
   for (int c = 1; c <= imp.getNChannels(); c++) {
     imp.setC(c);
     double min = I1l.getStatsForChannel(imp, c).min;
     IJ.run(imp, "Set...", "value=" + min + " slice");
   }
   imp.setC(1);
   imp.deleteRoi();
 }
Ejemplo n.º 2
0
 private boolean deleteOverlayRoi(ImagePlus imp) {
   if (imp == null) return false;
   Overlay overlay = null;
   ImageCanvas ic = imp.getCanvas();
   if (ic != null) overlay = ic.getShowAllList();
   if (overlay == null) overlay = imp.getOverlay();
   if (overlay == null) return false;
   Roi roi = imp.getRoi();
   for (int i = 0; i < overlay.size(); i++) {
     Roi roi2 = overlay.get(i);
     if (roi2 == roi) {
       overlay.remove(i);
       imp.deleteRoi();
       ic = imp.getCanvas();
       if (ic != null) ic.roiManagerSelect(roi, true);
       return true;
     }
   }
   return false;
 }