public void run(ImageProcessor ip) { showStatus = true; image.setRoi(convert(ip)); }
public void run(ImageProcessor ip) { showStatus = true; image.setRoi(convert(ip)); }
/** Returns a selection created from the thresholded pixels in the specified image, or null if there are no thresholded pixels. */ public static Roi run(ImagePlus imp) { ThresholdToSelection tts = new ThresholdToSelection(); return tts.convert(imp.getProcessor()); }
/** Returns a selection created from the thresholded pixels in the specified image, or null if there are no thresholded pixels. */ public static Roi run(ImagePlus imp) { ThresholdToSelection tts = new ThresholdToSelection(); return tts.convert(imp.getProcessor()); }
void createSelection() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) return; int saveMode = mode; mode = BLACK_AND_WHITE; apply(imp); mode = saveMode; ImageProcessor ip = imp.getProcessor().convertToByte(false); int fg = Prefs.blackBackground?255:0; ip.setThreshold(fg, fg, ImageProcessor.NO_LUT_UPDATE); Roi roi = (new ThresholdToSelection()).convert(ip); reset(imp); imp.setRoi(roi); }
void createSelection() { ImagePlus imp = WindowManager.getCurrentImage(); if (imp==null) return; int saveMode = mode; mode = BLACK_AND_WHITE; apply(imp); mode = saveMode; ImageProcessor ip = imp.getProcessor().convertToByte(false); int fg = Prefs.blackBackground?255:0; ip.setThreshold(fg, fg, ImageProcessor.NO_LUT_UPDATE); Roi roi = (new ThresholdToSelection()).convert(ip); reset(imp); imp.setRoi(roi); }
final Roi imagejroi = plugin.convert(ip); imagejroi.setLocation(x, y); ShapeRoi roi = new ShapeRoi(imagejroi);
Roi convertLineToPolygon(Roi roi, ImageProcessor ip) { if (roi==null) return null; ip.resetRoi(); ip.setColor(0); ip.fill(); ip.setColor(255); if (roi.getType()==Roi.LINE && roi.getStrokeWidth()>1) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip); //new ImagePlus("ip", ip.duplicate()).show(); ip.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); return tts.convert(ip); }
Roi convertLineToPolygon(Roi roi, ImageProcessor ip) { if (roi==null) return null; ip.resetRoi(); ip.setColor(0); ip.fill(); ip.setColor(255); if (roi.getType()==Roi.LINE && roi.getStrokeWidth()>1) ip.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip); //new ImagePlus("ip", ip.duplicate()).show(); ip.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); return tts.convert(ip); }
ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); roi2 = tts.convert(ip2); if (roi2==null) return roi;
public FloatPolygon getFloatPolygon() { if (cornerDiameter>0) { ImageProcessor ip = getMask(); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2!=null) { roi2.setLocation(x, y); return roi2.getFloatPolygon(); } } if (subPixelResolution() && bounds!=null) { float[] xpoints = new float[4]; float[] ypoints = new float[4]; xpoints[0] = (float)bounds.x; ypoints[0] = (float)bounds.y; xpoints[1] = (float)(bounds.x+bounds.width); ypoints[1] = (float)bounds.y; xpoints[2] = (float)(bounds.x+bounds.width); ypoints[2] = (float)(bounds.y+bounds.height); xpoints[3] = (float)bounds.x; ypoints[3] = (float)(bounds.y+bounds.height); return new FloatPolygon(xpoints, ypoints); } else { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); } }
ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); roi2 = tts.convert(ip2); if (roi2==null) return roi;
public FloatPolygon getFloatPolygon() { if (cornerDiameter>0) { ImageProcessor ip = getMask(); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2!=null) { roi2.setLocation(x, y); return roi2.getFloatPolygon(); } } if (subPixelResolution() && bounds!=null) { float[] xpoints = new float[4]; float[] ypoints = new float[4]; xpoints[0] = (float)bounds.x; ypoints[0] = (float)bounds.y; xpoints[1] = (float)(bounds.x+bounds.width); ypoints[1] = (float)bounds.y; xpoints[2] = (float)(bounds.x+bounds.width); ypoints[2] = (float)(bounds.y+bounds.height); xpoints[3] = (float)bounds.x; ypoints[3] = (float)(bounds.y+bounds.height); return new FloatPolygon(xpoints, ypoints); } else { Polygon p = getPolygon(); return new FloatPolygon(toFloat(p.xpoints), toFloat(p.ypoints), p.npoints); } }
private static Roi shrink(Roi roi, int n) { Rectangle bounds = roi.getBounds(); int width = bounds.width + 2; int height = bounds.height + 2; ImageProcessor ip = new ByteProcessor(width, height); roi.setLocation(1, 1); ip.setColor(255); ip.fill(roi); roi.setLocation(bounds.x, bounds.y); boolean bb = Prefs.blackBackground; Prefs.blackBackground = true; new EDM().toEDM(ip); Prefs.blackBackground = bb; ip.setThreshold(n+1, 255, ImageProcessor.NO_LUT_UPDATE); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2==null) return roi; Rectangle bounds2 = roi2.getBounds(); if (bounds2.width<=0 && bounds2.height<=0) return roi; roi2.setLocation(bounds.x+bounds2.x-1, bounds.y+bounds2.y-1); return roi2; }
private static Roi shrink(Roi roi, int n) { Rectangle bounds = roi.getBounds(); int width = bounds.width + 2; int height = bounds.height + 2; ImageProcessor ip = new ByteProcessor(width, height); roi.setLocation(1, 1); ip.setColor(255); ip.fill(roi); roi.setLocation(bounds.x, bounds.y); boolean bb = Prefs.blackBackground; Prefs.blackBackground = true; new EDM().toEDM(ip); Prefs.blackBackground = bb; ip.setThreshold(n+1, 255, ImageProcessor.NO_LUT_UPDATE); Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2==null) return roi; Rectangle bounds2 = roi2.getBounds(); if (bounds2.width<=0 && bounds2.height<=0) return roi; roi2.setLocation(bounds.x+bounds2.x-1, bounds.y+bounds2.y-1); return roi2; }
Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2==null) return roi;
Roi roi2 = (new ThresholdToSelection()).convert(ip); if (roi2==null) return roi;
mask.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); double xbase=roi.getXBase(), ybase=roi.getYBase(); Roi roi2 = new ThresholdToSelection().convert(mask); if (roi2!=null && (roi2 instanceof ShapeRoi)) { double perim = roi.getLength();
mask.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); double xbase=roi.getXBase(), ybase=roi.getYBase(); Roi roi2 = new ThresholdToSelection().convert(mask); if (roi2!=null && (roi2 instanceof ShapeRoi)) { double perim = roi.getLength();
if (floodFill && mask!=null) { mask.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); roi2 = new ThresholdToSelection().convert(mask); if (roi2!=null && (roi2 instanceof ShapeRoi)) { roi2.setLocation(roi.getXBase(), roi.getYBase());