Overlaying a contour on a small image [message #58987] |
Fri, 29 February 2008 10:16 |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Does anyone have a routine to overlay a contour plot on a small image
that is both accurate and aesthetically pleasing?
If one contours a 9x9 image
im = dist(9)
contour,im,/xsty,/ysty
then the axes will run from 0 to 8, because individual pixels have no
"width" when plotting. However, when displaying an 9x9 image, the
full length from say the left edge of the first pixel of a row to the
right edge of the last pixel is 9 pixels. So if one places the
image within the contour plot window, there will be a misalignment
between the contour levels and the image
The way around this is to force the contour to go from 0 to 9, as
described in the example to David Fanning's TVIMAGE program
im = dist(9)
TVIMAGE, bytscl(im), POSITION=thisPosition, /KEEP_ASPECT_RATIO
contour,im, Position=thisPosition,/xsty,/ysty,/noerase,xran=[0,9], $
yran=[0,9]
Now the contours and the image overlap, but the contours end a full
pixel before the upper and right edges. So for aesthetic reasons I
would like first center the plot to run from -0.5 to 8.5 so that there
is a half-pixel margin with no contour around all the edges (easily
done). Then I would like to extrapolate the contours so they reach
the edge of the plot. In principle this could be done by
extracting the path information but it seems quite complicated.
Alternatively, I could only display half of all edge pixels
so that there are no gaps between the contours and the edges.
Incidentally, the old ITTVIS procedure image_cont.pro to overlay a
contour on the same image, simply does it wrong, by using the default
contour axes sizes:
im = dist(9)
im[1,2] = 15
image_cont,im
and one sees that the contour of the "high" pixel does not exactly
overlay its position on the image.
|
|
|