[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pixel coordinates of a line



Marc Schellens wrote:

> I want to extract pixels along a line.
> I know start and endpoint (ie. I draw the line in top of the
> image).
> How to get the pixel values? Do I have to do it 'by hand'?

Good question. I don't know about such a function in IDL, but I think
there should be a routine for that.

What about this:
Your line runs from (x1,y1) to (x2,y2), the image has a size of
dimx*dimy. Let's create a thin, one pixel wide polygon along this line:
index = polyfillv( [x1,x2,x2+1,x1+1], [y1,y2,y2,y1], dimx, dimy )
(This assumes that |x2-x1| lt |y2-y1|).
Your pixel values are image[index] then. Well, nearly.

Another method would be drawing a real line via PLOTS (preferably in the
Z buffer), use TVRD() to get this screen part, use WHERE() to get the
indices of this line, and again image[index] is the information you
seek.

But let's wait a little for other responses, I'm pretty sure J.D. will
come up with another idea involving HISTOGRAM().

        Alex
-- 
  Alex Schuster     Wonko@planet-interkom.de
                    alex@pet.mpin-koeln.mpg.de