comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: pixel coordinates of a line
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: pixel coordinates of a line [message #25543 is a reply to message #25539] Thu, 28 June 2001 06:33 Go to previous messageGo to previous message
tam is currently offline  tam
Messages: 48
Registered: February 2000
Member
Marc Schellens wrote:
>
> Oh, I forgot:
> I have the start and endpoint, but they might need to be clipped
> to the images boders...
>
>> 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'?
>>
>> thanks,
>> marc


Working in pixel coordinates you have the endpoints (sx,sy,ex,ey) and the clipping
rectangle (x0,y0, x1, y1), so you should trivially be able to get the equation
of the line

y = m x + b [ m= (ey-sy)/(ex-sx), b = sy - m sx ]


Turn this into IDL...

x = lindgen(x1-x0) + x0
y = floor (m * x + b + 0.5) [add 0.5 to get appropriate rounding]
w = where (y ge y0 and y le y1)
if (w[0] ne -1) then begin
x = x(w)
y = y(w)
endif else begin
.... line is outside clipping rectangle
endelse

Here I'm assuming integral values for x0,x1, y0,y1 but not necessarily the
end points.

There are probably subtleties I've missed but this seems like a reasonable
start. Whether it will exactly match the pixels that IDL will draw on
is hard to say... Guess we'd need to know exactly how IDL draws a line.

Tom McGlynn
NASA/GSFC
tam@lheapop.gsfc.nasa.gov
[Mailed and posted]
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: volume slicing
Next Topic: Re: Intersecting geometric shapes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 01:54:13 PDT 2025

Total time taken to generate the page: 0.00188 seconds