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

Home » Public Forums » archive » Re: color .ps/gamma_ct
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: color .ps/gamma_ct [message #10809] Fri, 23 January 1998 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Peter Gallagher (P.Gallagher@qub.ac.uk) writes:

> I'm trying to plot two images in one Postscript file using the
> same color table. The only problem is that I want to apply a
> different gamma correction to each image.
> The GAMMA_CT changes the appearance of both the images each time
> it is applied - I want a separate gamma correction for each image.
>
> Any body come up against this problem before?

This is another of those "color awareness" issues that
comes up over and over and is a weakness, I think, in
the routines that are supplied with IDL. This is one
of the things I harp on in my book and I even supply
several routines (e.g., XColors) to help you solve
the problem.

Here is a better routine named Set_Gamma that can
be used to change the gamma correction. It uses the
keywords NCOLORS and BOTTOM so that you can determine
just which portion of the color table you want to change
the gamma correction on. It will allow you to have
two (or more) independent images with different gamma
corrections.

Suppose I had 200 colors and I wanted to use the
gray-scale color table for each, but I want each
image to have a different gamma correction. I would
do it like this:

image = GETImage()
LoadCT, 0, NColors=100
LoadCT, 0, NColors=100, Bottom=100
Set_Gamma, 0.7, NColors=100
Set_Gamma, 0.3, NColors=100, Bottom=100
TV, BytScl(image, Top=99)
TV, BytScl(Image, Top=99) + 100B

Cheers,

David

***************************************************
PRO Set_Gamma, gamma, NColors=ncolors, Bottom=bottom

IF N_Elements(ncolors) EQ 0 THEN ncolors = (!D.N_Colors < 256)
IF N_Elements(bottom) EQ 0 THEN bottom = 0

; Keep gamma between 0.1 and 10.

IF N_Params() EQ 0 THEN gamma = 1.0
gamma = gamma > 0.1
gamma = gamma < 10.0

; Get the current color table vectors.

TVLCT, r, g, b, /Get

; Pull the colors needed.

red = r[bottom:ncolors-1+bottom]
green = g[bottom:ncolors-1+bottom]
blue = b[bottom:ncolors-1+bottom]

; Apply gamma correction.

index = Findgen(ncolors)
distribution = index^gamma
index = Round(distribution * (ncolors-1) / Max(distribution))
red = Congrid(red(index), ncolors)
green = Congrid(green(index), ncolors)
blue = Congrid(blue(index), ncolors)

; Update the color table vectors.

r[bottom:ncolors-1+bottom] = red
g[bottom:ncolors-1+bottom] = green
b[bottom:ncolors-1+bottom] = blue

; Reload the color table.

TVLCT, r, g, b
END
***********************************************************


-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: color .ps/gamma_ct [message #10811 is a reply to message #10809] Fri, 23 January 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Peter Gallagher wrote:
>
> Hi all,
>
> I'm trying to plot two images in one Postscript file using the
> same color table. The only problem is that I want to apply a
> different gamma correction to each image.
>
> Something like ...
>
> LOADCT, 3
>
> TV, image1
> GAMMA_CT,.7
>
> TV, image2
> GAMMA_CT,.3
>
> The GAMMA_CT changes the appearance of both the images each time
> it is applied - I want a separate gamma correction for each image.
>
> Any body come up against this problem before?
>
No, but having just read this part in David Fanning's excellent book,
I would assume you will have to try the following steps:

1) load your color table
2) apply the 1st gamma correction
3) read the color table into an array (or the 3 r,g,b arrays)
4) load the original color table again
5) apply the second gamma correction
6) read the color table into an array
7) shrink both arrays by eliminating every second entry
8) load array1 in the lower part of the color table
9) load array2 in the upper part of the color table
10) re-scale your images (BYTSCL) so that they span the color
range of 0..half-1 (image1) and half..top (image2)

Hope this helps,
Martin.

------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
Re: color .ps/gamma_ct [message #10814 is a reply to message #10809] Fri, 23 January 1998 00:00 Go to previous message
Peter Gallagher is currently offline  Peter Gallagher
Messages: 2
Registered: January 1998
Junior Member
Liam Gumley wrote:
>
> How about something like this:
>
> SET_PLOT,'PS'
> DEVICE,/COLOR,BITS=8
>
> LOADCT, 3
> GAMMA_CT,.7
> TV, image1
>
> LOADCT, 3
> GAMMA_CT,.3
> TV, image2
>
> DEVICE,/CLOSE
>
> Cheers,
> Liam.


Thanks Liam but I tried this and GAMMA_CT still changes both the
images.

I also tried splitting the color table in two but again I still can't
work out how to apply the GAMMA_CT to each image individually.

Cheers,

Peter.


--
============================================================ ======
Peter T. Gallagher, | Tel: +44 1232 273708
Dept. of Pure and App. Physics, | Fax: +44 1232 438918
The Queen's University of Belfast,| E-mail: P.Gallagher@qub.ac.uk
Belfast, BT7 1NN, | http://star.pst.qub.ac.uk/~ptg
Northern Ireland. |
============================================================ ======
Re: color .ps/gamma_ct [message #10815 is a reply to message #10809] Fri, 23 January 1998 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Peter Gallagher wrote:
> I'm trying to plot two images in one Postscript file using the
> same color table. The only problem is that I want to apply a
> different gamma correction to each image.
> Something like ...
> LOADCT, 3
>
> TV, image1
> GAMMA_CT,.7
>
> TV, image2
> GAMMA_CT,.3
>
> The GAMMA_CT changes the appearance of both the images each time
> it is applied - I want a separate gamma correction for each image.

How about something like this:

SET_PLOT,'PS'
DEVICE,/COLOR,BITS=8

LOADCT, 3
GAMMA_CT,.7
TV, image1

LOADCT, 3
GAMMA_CT,.3
TV, image2

DEVICE,/CLOSE

Cheers,
Liam.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Widget inflation
Next Topic: Re: Trouble with IDL 5.0.2 (filled contours)

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

Current Time: Sun Oct 12 02:20:25 PDT 2025

Total time taken to generate the page: 1.04307 seconds