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

Home » Public Forums » archive » Re: Legend creation on an image
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: Legend creation on an image [message #48899] Sat, 03 June 2006 07:40
elsueniero is currently offline  elsueniero
Messages: 5
Registered: May 2006
Junior Member
It took me a while to realize that those function are not standar ENVI,
but yours.

Indeed, the solution with them was much more easier!
Thank you a lot

Juan

David Fanning wrote:
> elsueniero@gmail.com writes:
>
>> And the result is a grayscale RGB 1,1,1 to 20,20,20 bar. Not the
>> desired result, using the colors I set on the first line.
>>
>> What could be wrong?
>
> This command:
>
> out = TVRD()
>
> Now you have the variable out as an 8-bit image. So,
> you have to Set_Plot to WIN, re-load your colors,
> and set color decomposition OFF to see colors:
>
> Set_Plot, 'WIN"
> Loadct, colors, 1
> Device, Decomposed=0, Get_Decomposed=curState
> TV, out
> Device, Decomposed=curState
>
> Of course, you *could* use TVREAD and TVIMAGE and you
> wouldn't have to worry about most of this. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Legend creation on an image [message #48901 is a reply to message #48899] Fri, 02 June 2006 20:17 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
elsueniero@gmail.com writes:

> And the result is a grayscale RGB 1,1,1 to 20,20,20 bar. Not the
> desired result, using the colors I set on the first line.
>
> What could be wrong?

This command:

out = TVRD()

Now you have the variable out as an 8-bit image. So,
you have to Set_Plot to WIN, re-load your colors,
and set color decomposition OFF to see colors:

Set_Plot, 'WIN"
Loadct, colors, 1
Device, Decomposed=0, Get_Decomposed=curState
TV, out
Device, Decomposed=curState

Of course, you *could* use TVREAD and TVIMAGE and you
wouldn't have to worry about most of this. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Legend creation on an image [message #48902 is a reply to message #48901] Fri, 02 June 2006 19:31 Go to previous message
elsueniero is currently offline  elsueniero
Messages: 5
Registered: May 2006
Junior Member
>> A colorbar with similar characteristics is described in this article:
>>
>> http://www.dfanning.com/map_tips/precipmap.html
>>

I wrote my own code based on yours, now, and I am almost there...
but...

Since I already had a well-known color code for NDVI, I am not using
your function to load colors. And there is where the problem is...
maybe you can help me:

I have:

colores = [[0,0,0],[0,24,104],[254,254,254],[205,193,169], $
[199,186,169],[182,148,111],[170,129,75],[143,115,65], $
[128,105,35],[148,183,19],[116,171,5],[102,162,2],[81,150,0] ,$
[62,129,0],[24,117,3],[1,92,13],[1,71,0],[5,56,5],[0,40,3],[ 2,16,0]]

set_plot, 'Z'
device, set_resolution=[600, 300], set_colors=256, z_buffering=0

; Change the color formats
R = transpose(colores[0,*])
G = transpose(colores[1,*])
B = transpose(colores[2,*])
; Load the colors (starting at 1 like you recommend)
tvlct,r,g,b,1

(..) Some init code we only need here the following
ncolors = n_elements(R)
bottom=1
(..)

; Start drawing
bar = BINDGEN(ncolors) # REPLICATE(1B, 20)
; Fixed position
position = [0.1, 0.85, 0.9, 0.92]

bar = BYTSCL(bar, TOP=(ncolors-1 < (255-bottom))) + bottom

xstart = position(0)
ystart = position(1)
xsize = (position(2) - position(0))
ysize = (position(3) - position(1))

bar = CONGRID(bar, CEIL(xsize*!D.X_VSize), CEIL(ysize*!D.Y_VSize),
/INTERP)

TV, bar, xstart, ystart, /Normal

out = tvrd()
device,/close
set_plot, 'win'

tv,out

And the result is a grayscale RGB 1,1,1 to 20,20,20 bar. Not the
desired result, using the colors I set on the first line.

What could be wrong?

Thank you for your time!!!
Juan
Re: Legend creation on an image [message #48904 is a reply to message #48902] Fri, 02 June 2006 15:31 Go to previous message
elsueniero is currently offline  elsueniero
Messages: 5
Registered: May 2006
Junior Member
Thank you David,

I downloaded and tried it, and it work great.

But how can I put it inside the array of the image raw data?
After this, what I do is write the array into a geotiff. How can I add
this on a certain location it?


David Fanning wrote:
> elsueniero@gmail.com writes:
>
>> I am trying to create a legend similar to the ones shown here:
>> http://edcdaac.usgs.gov/modis/myd13a1v4.asp
>>
>> I already have my two vectors, one with the limits, and the other with
>> the colors:
>>
>> ndvi_color_map_index = [-1.0,0.0,0.028571429,0.057142857,0.085714286, $
>> 0.11428571,0.14285714,0.17142857,0.2, $
>> 0.25,0.3,0.35,0.40,0.46666667,0.53333333,0.6,0.7,0.8,0.9]
>>
>> ndvi_color_map_colors = [[0,0,0],[0,24,104],[254,254,254], $
>> [205,193,169],[199,186,169],[182,148,111],[170,129,75],[143, 115,65], $
>> [128,105,35],[148,183,19],[116,171,5],[102,162,2],[81,150,0] ,$
>> [62,129,0],[24,117,3],[1,92,13],[1,71,0],[5,56,5],[0,40,3],[ 2,16,0]]
>>
>> * note that n_elements(ndvi_color_map_index) + 1 ==
>> n_elements(ndvi_color_map_colors)
>> thats because all info bellow -1.0 should be black ([0,0,0]) and the
>> same with all the info above 0.9
>>
>> I have both the floating point image in "NDVIfloat" and the 3-band
>> color image in "NDVIcolor"
>>
>> Now what I need to do is to put on the lower-rigth 600x300 pixels of
>> the NDVIcolor image a legend the shown. (the image is 1300x1900 and I
>> now that those 600x300 is background)
>>
>> I know that with some for's I can put the colors bins, but how can I
>> put text on an array from IDL?? Is that possible??
>
> A colorbar with similar characteristics is described in this article:
>
> http://www.dfanning.com/map_tips/precipmap.html
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Legend creation on an image [message #48905 is a reply to message #48904] Fri, 02 June 2006 15:14 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
elsueniero@gmail.com writes:

> I am trying to create a legend similar to the ones shown here:
> http://edcdaac.usgs.gov/modis/myd13a1v4.asp
>
> I already have my two vectors, one with the limits, and the other with
> the colors:
>
> ndvi_color_map_index = [-1.0,0.0,0.028571429,0.057142857,0.085714286, $
> 0.11428571,0.14285714,0.17142857,0.2, $
> 0.25,0.3,0.35,0.40,0.46666667,0.53333333,0.6,0.7,0.8,0.9]
>
> ndvi_color_map_colors = [[0,0,0],[0,24,104],[254,254,254], $
> [205,193,169],[199,186,169],[182,148,111],[170,129,75],[143, 115,65], $
> [128,105,35],[148,183,19],[116,171,5],[102,162,2],[81,150,0] ,$
> [62,129,0],[24,117,3],[1,92,13],[1,71,0],[5,56,5],[0,40,3],[ 2,16,0]]
>
> * note that n_elements(ndvi_color_map_index) + 1 ==
> n_elements(ndvi_color_map_colors)
> thats because all info bellow -1.0 should be black ([0,0,0]) and the
> same with all the info above 0.9
>
> I have both the floating point image in "NDVIfloat" and the 3-band
> color image in "NDVIcolor"
>
> Now what I need to do is to put on the lower-rigth 600x300 pixels of
> the NDVIcolor image a legend the shown. (the image is 1300x1900 and I
> now that those 600x300 is background)
>
> I know that with some for's I can put the colors bins, but how can I
> put text on an array from IDL?? Is that possible??

A colorbar with similar characteristics is described in this article:

http://www.dfanning.com/map_tips/precipmap.html

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: HELP!!!!! How to use IDL to create a move?
Next Topic: how to open three single-band files simultaneously

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

Current Time: Fri Oct 10 22:15:59 PDT 2025

Total time taken to generate the page: 1.34645 seconds