Re: Get continuous pixel coordinates from a line ROI
Posted by Gabriel Landini on Jul 13, 2008; 11:27am
URL: http://imagej.273.s1.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-tp3688036p3688038.html
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);
//==============================================