void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isLine()) { IJ.error("Line to Area", "Line selection required"); return; } if (roi.getType() == Roi.LINE && roi.getStrokeWidth() == 1) { IJ.error("Line to Area", "Straight line width must be > 1"); return; } ImageProcessor ip2 = new ByteProcessor(imp.getWidth(), imp.getHeight()); ip2.setColor(255); if (roi.getType() == Roi.LINE) ip2.fillPolygon(roi.getPolygon()); else { roi.drawPixels(ip2); // BufferedImage bi = new BufferedImage(imp.getWidth(), imp.getHeight(), // BufferedImage.TYPE_BYTE_GRAY); // Graphics g = bi.getGraphics(); // Roi roi2 = (Roi)roi.clone(); // roi2.setStrokeColor(Color.white); // roi2.drawOverlay(g); // ip2 = new ByteProcessor(bi); } // new ImagePlus("ip2", ip2.duplicate()).show(); ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); Roi roi2 = tts.convert(ip2); imp.setRoi(roi2); Roi.previousRoi = (Roi) roi.clone(); }
void lineToArea(ImagePlus imp) { Roi roi = imp.getRoi(); if (roi == null || !roi.isLine()) { IJ.error("Line to Area", "Line selection required"); return; } ImageProcessor ip2 = new ByteProcessor(imp.getWidth(), imp.getHeight()); ip2.setColor(255); if (roi.getType() == Roi.LINE && roi.getStrokeWidth() > 1) ip2.fillPolygon(roi.getPolygon()); else roi.drawPixels(ip2); // new ImagePlus("ip2", ip2.duplicate()).show(); ip2.setThreshold(255, 255, ImageProcessor.NO_LUT_UPDATE); ThresholdToSelection tts = new ThresholdToSelection(); Roi roi2 = tts.convert(ip2); imp.setRoi(roi2); Roi.previousRoi = (Roi) roi.clone(); }