Login  Register

Re: run("draw") slower than drawing lines with drawLine

Posted by Rasband, Wayne (NIH/NIMH) [E] on Aug 10, 2011; 1:30pm
URL: http://imagej.273.s1.nabble.com/run-draw-slower-than-drawing-lines-with-drawLine-tp3683528p3683529.html

On Aug 9, 2011, at 11:55 PM, Emmanuel Levy wrote:

> Hi,
>
> I'm drawing a contour line around identified objects for quality
> control. Given that I have a lot of objects, I'm trying to improve the
> "drawing speed".
>
> I tried 3 options:
>
> 1.
> roiManager("Select", object);
> run("Draw");

It is *much* faster to draw all the object contours at once:

   roiManager("Deselect");
   roiManager("Draw");

You can also use an overlay to draw the contours non-destructively, and in color:

   roiManager("Deselect");
   roiManager("Set Color", "yellow");
   run("From ROI Manager"); // Image>Overlay>From ROI Manager

-wayne


>
> 2.
> roiManager("Select", object);
> run("Area to Line");
> run("Clear", "slice");
>
> 3.
> roiManager("Select", object);
> getSelectionCoordinates(xCoordinates, yCoordinates);
> for (pix =0; pix < xCoordinates.length-1; pix++){
> drawLine(xCoordinates[pix], yCoordinates[pix] ,xCoordinates[pix+1],
> yCoordinates[pix+1] );
> }
>
> Option 3 is the fastest of all! (this let me wonder if the method
> "draw" couldn't be improved?). Actually, this is quite a stupid
> question but ... where should I look for code of "built-in" functions?
>
> Thanks!
>
> Emmanuel