Login  Register

Re: Get continuous pixel coordinates from a line ROI

Posted by Wayne Rasband on Jul 15, 2008; 10:03pm
URL: http://imagej.273.s1.nabble.com/Get-continuous-pixel-coordinates-from-a-line-ROI-tp3688036p3688043.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).

ImageJ 1.41h will have an easy way to get the coordinates of points
along a line, spaced one pixel apart. This feature is not yet in the
v1.41h daily build but it does have the ability to display wide lines
using translucency, similar to the way the Straighten plugin works.

-wayne

>
> 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);
> > //==============================================
> >
>