public void setMask(ImageProcessor mask) { record("setMask", mask, ImageProcessor.class); proc.setMask(mask); }
public void setMask(ImageProcessor mask) { record("setMask", mask, ImageProcessor.class); proc.setMask(mask); }
ip.setMask(mask); // restore ROI ip.setRoi(roi);
/** Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask. After processing, call <code>reset(mask)</code> to restore non-masked pixels. Here is an example: <pre> ip.setRoi(new OvalRoi(50, 50, 100, 50)); ip.fill(); ip.reset(ip.getMask()); </pre> The example assumes <code>snapshot()</code> has been called, which is the case for code executed in the <code>run()</code> method of plugins that implement the <code>PlugInFilter</code> interface. @see ij.ImagePlus#getRoi */ public void setRoi(Roi roi) { if (roi==null) resetRoi(); else { if (roi instanceof PointRoi && ((PointRoi)roi).getNCoordinates()==1) { setMask(null); FloatPolygon p = roi.getFloatPolygon(); setRoi((int)p.xpoints[0], (int)p.ypoints[0], 1, 1); } else { setMask(roi.getMask()); setRoi(roi.getBounds()); } } }
/** For images with irregular ROIs, returns a byte mask, otherwise, returns * null. Mask pixels have a non-zero value.and the dimensions of the * mask are equal to the width and height of the ROI. * @see ij.ImagePlus#createRoiMask * @see ij.ImagePlus#createThresholdMask */ public ImageProcessor getMask() { if (roi==null) { if (ip!=null) ip.resetRoi(); return null; } ImageProcessor mask = roi.getMask(); if (mask==null) return null; if (ip!=null && roi!=null) { ip.setMask(mask); ip.setRoi(roi.getBounds()); } return mask; }
/** Defines a non-rectangular region of interest that will consist of a rectangular ROI and a mask. After processing, call <code>reset(mask)</code> to restore non-masked pixels. Here is an example: <pre> ip.setRoi(new OvalRoi(50, 50, 100, 50)); ip.fill(); ip.reset(ip.getMask()); </pre> The example assumes <code>snapshot()</code> has been called, which is the case for code executed in the <code>run()</code> method of plugins that implement the <code>PlugInFilter</code> interface. @see ij.ImagePlus#getRoi */ public void setRoi(Roi roi) { if (roi==null) resetRoi(); else { if (roi instanceof PointRoi && ((PointRoi)roi).getNCoordinates()==1) { setMask(null); FloatPolygon p = roi.getFloatPolygon(); setRoi((int)p.xpoints[0], (int)p.ypoints[0], 1, 1); } else { setMask(roi.getMask()); setRoi(roi.getBounds()); } } }
/** For images with irregular ROIs, returns a byte mask, otherwise, returns * null. Mask pixels have a non-zero value.and the dimensions of the * mask are equal to the width and height of the ROI. * @see ij.ImagePlus#createRoiMask * @see ij.ImagePlus#createThresholdMask */ public ImageProcessor getMask() { if (roi==null) { if (ip!=null) ip.resetRoi(); return null; } ImageProcessor mask = roi.getMask(); if (mask==null) return null; if (ip!=null && roi!=null) { ip.setMask(mask); ip.setRoi(roi.getBounds()); } return mask; }
/** * Assigns the specified ROI to this image and displays it without saving it * as previousRoi as it is done by <code>setRoi()</code>. */ public void putRoi(Roi newRoi) { Rectangle bounds = new Rectangle(); if (newRoi != null) { // Roi with width and height = 0 is same as null Roi. bounds = newRoi.getBounds(); if (bounds.width == 0 && bounds.height == 0 && newRoi.getType() != Roi.POINT) { newRoi = null; } } roi = newRoi; if (roi != null) { if (ip != null) { ip.setMask(null); if (roi.isArea()) ip.setRoi(bounds); else ip.resetRoi(); } roi.setImage(this); } draw(); }
/** * Assigns the specified ROI to this image and displays it without saving it * as previousRoi as it is done by <code>setRoi()</code>. */ public void putRoi(Roi newRoi) { Rectangle bounds = new Rectangle(); if (newRoi != null) { // Roi with width and height = 0 is same as null Roi. bounds = newRoi.getBounds(); if (bounds.width == 0 && bounds.height == 0 && newRoi.getType() != Roi.POINT) { newRoi = null; } } roi = newRoi; if (roi != null) { if (ip != null) { ip.setMask(null); if (roi.isArea()) ip.setRoi(bounds); else ip.resetRoi(); } roi.setImage(this); } draw(); }
ImageStatistics getRedirectStats(int measurements, Roi roi) { ImagePlus redirectImp = getRedirectImageOrStack(imp); if (redirectImp==null) return null; ImageProcessor ip = redirectImp.getProcessor(); if (imp.getTitle().equals("mask") && imp.getBitDepth()==8) { ip.setMask(imp.getProcessor()); ip.setRoi(0, 0, imp.getWidth(), imp.getHeight()); } else ip.setRoi(roi); return ImageStatistics.getStatistics(ip, measurements, redirectImp.getCalibration()); }
ImageStatistics getRedirectStats(int measurements, Roi roi) { ImagePlus redirectImp = getRedirectImageOrStack(imp); if (redirectImp==null) return null; ImageProcessor ip = redirectImp.getProcessor(); if (imp.getTitle().equals("mask") && imp.getBitDepth()==8) { ip.setMask(imp.getProcessor()); ip.setRoi(0, 0, imp.getWidth(), imp.getHeight()); } else ip.setRoi(roi); return ImageStatistics.getStatistics(ip, measurements, redirectImp.getCalibration()); }
pf.setPolygon(roi.xpoints, roi.ypoints, roi.npoints); ImageProcessor mask = pf.getMask(bounds.width, bounds.height); setMask(mask); setRoi(bounds); for (int i=0; i<roi.npoints; i++) {
public void setRoi(Rectangle r) { if (null==r) { killRoi(); return; } killRoi(); this.roi = new Roi(r.x, r.y, r.width, r.height); this.roi.setImage(this); ImagePlus imp = patch[currentSlice-1].getProject().getLoader().fetchImagePlus(patch[currentSlice-1]); ImageProcessor ip = imp.getProcessor(); if (null != ip) { ip.setMask(null); ip.setRoi(r); } //draw(); // not needed }
public ImageProcessor getMask() { ImagePlus imp = patch[currentSlice-1].getProject().getLoader().fetchImagePlus(patch[currentSlice-1]); ImageProcessor ip = imp.getProcessor(); Roi roi = getRoi(); if (null == roi) { ip.resetRoi(); return null; } ImageProcessor mask = roi.getMask(); if (null==mask) return null; ip.setMask(mask); ip.setRoi(roi.getBounds()); return mask; }
/** 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); }
/** 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); }
min = ip2.getMin(); max = ip2.getMax(); ip2 = ip2.convertToByte(true); ip2.setMask(mask); ip2.setRoi(rect);
public void setRoi(Roi roi) { killRoi(); //super.setRoi(roi); // needed ? If roi is protected, no if (null==roi) { this.roi = null; return; } // translate roi to Patch coordinate system Rectangle b = getBounds(); Roi roi2 = (Roi)roi.clone(); Rectangle r = roi2.getBounds(); roi2.setLocation(r.x - b.x, r.y - b.y); roi = roi2; if (roi.isVisible()) roi = (Roi)roi.clone(); Rectangle bounds = roi.getBounds(); if (0==bounds.width && 0==bounds.height) return; this.roi = roi; ImagePlus imp = patch[currentSlice-1].getProject().getLoader().fetchImagePlus(patch[currentSlice-1]); imp.setRoi(roi); ImageProcessor ip = imp.getProcessor(); if (null!=ip) { ip.setMask(null); ip.setRoi(bounds); } this.roi.setImage(this); //draw(); //not needed //stack.setRoi(roi.getBounds()); // doesn't make a difference because I'm setting the Roi at VirtualStack.getProcessor(int) as well. }