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

Home » Public Forums » archive » Re: Overplot contour on previously stablished coordinates
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: Overplot contour on previously stablished coordinates [message #83410] Fri, 01 March 2013 14:45
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mairan.teodoro@gmail.com writes:

> The images I'm working on are not the same (and therefore, they have different dimensions and scales).
>
> Here you can see the original image from which I get the contours:
>
> https://dl.dropbox.com/u/6573328/teodoro2.jpg
>
> The image on the left is the original, non-rotated HST image. On the right you can see how this image should be regarding my iso-velocity one.

OK, well, you are still going to have to figure out the X and Y values
for the contour plot to overlay it properly on a data coordinate system.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Overplot contour on previously stablished coordinates [message #83413 is a reply to message #83410] Fri, 01 March 2013 12:43 Go to previous message
mairan.teodoro is currently offline  mairan.teodoro
Messages: 20
Registered: June 2008
Junior Member
Hi David!

Thanks for the comments.

The images I'm working on are not the same (and therefore, they have different dimensions and scales).

Here you can see the original image from which I get the contours:

https://dl.dropbox.com/u/6573328/teodoro2.jpg

The image on the left is the original, non-rotated HST image. On the right you can see how this image should be regarding my iso-velocity one.

m.
Re: Overplot contour on previously stablished coordinates [message #83414 is a reply to message #83413] Fri, 01 March 2013 12:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> OK, well, a couple of things. You are contaminating your color table
> because you are working in indexed color. You see this by the white line
> in your color bar.

The color table contamination is occurring because you are calling your
cgPlot command incorrectly. You specify the AXISCOLOR keyword like this:

AXISCOLOR=cgColor('white')

And you should be doing it like this:

AXISCOLOR='white'

The difference is that the way you are doing it, cgColor is forced to
load the white color somewhere in the color table (because you are using
indexed color), but if you allow cgPlot to load the color it will do it
using decomposed color and never have to load a color in the color
table.

Cheers,

David





--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Overplot contour on previously stablished coordinates [message #83415 is a reply to message #83414] Fri, 01 March 2013 12:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mairan.teodoro@gmail.com writes:

> This is the part of the code that does the plot:
>
> cgplot, findgen(100),title=strtrim(string(((w[i+j]-lref)/lref)*a.c/1 d5,form='(I10)'),2),$
> xsty=1, ysty=1, charsize=0.8,$
> xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
> yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])],$
> /nodata, position=p
>
> ;;; this is my iso-velocity image
> cgimage, bytscl(rot(img, 0, missing=0), min=mindisplay, max=maxdisplay), position=p, /overplot,$
> xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
> yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])]
>
> ;;; normalized intensity colorbar
> cgColorBar, position=[p[2]+0.005, p[1], p[2]+0.02, p[3]],$
> /vertical, /right, charsize=0.8,$
> range=[mindisplay,maxdisplay]
>
> ;;; this is just to show the axis in white in my iso-image
> cgplot, findgen(100),$
> xsty=1, ysty=1, xtickformat='(A1)', ytickformat='(A1)', axiscolor=cgcolor('white'),$
> xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
> yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])],$
> /nodata, /noerase, position=p, charsize=0.8
>
> ;;; this is the contour obtained from a FITS image
> ;;; with astrometric solution stored in header.
> ;;; The size and orientation are not the same as
> ;;; that of my iso-velocity image.
> cgcontour, rot(data_img, 0.), levels=[0.9,5,8],$
> color='white', background='black',$
> label=0, olevels=olevels, /onimage, /missing
>
> The result for one image can be seen in this link:
>
> https://dl.dropbox.com/u/6573328/teodoro.png

OK, well, a couple of things. You are contaminating your color table
because you are working in indexed color. You see this by the white line
in your color bar. I would fix this by doing all your graphics in
decomposed color. (The other alternative would be to load your color
tables again just before you draw the color bar.) But, I would bracket
your graphics commands with this code, then you don't have to worry
about contaminating anything:

SetDecomposedState, 1, Current=currentState
graphics commands here...
SetDecomposedState, currentState

I can't tell why your contour plot is rotated, but I note that the data
you display as an image and the data you are contouring are not the same
data set. Are they suppose to be?

I also note that your contour plot isn't specifying the X and Y location
of the values you are trying to contour. This is probably the main
reason you are having problems. You are not telling IDL where the
contours are suppose to go! In other words, you are calling the contour
plot like this:

cgContour, data, /overplot

And you should be calling it like this:

cgContour, data, x, y, /overplot

The X and Y vectors are absolutely REQUIRED if you are overplotting.
Otherwise, there is no information to do the overplotting. If you don't
have these vectors, you can make them like this:

s = Size(rot(data_img, 0.), /Dimensions)
x = Scale_Vector(Findgen(s[0]), reform(astro[0,0,0]), $
reform(astro[size[1]-1,size[2]-1,0]))
y = Scale_Vector(Findgen(s[1]), reform(astro[0,0,1]),$
reform(astro[size[1]-1,size[2]-1,1]))

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Overplot contour on previously stablished coordinates [message #83416 is a reply to message #83415] Fri, 01 March 2013 11:31 Go to previous message
mairan.teodoro is currently offline  mairan.teodoro
Messages: 20
Registered: June 2008
Junior Member
I forgot to mention that what I would like to have is the contour over plotted using the same coordinate system as the iso-velocity image, so that I could compare the iso-velocity and the optical (contour) appearance of my astronomical object.

Best regards,
m.
Re: Overplot contour on previously stablished coordinates [message #83417 is a reply to message #83416] Fri, 01 March 2013 11:25 Go to previous message
mairan.teodoro is currently offline  mairan.teodoro
Messages: 20
Registered: June 2008
Junior Member
Hi David!

Thanks for the quick reply.

This is the part of the code that does the plot:

cgplot, findgen(100),title=strtrim(string(((w[i+j]-lref)/lref)*a.c/1 d5,form='(I10)'),2),$
xsty=1, ysty=1, charsize=0.8,$
xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])],$
/nodata, position=p

;;; this is my iso-velocity image
cgimage, bytscl(rot(img, 0, missing=0), min=mindisplay, max=maxdisplay), position=p, /overplot,$
xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])]

;;; normalized intensity colorbar
cgColorBar, position=[p[2]+0.005, p[1], p[2]+0.02, p[3]],$
/vertical, /right, charsize=0.8,$
range=[mindisplay,maxdisplay]

;;; this is just to show the axis in white in my iso-image
cgplot, findgen(100),$
xsty=1, ysty=1, xtickformat='(A1)', ytickformat='(A1)', axiscolor=cgcolor('white'),$
xrange=[reform(astro[0,0,0]),reform(astro[size[1]-1,size[2]- 1,0])],$
yrange=[reform(astro[0,0,1]),reform(astro[size[1]-1,size[2]- 1,1])],$
/nodata, /noerase, position=p, charsize=0.8

;;; this is the contour obtained from a FITS image
;;; with astrometric solution stored in header.
;;; The size and orientation are not the same as
;;; that of my iso-velocity image.
cgcontour, rot(data_img, 0.), levels=[0.9,5,8],$
color='white', background='black',$
label=0, olevels=olevels, /onimage, /missing

The result for one image can be seen in this link:

https://dl.dropbox.com/u/6573328/teodoro.png

Thanks for any help!
m.
Re: Overplot contour on previously stablished coordinates [message #83418 is a reply to message #83417] Fri, 01 March 2013 09:58 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> By the way, I can't think of a reason why cgPlot would have to be used
> with cgImage to set up a coordinate system. cgImage is perfectly capable
> of doing this on its own.

In fact, if you just want contours on your image, simply setting the
OnImage keyword to the cgContour command will do it. See this example in
the Coyote Plot Gallery:

http://www.idlcoyote.com/gallery/index.html#IMGCONTOURS

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Overplot contour on previously stablished coordinates [message #83419 is a reply to message #83418] Fri, 01 March 2013 09:54 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
mairan.teodoro@gmail.com writes:

> I have an image created using cgPlot in combination with cgImage. This image has its own coordinate system, which is given in distance from the central point.
>
> Now I would like to superpose a contour image on the previous one, using the same coordinate system. The problem is that the contour image is rotated and has a different size.

Sounds to me like you switched your X and Y values for your contour
plot, but it is impossible to know without seeing some code.

By the way, I can't think of a reason why cgPlot would have to be used
with cgImage to set up a coordinate system. cgImage is perfectly capable
of doing this on its own.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Undocumented functions in IDL
Next Topic: JD Smith Missing

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

Current Time: Wed Oct 08 17:02:37 PDT 2025

Total time taken to generate the page: 0.00540 seconds