Color table question [message #435] |
Mon, 10 August 1992 15:38  |
patel
Messages: 9 Registered: August 1992
|
Junior Member |
|
|
In PV-WAVW, I need to display a gray scale image(256 grays). I need
few colors for graphics. I did the following to accomplish this:
loadct,0 ; load a gray scale color table.
; Load the color table with 7 colors.
Tvlct, 140, 140, 140, 1
Tvlct, 130, 140, 220, 2
Tvlct, 90, 80, 160, 3
Tvlct, 255, 255, 255, 4
Tvlct, 200, 200, 60, 5
Tvlct, 50, 170, 80, 6
Tvlct, 200, 70, 70, 7
; Byte scale the image in 'im'
imb=bytscl(im)
;to avoid funny colors in the image, set all pixels with value <10 to 10
imb(where(imb lt 10))=10
tvscl,imb
end
with this segment of the program, I donot expect to see any colors
in my image. But I do see scattered pixels with different colors.
What am I doing wrong here.
Thanks for your help.
Maqbool Patel
patel@hippy.drad.umn.edu
|
|
|
Re: Color table question [message #436 is a reply to message #435] |
Mon, 10 August 1992 16:59   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
In article <1992Aug10.223854.14071@news2.cis.umn.edu>,
patel@sparky.drad.umn.edu () writes...
> In PV-WAVW, I need to display a gray scale image(256 grays). I need
> few colors for graphics. I did the following to accomplish this:
>
>
> loadct,0 ; load a gray scale color table.
> ; Load the color table with 7 colors.
> Tvlct, 140, 140, 140, 1
> Tvlct, 130, 140, 220, 2
> Tvlct, 90, 80, 160, 3
> Tvlct, 255, 255, 255, 4
> Tvlct, 200, 200, 60, 5
> Tvlct, 50, 170, 80, 6
> Tvlct, 200, 70, 70, 7
>
> ; Byte scale the image in 'im'
> imb=bytscl(im)
> ;to avoid funny colors in the image, set all pixels with value <10 to 10
> imb(where(imb lt 10))=10
> tvscl,imb
> end
>
>
> with this segment of the program, I donot expect to see any colors
> in my image. But I do see scattered pixels with different colors.
> What am I doing wrong here.
First of all, since you've already scaled the image with BYTSCL, you don't need
to rescale it with TVSCL. Use TV instead. Also, you don't need to go to all
that much trouble to make sure that the scaled image has no values <10; you can
simply say
imb = bytscl(im) > 10b
tv, imb
Even better would be to scale the image to exactly the number of colors
available after reserving the 10 colors you're using elsewhere. At the same
time, we can also take care of the fact that your display may have less than
256 colors available:
imb = bytscl(im,top=!d.n_colors-11) + 10b
tv, imb
In fact, you simplify this to one line
tv, bytscl(im,top=!d.n_colors-11) + 10b
Bill Thompson
|
|
|
Re: color table question [message #29762 is a reply to message #435] |
Sat, 16 March 2002 12:19  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Rob Dimeo wrote:
>
> Hi,
>
> I suspect that this question will have a very simple answer (hoping,
> anyway).
>
> I want to display an image using color table 6 but this color table
> does not have white in it. Next I want to display a white crosshairs
> on top of the image. The way that I do this is not ideal because I am
> loading the black-white color table after displaying the color image
> in the window but before I draw the crosshairs (see test code below).
> The reason that this is not ideal is that, in my application, I am
> really moving this crosshairs around the screen as the cursor moves
> over the image. Motion events are being generated resulting in many
> calls to loadct, slowing down the whole works.
>
> I guess what I am really asking for is a persistent way to specify the
> color of something as white (for instance) when a particular color
> table has been loaded. I suspect that I can replace one of the color
> table entries with [255,255,255] for instance? I just am not sure how
> to do this.
>
> Any help you can give is greatly appreciated!
>
> Best regards,
>
> Rob
Dear Rob,
we have defined some colortabels in the way that the first 20 colors
are always the same e.g. for plot
The colors from 21 to 255 are used by contour.
With c_color you can set up the colors for the levels.
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/ct_ncdf.tar.gz
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/ct_blue_green_yellow_red.t
ct_ncdf,c
ct_blue_green_yellow_red
The red_green_blue we don't have but you can design it yourself with
this tool
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/x_def_colortable.tar.gz
regards
Reimar
pro test_color
ct_ncdf,c
ct_blue_green_yellow_red
;loadct,6,/silent
window,xsize = 225,ysize = 225,/free & winVis = !d.window
window,/free,/pixmap,xsize = 225,ysize = 225 & winPix = !d.window
image = smooth(byte(255*randomn(s,225,225,/uniform)),5,/edge_truncat e)
wset,winPix
tv,image
wset,winVis
device,copy = [0,0,!d.x_size,!d.y_size,0,0,winPix]
plots,[0,225],[112,112],linestyle = 0,/device,color=c.white
plots,[112,112],[0,255],linestyle = 0,/device,color=c.white
empty
wdelete,winPix
end
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: color table question [message #29764 is a reply to message #435] |
Fri, 15 March 2002 17:19  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Rob Dimeo (robert.dimeo@nist.gov) writes:
> I suspect that this question will have a very simple answer (hoping,
> anyway).
>
> I want to display an image using color table 6 but this color table
> does not have white in it. Next I want to display a white crosshairs
> on top of the image. The way that I do this is not ideal because I am
> loading the black-white color table after displaying the color image
> in the window but before I draw the crosshairs (see test code below).
> The reason that this is not ideal is that, in my application, I am
> really moving this crosshairs around the screen as the cursor moves
> over the image. Motion events are being generated resulting in many
> calls to loadct, slowing down the whole works.
>
> I guess what I am really asking for is a persistent way to specify the
> color of something as white (for instance) when a particular color
> table has been loaded. I suspect that I can replace one of the color
> table entries with [255,255,255] for instance? I just am not sure how
> to do this.
Typically, one loads "image" colors in one part of
the color table and "drawing" colors in another.
I always put drawing colors at the top of the color
table, because it is easier to restrict image
display to the bottom of the color table (you
don't have to add anything to the byte scaled
image data). I'd set this color table up like
this:
topColorIndex = !D.Table_Size - 1
LOADCT, 6, NColors=topColorIndex
TVLCT, 255, 255, 255, topColorIndex
Then, I'd display my image like this:
TV, BytScl(image, Top=topColorIndex-1)
And I would draw the cursor like this:
PlotS, x, y, /Device, Color=topColorIndex
If you liked this color table you could save it
and use it over again. Here, for example, is one
way to do that:
TVLCT, rr, gg, bb, /Get
Save, rr, gg, bb, File='mycolortable.sav'
Then, when you wanted to use it, you could do
this:
Restore, 'mycolortable.sav'
TVLCT, rr, gg, bb
Just remember to scale your image data into the
number of colors you are using as "image" colors
in the color table. You might even want to save
a variable with this information with your color
table information.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: color table question [message #29771 is a reply to message #435] |
Thu, 14 March 2002 10:58  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
"Rob Dimeo" <robert.dimeo@nist.gov> wrote in message
news:cb539436.0203141014.143e49e@posting.google.com...
> I suspect that I can replace one of the color
> table entries with [255,255,255] for instance? I just am not sure how
> to do this.
Check out tvlct.
tvlct, 255,255,255,100
will insert white into your color table at index 100.
-Rick
|
|
|