ImageProcessor/drawPolyline???

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ImageProcessor/drawPolyline???

Kenneth Sloan-2
I need to draw a polyline on an ImageProcessor.  I see drawPolygon(), but no drawPolyline().

Is this intentional?

Do I lose anything by writing my own to use multiple drawLine() calls?
--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageProcessor/drawPolyline???

Michael Schmid
Hi Kenneth,

you can create a PolygonRoi (with type polyline) and use
roi.drawPixels(ip) or (equivalent) ip.draw(roi). This is how the ImageJ
'Draw' command does it:
 
https://github.com/imagej/imagej1/blob/master/ij/plugin/filter/Filler.java#L108
   https://github.com/imagej/imagej1/blob/master/ij/gui/PolygonRoi.java#L301

Of course, you can also copy the drawPolygon code and just omit the last
line that closes the polygon
 
https://github.com/imagej/imagej1/blob/master/ij/process/ImageProcessor.java#L1246

Michael
__________________________________________________

On 29/06/2019 11:26 PM, Kenneth Sloan wrote:
> I need to draw a polyline on an ImageProcessor.  I see drawPolygon(), but no drawPolyline().
>
> Is this intentional?
>
> Do I lose anything by writing my own to use multiple drawLine() calls?
> --
> Kenneth Sloan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: ImageProcessor/drawPolyline???

Kenneth Sloan-2
Thank you for the reply.

Once you have the xpoints and ypoints arrays, it's a 1 liner (not even worth declaring a method).
I guess I was just worried that there might be an optimization of the display at the vertices that I would miss out on.  But, it looks fine, so I'm happy.

On a meta-level - this is an example of multiple (very minor) deviations from "orthogonal design" in the ImageJ API.  One *could* use the ROI hack to draw Polygons, just as easily as Polylines.  So, the purist in me would prefer to do BOTH using an ROI or to provide BOTH directly.  One of each is just (mildly) confusing.

--
Kenneth Sloan
[hidden email]
Vision is the art of seeing what is invisible to others.





> On Jun 30, 2019, at 09:39, Michael Schmid <[hidden email]> wrote:
>
> Hi Kenneth,
>
> you can create a PolygonRoi (with type polyline) and use roi.drawPixels(ip) or (equivalent) ip.draw(roi). This is how the ImageJ 'Draw' command does it:
> https://github.com/imagej/imagej1/blob/master/ij/plugin/filter/Filler.java#L108
>  https://github.com/imagej/imagej1/blob/master/ij/gui/PolygonRoi.java#L301
>
> Of course, you can also copy the drawPolygon code and just omit the last line that closes the polygon
> https://github.com/imagej/imagej1/blob/master/ij/process/ImageProcessor.java#L1246
>
> Michael
> __________________________________________________
>
> On 29/06/2019 11:26 PM, Kenneth Sloan wrote:
>> I need to draw a polyline on an ImageProcessor.  I see drawPolygon(), but no drawPolyline().
>> Is this intentional?
>> Do I lose anything by writing my own to use multiple drawLine() calls?
>> --
>> Kenneth Sloan
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html