@Override public ImageProcessor getMask() { record("getMask"); return proc.getMask(); }
@Override public ImageProcessor getMask() { record("getMask"); return proc.getMask(); }
/** Fills a polygon. */ public void fillPolygon(Polygon p) { setRoi(p); fill(getMask()); resetRoi(); }
/** Fills a polygon. */ public void fillPolygon(Polygon p) { setRoi(p); fill(getMask()); resetRoi(); }
/** Gaussian Filtering of an ImageProcessor. This method is for compatibility with the * previous code (before 1.38r) and uses a low-accuracy kernel, only slightly better * than the previous ImageJ code. * The 'radius' in this call is different from the one used in ImageJ 1.38r and later. * Therefore, use blurGaussian(ip, sigma, sigma, accuracy), where 'sigma' is equivalent * to the 'sigma (radius)' of the Menu, and accuracy should be 0.02 unless better * accuracy is desired. */ @Deprecated public boolean blur(ImageProcessor ip, double radius) { Rectangle roi = ip.getRoi(); if (roi.height!=ip.getHeight() && ip.getMask()==null) ip.snapshot(); // a snapshot is needed for out-of-Rectangle pixels blurGaussian(ip, 0.4*radius, 0.4*radius, 0.01); return true; }
void applyTable(ImageProcessor ip, int[] lut) { if (updateSelectionOnly) { ImageProcessor mask = ip.getMask(); if (mask!=null) ip.snapshot(); ip.applyTable(lut); if (mask!=null) ip.reset(mask); } else ip.applyTable(lut); }
/** Gaussian Filtering of an ImageProcessor. This method is for compatibility with the * previous code (before 1.38r) and uses a low-accuracy kernel, only slightly better * than the previous ImageJ code. * The 'radius' in this call is different from the one used in ImageJ 1.38r and later. * Therefore, use blurGaussian(ip, sigma, sigma, accuracy), where 'sigma' is equivalent * to the 'sigma (radius)' of the Menu, and accuracy should be 0.02 unless better * accuracy is desired. */ @Deprecated public boolean blur(ImageProcessor ip, double radius) { Rectangle roi = ip.getRoi(); if (roi.height!=ip.getHeight() && ip.getMask()==null) ip.snapshot(); // a snapshot is needed for out-of-Rectangle pixels blurGaussian(ip, 0.4*radius, 0.4*radius, 0.01); return true; }
public void makeMask(ImageProcessor ip, Rectangle r) { mask = ip.getMask(); if (mask==null) { mask = new ByteProcessor(r.width, r.height); mask.invert(); } else { // duplicate mask (needed because getMask caches masks) mask = mask.duplicate(); } mask.invert(); }
public void makeMask(ImageProcessor ip, Rectangle r) { mask = ip.getMask(); if (mask==null) { mask = new ByteProcessor(r.width, r.height); mask.invert(); } else { // duplicate mask (needed because getMask caches masks) mask = mask.duplicate(); } mask.invert(); }
void applyTable(ImageProcessor ip, int[] lut) { if (updateSelectionOnly) { ImageProcessor mask = ip.getMask(); if (mask!=null) ip.snapshot(); ip.applyTable(lut); if (mask!=null) ip.reset(mask); } else ip.applyTable(lut); }
/** Fills outside an Roi. */ public void fillOutside(Roi roi) { if (roi==null || !roi.isArea()) return; ImageProcessor m = getMask(); Rectangle r = getRoi(); ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi)roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0,0, width, height)); setRoi(s1.xor(s2)); fill(getMask()); setMask(m); setRoi(r); }
/** Fills the ROI with the current fill/draw value. * @see #setColor(Color) * @see #setValue(double) * @see #fill(Roi) */ public void fill(Roi roi) { if (roi!=null && roi.isLine()) { if ((roi instanceof Line) && roi.getStrokeWidth()>1 && !(roi instanceof Arrow)) fillPolygon(roi.getPolygon()); else roi.drawPixels(this); return; } ImageProcessor m = getMask(); Rectangle r = getRoi(); setRoi(roi); fill(getMask()); setMask(m); setRoi(r); }
/** Fills outside an Roi. */ public void fillOutside(Roi roi) { if (roi==null || !roi.isArea()) return; ImageProcessor m = getMask(); Rectangle r = getRoi(); ShapeRoi s1, s2; if (roi instanceof ShapeRoi) s1 = (ShapeRoi)roi; else s1 = new ShapeRoi(roi); s2 = new ShapeRoi(new Roi(0,0, width, height)); setRoi(s1.xor(s2)); fill(getMask()); setMask(m); setRoi(r); }
/** Restore image outside non-rectangular roi. */ void doMasking(ImagePlus imp, ImageProcessor ip) { ImageProcessor mask = imp.getMask(); if (mask!=null) { Rectangle r = ip.getRoi(); if (mask.getWidth()!=r.width||mask.getHeight()!=r.height) { ip.setRoi(imp.getRoi()); mask = ip.getMask(); } ip.reset(mask); } }
/** Restore image outside non-rectangular roi. */ void doMasking(ImagePlus imp, ImageProcessor ip) { ImageProcessor mask = imp.getMask(); if (mask!=null) { Rectangle r = ip.getRoi(); if (mask.getWidth()!=r.width||mask.getHeight()!=r.height) { ip.setRoi(imp.getRoi()); mask = ip.getMask(); } ip.reset(mask); } }
/** Paints an approximation of the pipe into the set of slices. */ static public void paint(final Pipe pipe, final Map<Layer,ImageProcessor> slices, final int value, final float scale) { final VectorString3D vs = pipe.asVectorString3D(); vs.resample(1); // one pixel final double[] px = vs.getPoints(0); final double[] py = vs.getPoints(1); final double[] pz = vs.getPoints(2); final double[] pr = vs.getDependent(0); // For each point for (int i=0; i<px.length-1; i++) { final ImageProcessor ip = slices.get(pipe.getLayerSet().getNearestLayer(pz[i])); if (null == ip) continue; final OvalRoi ov = new OvalRoi((int)((px[i] - pr[i]) * scale), (int)((py[i] - pr[i]) * scale), (int)(pr[i]*2*scale), (int)(pr[i]*2*scale)); ip.setRoi(ov); ip.setValue(value); ip.fill(ip.getMask()); } }
void updatePaste() { if (clipboard!=null) { imp.getMask(); ImageProcessor ip = imp.getProcessor(); ip.reset(); int xoffset=0, yoffset=0; Roi croi = clipboard.getRoi(); if (croi!=null) { Rectangle r = croi.getBounds(); if (r.x<0) xoffset=-r.x; if (r.y<0) yoffset=-r.y; } ip.copyBits(clipboard.getProcessor(), x+xoffset, y+yoffset, pasteMode); if (type!=RECTANGLE) ip.reset(ip.getMask()); if (ic!=null) ic.setImageUpdated(); } }
void doIPMethod(int type) { interp.getParens(); ImageProcessor ip = getProcessor(); switch (type) { case SNAPSHOT: ip.snapshot(); break; case RESET: ip.reset(); updateNeeded = true; break; case FILL: ImagePlus imp = getImage(); Roi roi = imp.getRoi(); if (!colorSet) setForegroundColor(ip); if (roi==null) { ip.resetRoi(); ip.fill(); } else { ip.setRoi(roi); ip.fill(ip.getMask()); } imp.updateAndDraw(); break; } }
void applyRGB(ImagePlus imp, ImageProcessor ip) { double min = imp.getDisplayRangeMin(); double max = imp.getDisplayRangeMax(); ip.setRoi(imp.getRoi()); ip.reset(); if (channels!=7) ((ColorProcessor)ip).setMinAndMax(min, max, channels); else ip.setMinAndMax(min, max); ip.reset(ip.getMask()); imp.changes = true; previousImageID = 0; ((ColorProcessor)ip).caSnapshot(false); setup(); if (Recorder.record) { if (Recorder.scriptMode()) Recorder.recordCall("IJ.run(imp, \"Apply LUT\", \"\");"); else Recorder.record("run", "Apply LUT"); } }
public void processOpenButton() { // Convert to mask ImagePlus image = cc.getImage(); ImageProcessor ip = image.getProcessor(); ImageProcessor newip = new ByteProcessor( ip.getWidth(), ip.getHeight()); newip.setBackgroundValue(0); newip.setRoi(image.getRoi()); newip.setValue(255); newip.fill(newip.getMask()); // open newip.erode(); newip.dilate(); // convert back to selection newip.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ImagePlus tmp = new ImagePlus(" ", newip); ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", tmp); ts.run(newip); newip.resetThreshold(); image.setRoi(tmp.getRoi()); }