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

Home » Public Forums » archive » cgimage and color tables
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
cgimage and color tables [message #79568] Mon, 12 March 2012 21:44 Go to next message
A J is currently offline  A J
Messages: 11
Registered: February 2012
Junior Member
Hello,

I need to display a grid of values, numbered 1-5, each value having a
specific color. What I have been trying to do is something like this:

> color_code = ['grn6', 'dodger blue', 'royal blue', 'salmon', 'pink']

> cgimage, grid, /scale, bottom = 0, top = 4

I don't want to set a predefined color table becasue I want to use the
colors I have chosen above. I have failed in my attempts to create a
color table with just these 5 colors. So how do I get, say, value 3 to
use color_code[2] etc?

Thankyou for your patience,

-Lex
Re: cgimage [message #81118 is a reply to message #79568] Wed, 15 August 2012 12:51 Go to previous message
DavidF[1] is currently offline  DavidF[1]
Messages: 94
Registered: April 2012
Member
Gompie writes:

> When I set yrange=[a,b] in cgplot it plots values between a,b. How is is possible to do the same in cgimage.?

Interestingly, I had the occasion this morning to want something very much like this. I have two images, one larger than the other, but both only having image data in part of the rectangular array. The images are in GeoTiff files, so I can find the projected ranges of the image rectangles.

It turns out there is imperfect overlap between the valid data in the two images, so I wish to create a single image that shows only the overlapping data. So, the idea is this, fit a smaller image onto the larger, and do it in such a way that you clip any part of the smaller image's valid data that is not also part of the larger image's valid data.

Essentially, I have to clip the smaller image based on its "axis" values.

My code looked like this. "Zone" is a zonal map and "land" is a LandSat image.
The ranges are in projected meter space.

zone = 'quer_zones_ext.tif'
land = 'L5224069_06919980623_B50.TIF'

mzone = cggeomap(zone, image=image)
mzone -> Getproperty, XRange=zxr, YRANGE=zyr
cgdisplay, Aspect=image, xsize=800
cgLoadct, 33, ncolors=6, bottom=1
cgImage, image, XRange=zxr, YRANGE=zyr, /save

mland = cggeomap(land, image=img)
mland ->GetProperty, XRange=lxr, YRange=lyr
x0 = zxr[0] > lxr[0]
x1 = zxr[1] < lxr[1]
y0 = zyr[0] > lyr[0]
y1 = zyr[1] < lyr[1]
xr = [x0,x1]
yr = [y0,y1]
s = Size(img, /DIMENSIONS)
xvec = Scale_Vector(Findgen(s[0]), lxr[0], lxr[1])
yvec = Scale_Vector(Findgen(s[1]), lyr[0], lyr[1])
xsubs = Value_Locate(xvec, xr)
ysubs = Value_Locate(yvec, yr)
imgsub = img[xsubs[0]:xsubs[1], ysubs[0]:ysubs[1]]

To display the clipped, smaller image on the first, I made a slight modification to cgImage, which I will check in later today. Basically, if you set the OVERPLOT keyword *and* you specify both an XRANGE and YRANGE when you call cgImage, I will adjust the image position in the window to place the image at the proper location in the set of axes that are currently defined for the window.

Cheers,

David
Re: cgimage [message #81127 is a reply to message #79568] Wed, 15 August 2012 05:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> When I set yrange=[a,b] in cgplot it plots values between a,b. How is is possible to do the same in cgimage.?

Yes, the axes don't do image subsetting. If you want
image subsetting, you have to do it directly with the
image.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: cgimage [message #81128 is a reply to message #79568] Wed, 15 August 2012 04:44 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Wednesday, August 15, 2012 7:20:04 AM UTC-4, Gompie wrote:
> Thanks David,
>
> When I set yrange=[a,b] in cgplot it plots values between a,b. How is is possible to do the same in cgimage.?

Use xrange,yrange with cgimage, but also set the /axes keyword
Re: cgimage [message #81129 is a reply to message #79568] Wed, 15 August 2012 04:20 Go to previous message
Gompie is currently offline  Gompie
Messages: 76
Registered: August 2012
Member
Thanks David,
When I set yrange=[a,b] in cgplot it plots values between a,b. How is is possible to do the same in cgimage.?
Re: cgimage [message #81130 is a reply to message #79568] Tue, 14 August 2012 21:37 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Gompie writes:

> I have a 2d array that has pixel values. I can plot it using cgplot. However i want to plot it using cgimage. But when i do it I lose the y axis scaling.
> Is it possible to get the same y axis scaling that I get using the cgplot.

Use the XRANGE and YRANGE keywords to get whatever scaling
you like.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to prevent proliferation of leftover objects when NG plots are included in unit tests.
Next Topic: memory allocation problem

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

Current Time: Wed Oct 08 11:40:59 PDT 2025

Total time taken to generate the page: 0.00694 seconds