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

Home » Public Forums » archive » pixel coordinates of a line
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
pixel coordinates of a line [message #25547] Wed, 27 June 2001 23:29 Go to next message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
Hello everybody,

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
Re: pixel coordinates of a line [message #25606 is a reply to message #25547] Mon, 02 July 2001 03:47 Go to previous message
Struan Gray is currently offline  Struan Gray
Messages: 178
Registered: December 1995
Senior Member
A blast from the past. I'm old enough to have had to
write my own graphical user interface from scratch. I did
so on a curious HP Pascal Workstation, which had a graphics
library based on HPGL, but the plotting was *one* *hundred*
times slower than if you just stuffed pixels into the
display memory yourself.

Anyway, my algorithm for drawing a line was this:

First clip the line (if necessary) using
geometry-derived algebra like Tom's, this gives you (x1,y1)
and (x2,y2), the screen coordinates of the line that will
actually be drawn.

Then find out which of (x2-x1) and (y2-y1) had the
largest magnitude, this gives you the number of pixels,
since there will be one pixel for each integer value of this
coordinate.

Finally, loop through the coordinates for whichever axis
had the longest span, adding the index times the line's
slope to the other coordinate. Using integer maths made the
rounding off automatic and fast. In IDL you could do this
step as a matrix operation with an index matrix.


Struan
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: VARRAY, memory & extracting subarrays
Next Topic: Intersecting geometric shapes

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

Current Time: Wed Oct 08 14:01:19 PDT 2025

Total time taken to generate the page: 0.00774 seconds