Roi getRoiNonBackground( ByteProcessor bp ) { bp.setThreshold(1,255,ImageProcessor.NO_LUT_UPDATE); // bp.threshold(0); ImageStack tempStack = new ImageStack(bp.getWidth(),bp.getHeight()); tempStack.addSlice(null,bp); ImagePlus imp = new ImagePlus("example stack",tempStack); ThresholdToSelection tts = new ThresholdToSelection(); tts.setup( "", imp ); tts.run(bp); // imp.show(); return imp.getRoi(); }
/** 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 Roi convert(ImageProcessor ip) { this.ip = ip; min = (float)ip.getMinThreshold(); max = (float)ip.getMaxThreshold(); w = ip.getWidth(); h = ip.getHeight(); return getRoi(); }
ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", binary); for (int s=0; s<nSlices; s++) { if (templateSlices.contains(new Integer(s+zmin))) int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); Roi roi = ts.convert(bp); if (roi==null) { IJ.error("RoiInterpolator", "Unable to interpolate slice "+(s+1)+". More\nintermediate ROIs needed.");
public void run(ImageProcessor ip) { showStatus = true; image.setRoi(convert(ip)); }
int xAfterLowerRightCorner = -1; //x at right of 8-connected (not 4-connected) pixels NW-SE thisRow[1] = y < h ? selected(0, y) : false; for (int x = 0; x <= w; x++) { if (y < h && x < w - 1) thisRow[x + 2] = selected(x + 1, y); //we need to read one pixel ahead else if (x < w - 1) thisRow[x + 2] = false;
ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", binary); for (int s=0; s<nSlices; s++) { if (templateSlices.contains(new Integer(s+zmin))) int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); Roi roi = ts.convert(bp); if (roi==null) { IJ.error("RoiInterpolator", "Unable to interpolate slice "+(s+1)+". More\nintermediate ROIs needed.");
public void run(ImageProcessor ip) { showStatus = true; image.setRoi(convert(ip)); }
int xAfterLowerRightCorner = -1; //x at right of 8-connected (not 4-connected) pixels NW-SE thisRow[1] = y < h ? selected(0, y) : false; for (int x = 0; x <= w; x++) { if (y < h && x < w - 1) thisRow[x + 2] = selected(x + 1, y); //we need to read one pixel ahead else if (x < w - 1) thisRow[x + 2] = false;
@Override public Area call() throws Exception { final Image<BitType> imb = interpol.process(weight); final ImagePlus imp = ImageJFunctions.copyToImagePlus(imb, ImagePlus.GRAY8); // BitType gets copied to 0 and 255 in 8-bit ByteProcessor final ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", imp); final ImageProcessor ip = imp.getProcessor(); ip.setThreshold(1, 255, ImageProcessor.NO_LUT_UPDATE); ts.run(ip); final Roi roi = imp.getRoi(); return null == roi ? new Area() : M.getArea(roi).createTransformedArea(back); } }));
/** 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 Roi convert(ImageProcessor ip) { this.ip = ip; min = (float)ip.getMinThreshold(); max = (float)ip.getMaxThreshold(); w = ip.getWidth(); h = ip.getHeight(); return getRoi(); }
void select() { ImageProcessor ip = copy.duplicate(); ImagePlus dummy = new ImagePlus("dummy", ip); byte[] p = (byte[])ip.getPixels(); ThresholdToSelection ts = new ThresholdToSelection(); for (int i = 1; i <= image.getStackSize(); i++) { Roi roi = stackWindow.getRoi(i); if (roi == null) continue; copy = image.getStack().getProcessor(i); Arrays.fill(p, (byte)0); apply(ip, roi, minThreshold, maxThreshold, erodeDilateIterations, true); ip.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ts.setup("", dummy); ts.run(ip); stackWindow.setRoi(i, dummy.getRoi()); } }
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); }
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()); }
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); }
public void processCloseButton() { // 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.dilate(); newip.erode(); // 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()); }
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); }
ImagePlus roiImage = new ImagePlus("bla", stack); ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", roiImage); for(int i = firstIndex; i <= lastIndex; i++) { ImageProcessor bp = stack.getProcessor(1); int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); ts.run(bp); rois[i] = roiImage.getRoi();
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); }