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

Home » Public Forums » archive » Re: overlying an image and a contour plot
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
Re: overlying an image and a contour plot [message #17849] Mon, 15 November 1999 00:00
Med Bennett is currently offline  Med Bennett
Messages: 109
Registered: April 1997
Senior Member
A key issue that took me a while to figure out is that the pixels of an
image represent a finite area, unlike grid coordinates. Thus if you
have a grid representing 5000 by 5000 units with a grid spacing of 50
units, your contouring grid will have to be of size 101 by 101. if your
image file also is 101 by 101, the image pixels have to extend *outside*
the axis coordinates by .5 pixels on all sides. I call this a node
centered image. A cell centered image would be only 100 by 100 pixels,
the image occupies the exact coordinate axis ranges, and the first pixel
center is at x[0]+25., y[0]+25. Some extra calculations for the use of
the position keyword are required in the former case. I do the contour
plot first with /nodata to get the exact axis position values, do the
calcs, output the image, and the contour again over the image with the
real data. Easier in postscript be cause it scales the pixels for you -
on screen you have to resize the image appropriately also.

tebbens@my-deja.com wrote:

> We are trying to overlay an image and a contour
> plot, but can't get a perfect match in position
> and size.
>
> On the contour plot, the x axis is 652 values and
> the y axis is 5048 values. We want to fit the
> image exactly into the contour plot.
>
> The following commands are used:
>
> position=[.6,.05,r,.95]
> tv, image, .6, .05, $
> xsize=position(2)-position(0), $
> ysize=position(3)-position(1), /normal
> xvalue = 652.
> yvalue = 5048.
>
> ; r should be the length of the x-axis in the
> ; normal coordinate system (x and y window
> ; size=1)
> r= 10./7.*(.9 * xvalue/yvalue) + .6
>
> contour, xstyle=1, ystyle=1, /iso, $
> position=[.6,.05,r,.95], /noerase
>
> The image and contour overlay, but the x-axis of
> the image is too long to fit the contour plot.
> When the command tvimage is used instead of tv,
> the images are the same size, but are offset in
> both x and y direction by a few pixels.
>
> We think the problem is with the r value, but
> we don't know why the simple commands above
> don't work.
>
> Any suggestions to get these to overlay?
>
> Thanks in advance.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Re: overlying an image and a contour plot [message #17871 is a reply to message #17849] Fri, 12 November 1999 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Sarah Tebbens (tebbens@my-deja.com) writes:

> We are trying to overlay an image and a contour
> plot, but can't get a perfect match in position
> and size.
>
> On the contour plot, the x axis is 652 values and
> the y axis is 5048 values. We want to fit the
> image exactly into the contour plot.
>
> The following commands are used:
>
> position=[.6,.05,r,.95]
> tv, image, .6, .05, $
> xsize=position(2)-position(0), $
> ysize=position(3)-position(1), /normal
> xvalue = 652.
> yvalue = 5048.
>
> ; r should be the length of the x-axis in the
> ; normal coordinate system (x and y window
> ; size=1)
> r= 10./7.*(.9 * xvalue/yvalue) + .6
>
> contour, xstyle=1, ystyle=1, /iso, $
> position=[.6,.05,r,.95], /noerase
>
> The image and contour overlay, but the x-axis of
> the image is too long to fit the contour plot.
> When the command tvimage is used instead of tv,
> the images are the same size, but are offset in
> both x and y direction by a few pixels.
>
> We think the problem is with the r value, but
> we don't know why the simple commands above
> don't work.
>
> Any suggestions to get these to overlay?

I think the problem probably lies in the use
of the ISOTROPIC keyword. I've never understood
what "isotropic" means, but I think it means
"keep the damn aspect ratio correct".

I would try something like this. (I would be
*very* surprised if this doesn't work, because
this is what TVIMAGE was designed for. If it
doesn't work, let me know immediately.)

windowPos = [0.1, 0.1, 0.9, 0.9]
TVImage, data, /Keep_Aspect, Position=windowPos
Contour, data, XStyle=1, YStyle=1, Position=windowPos, /NoErase

The key thing here is putting the window position in a variable,
since the actual values in it may change in the TVImage command.
In other words, the Position keyword is both an input and an
output keyword in this case.

Let us know. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Callable IDL and Borland CBuilder 3
Next Topic: Clearing WIDGET_TEXT fields with LOOP

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

Current Time: Fri Oct 10 22:33:26 PDT 2025

Total time taken to generate the page: 0.47988 seconds