Login  Register

Execute "Line to Area" from "segmented line" roi

Posted by guitarro17 on Aug 22, 2014; 2:18am
URL: http://imagej.273.s1.nabble.com/Execute-Line-to-Area-from-segmented-line-roi-tp5009299.html

Hi!

I use ImageJ as library in my application, and I have a sequence of points that form a segmented line.
I'm having some trouble in turning this segmented line into an area selection/roi (Like the menu Edit -> Selection -> Line to Area), and then crop the image.

My code until now, but that doesn't work:

ImagePlus imp = new ImagePlus("", ip);
PolygonRoi s = new PolygonRoi(xPoints, yPoints, nPoints, Roi.POLYLINE);
imp.setRoi(s);
IJ.run(imp, "Line to Area", "");
IJ.run(imp, "Crop", "");
ImageProcessor ip2 = imp.getProcessor();

What should I do? thanks!