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! |
On Aug 21, 2014, at 10:18 PM, guitarro17 wrote:
> 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. Set the width of the segmented line selection and the Edit>Selection>Line to Area command will work as expected. The following JavaScript example creates a segmented line selection, sets its width to 35 pixels and then uses "Line to Area" to convert it into an area selection. There is a screenshot of the output at <http://wsr.imagej.net/images/LineToArea.png>. -wayne imp = IJ.createImage("Untitled","8-bit black",300,200,1); xpoints = [55,105,164,209,229,217]; ypoints = [111,137,132,102,62,25]; line = new PolygonRoi(xpoints,ypoints,Roi.POLYLINE); imp.setRoi(line); IJ.run(imp, "Fit Spline", ""); IJ.setForegroundColor(255,255,255); IJ.run(imp, "Draw",""); line.setStrokeWidth(35); IJ.run(imp, "Line to Area",""); IJ.run(imp, "Crop", ""); imp.show(); > 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! > > -- > View this message in context: http://imagej.1557.x6.nabble.com/Execute-Line-to-Area-from-segmented-line-roi-tp5009299.html > Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks, I will try that! :) Abraço, Prof. Guilherme Chagas Kurtz Cursos de Ciência da Computação e Sistemas de Informação UNIFRA - Centro Universitário Franciscano Rua dos Andradas 1614 - 97010-032 - Centro - Santa Maria - RS +55 55 3220 1200 2014-08-23 14:06 GMT-03:00 Rasband, Wayne (NIH/NIMH) [E] [via ImageJ] <[hidden email]>:
|
In reply to this post by Rasband, Wayne (NIH/NIMH) [E]
Just curious, because I could not find the answer on google: what the "Fit Spline" command do? Abraço, Prof. Guilherme Chagas Kurtz Cursos de Ciência da Computação e Sistemas de Informação UNIFRA - Centro Universitário Franciscano Rua dos Andradas 1614 - 97010-032 - Centro - Santa Maria - RS +55 55 3220 1200 2014-08-23 18:16 GMT-03:00 Guilherme Kurtz <[hidden email]>:
|
On Saturday 23 Aug 2014 14:15:44 you wrote:
> Just curious, because I could not find the answer on google: what the "Fit > Spline" command do? You can find what all the commands do using the online documentation. http://rsbweb.nih.gov/ij/docs/guide/146.html In this case: http://rsbweb.nih.gov/ij/docs/guide/146-27.html 27.12.4 Fit Spline Fits a cubic spline curve to a polygon or polyline selection (see ROI manipulations). If you want to know what the command does in terms of what code it executes, use CTRL-L and type Fit Spine in the Search box. That shows you that the command calls ij.plugin.Selection("spline") Hope this helps. Cheers Gabriel -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Sure it helps! Thanks Gabriel :D Abraço, Prof. Guilherme Chagas Kurtz Cursos de Ciência da Computação e Sistemas de Informação UNIFRA - Centro Universitário Franciscano Rua dos Andradas 1614 - 97010-032 - Centro - Santa Maria - RS +55 55 3220 1200 2014-08-24 4:36 GMT-03:00 Gabriel Landini [via ImageJ] <[hidden email]>:
|
Free forum by Nabble | Edit this page |