Login  Register

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

Posted by Emmanuel Levy on Aug 10, 2011; 1:57pm
URL: http://imagej.273.s1.nabble.com/run-draw-slower-than-drawing-lines-with-drawLine-tp3683528p3683530.html

Hi Wayne,

Wow, that's indeed so much faster thanks!!

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

May I ask you what is the advantage of this option? Does it mean there
a simple way to subsequently "remove" the lines drawn? (even after
saving of the image?)

One small additional thing for which I'm sure there is a trick: I have
to add a label to each object. At the moment I'm doing it this way:

nObjects = roiManager("count");
for (object=0; object<nObjects/2 ; object++){
        roiManager("Select", object);
        getSelectionBounds(x, y, width, height);
        setFont("Arial", 20, "antiliased");
        drawString(object+1, x+width/2 - 5, y+ height/2 + 10);
}

is there a way to do that without a loop to make it as fast as the
drawing of boundaries?

Thanks for any hint!

Emmanuel




On 10 August 2011 09:30, Rasband, Wayne (NIH/NIMH) [E]
<[hidden email]> wrote:

> 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
>