@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); } }));
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(); }
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()); } }
final ThresholdToSelection tts = new ThresholdToSelection(); // TODO replace by our much faster method that scans by line, in AmiraImporter tts.setup("", imp); tts.run(alpha_mask); final Roi roi = imp.getRoi(); if (null == 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()); }
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()); }
int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); ts.run(bp); rois[i] = roiImage.getRoi();
int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); ts.run(bp); rois[i] = roiImage.getRoi();
int threshold = 255; bp.setThreshold(threshold, threshold, ImageProcessor.NO_LUT_UPDATE); ts.run(bp); rois[i] = roiImage.getRoi();
ThresholdToSelection ts = new ThresholdToSelection(); ts.setup("", tmp); ts.run(newip); newip.resetThreshold(); ip.insert(copy, 0, 0);