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

*To*: Marc Schellens <m_schellens(at)hotmail.com>*Subject*: Re: pixel coordinates of a line*From*: tam <tam(at)lheapop.gsfc.nasa.gov>*Date*: Thu, 28 Jun 2001 09:33:54 -0400*Newsgroups*: comp.lang.idl-pvwave*Organization*: NASA/GSFC(USRA)*References*: <3B3ACEBC.B64C9408@hotmail.com> <3B3AD016.42710606@hotmail.com>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:25453

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]

**References**:**pixel coordinates of a line***From:*Marc Schellens

**Re: pixel coordinates of a line***From:*Marc Schellens

- Prev by Date:
**Re: pixel coordinates of a line** - Next by Date:
**filled closed curve** - Prev by thread:
**Re: pixel coordinates of a line** - Next by thread:
**Re: pixel coordinates of a line** - Index(es):