Re: Get continuous pixel coordinates from a line ROI
Posted by
lechristophe on
Jul 15, 2008; 5:14pm
URL: http://imagej.273.s1.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-tp3688036p3688039.html
The problem with your strategy (your macro) is that it does not store
the ROI coordinates processively (i.e. in order along the path from
first to lat point), but as a x-y scan intersecting with the ROI. And
this is what I need to then trace perpendicular segments, in order to
store profiles that will be used to reconstruct the straightened image
(because at the beginning I want to reprogram the Straighten plugin as
a macro tool).
On Sun, Jul 13, 2008 at 13:27, Gabriel Landini <
[hidden email]> wrote:
> More on this problem.
> If I fit a spline, and then run:
>
> getSelectionCoordinates(x, y);
> for (i=0;i<x.length;i++)
> print (x[i], y[i]);
>
> I get lots of the same pixel coordinates which I guesss is because the spline
> is subsampled.
>
> Here is my previous suggestion which returns the coordinates (only once) of
> the pixels under the selection:
>
>
>
> //==============================================
> //getSplineCoordinates.txt
> //
> waitForUser("Draw a polyline and press OK,\nthen I will fit a spline\nand get
> the coordinates");
>
> if(selectionType()!=6) {
> exit("Not a polyline selection!");
> }
>
> run("Fit Spline");
>
> setBatchMode(true);
> w=getWidth();
> h=getHeight();
> newImage("temp", "8-bit Black", w, h, 1);
> run("Restore Selection");
> run("Colors...", "foreground=white background=black selection=yellow");
> run("Draw");
> nBins = 256;
> getHistogram(values, counts, nBins);
> x=newArray(counts[255]);
> y=newArray(counts[255]);
>
> counter=-1;
> for (j=0;j<h;j++){
> for (i=0;i<w;i++){
> if (getPixel(i,j)==255){
> counter++;
> x[counter]=i;
> y[counter]=j;
> print(x[counter],y[counter]);
> }
> }
> }
> close();
> setBatchMode(false);
> //==============================================
>