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

Home » Public Forums » archive » overlying an image and a contour plot
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: overlying an image and a contour plot [message #17921 is a reply to message #17876] Tue, 16 November 1999 00:00 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Getting the right pixel alignment can be a problem. I also totally
agree with Mr. Bennett's suggestion that you may need to "add" an
extra half-pixel on either side.

I like to think about it this way: CONTOUR applies to data at the
pixel *centers*, but when displaying an image you want to show every
pixel out to its edges, and that's where the two half pixels comes
from. I would also like to point out that TVIMAGE uses CONGRID, which
has a bug in the way it interpolates, which *guarantees* that you will
be off by at least a half a pixel. Not good.

To solve these problems I use the PLOTIMAGE procedure available from
my web page (listed below). It makes putting images on the screen or
Postscript page easy -- especially aligning everything.

Here's how it works. This little script assumes you have an image,
and your X and Y values:

;; Usually you want to BYTSCL your image first - I like this algorithm
IDL> b = bytscl(image, min=-100, max=100, top=!d.n_colors-3b)+1b

;; Then you compute your image boundaries. Remember those half-pixels!
IDL> dx = x(1) - x(0) & dy = y(1) - y(0)
IDL> imgxrange = [min(x)-0.5*dx, max(x)+0.5*dx]
IDL> imgyrange = [min(y)-0.5*dy, max(y)+0.5*dy]

;; Finally, plot the image and overlay the contours
IDL> PLOTIMAGE, b, imgxrange=imgxrange, imgyrange=imgyrange
IDL> CONTOUR, image, x, y, ...

You see, most of it is a little bookkeeping. PLOTIMAGE is nice
because you can specify an XRANGE and YRANGE independent of the image
boundaries, meaning that you can zoom in to a sub image for example.
And for astronomers, it will automatically reverse the image if
needed!

Good luck,

Craig
http://cow.physics.wisc.edu/~craigm/idl/idl.html

P.S. PLOTIMAGE uses parts of TVIMAGE. The good parts. Thanks David!

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: MPFIT update
Next Topic: Re: determining the display size (IDL)

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

Current Time: Mon Oct 13 13:54:54 PDT 2025

Total time taken to generate the page: 1.75867 seconds