Login  Register

Re: Get continuous pixel coordinates from a line ROI

Posted by Gabriel Landini on Jul 12, 2008; 3:03pm
URL: http://imagej.273.s1.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-tp3688036p3688037.html

On Saturday 12 July 2008, Christophe Leterrier wrote:
> The macro starts with a spline fitting of the line ROI, then retrieve all
> the ROI > coordinates using getSelectionCoordinates().
> Unfortunately, this  function only returns vertices, and not all pixel
> coordinates (continuous) along the ROI. Before implementing a loop to
> interpolate the missing points between vertices, I wanted to ask if someone
> has a more elegant solution...

Not elegant... but just in case:

execute in the macro "waitforuser" so it stops and you can draw the line,

Draw the line ROI on the image with the mouse

now the macro continues:
Set batchmode true (to make the following transparent),
Duplicate the image,
Math subtract 1,
Set foreground colour to 255,
Restore selection,
Fit spline,
Draw,
now scan the image for pixels == 255 and store in an array.
You can get the array size first by looking at the image histogram (as the
only 255 pixels will be the drawn spline).
close image (so the batch mode off does not show it).
set batch mode off

The drawback is that the line pixels are not in drawn order.


BTW, the Align_RGB_planes plugin mentioned yesterday is updated at my site.

Cheers,

G.