color_quan & gif files [message #16489] |
Thu, 29 July 1999 00:00  |
Simon Hall
Messages: 4 Registered: August 1998
|
Junior Member |
|
|
Hi,
I'm producing a lot of images that will eventually end up on a web
page, so I'm generating .gif files. I'm also using a 24 bit display
so my code is something like this:
set_plot, 'win'
device, decomposed = 0
<do plot here>
tvlct, r, g, b, /get
write_gif, filename, color_quan(tvrd(/true), 1, r, g, b), r, g, b
(All this courtesy of dfanning.com, thanks David)
I do get valid gif files but color_quan seems to alter the colours a
little. Most noticably, the white background is now light grey
([248,248,248] rather than [255,255,255]). Not a big difference but
immediately obvious against a white background.
Has anyone else had this problem? Anyone know of a solution that
doesn't involve lightening all the images in photoshop... I don't want
to start poking around with quantization translation vectors if
someone else has already done it...
I'm using IDL 5.2 on NT4.
Once again, TIA
Simon Hall
Simon.Hall@atm.ch.cam.ac.uk
|
|
|
Re: color_quan & gif files [message #16561 is a reply to message #16489] |
Fri, 30 July 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Liam Gumley (Liam.Gumley@ssec.wisc.edu) writes:
> Indeed, it depends on your application. If you are working with plots,
> David's suggestion no doubt produces better results. However for my
> applications (images), the statistical method seems to work better. I've
> created a couple of test images if anyone is interested. If they seem
> dark, you may wish to view them in an application which allows gamma
> correction.
>
> ftp://origin.ssec.wisc.edu/pub/gumley/test1.gif
> was created with
> image = color_quan(image, 1, r, g, b, colors=256)
>
> ftp://origin.ssec.wisc.edu/pub/gumley/test2.gif
> was created with
> image = color_quan(image, 1, r, g, b, cube=6)
> Note the speckle on the cloud feature to the right of the white box. The
> speckle is more apparent when gamma is adjusted to give a pleasing image
> brightness.
Thanks for these test images, Liam. I guess I'm surprised
there aren't more differences between the two methods for
finding the proper colors. At least to my unexpert eye, the
two images looked remarkably similar. I'm mostly surprised,
I think, because the color tables that come back from the
two methods (viewed, for example, with my CIndex program)
are so *completely* different, although both produce
color tables that are quite a bit different from what
we are used to seeing. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: color_quan & gif files [message #16562 is a reply to message #16489] |
Fri, 30 July 1999 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
David Fanning wrote:
> A further advantage of the CUBE method is that the colors it
> produces are independent of the input image. Thus, it is likely
> to work better with primary colors of the sort used in plots.
> Rather than, say, the colors used in images.
Indeed, it depends on your application. If you are working with plots,
David's suggestion no doubt produces better results. However for my
applications (images), the statistical method seems to work better. I've
created a couple of test images if anyone is interested. If they seem
dark, you may wish to view them in an application which allows gamma
correction.
ftp://origin.ssec.wisc.edu/pub/gumley/test1.gif
was created with
image = color_quan(image, 1, r, g, b, colors=256)
ftp://origin.ssec.wisc.edu/pub/gumley/test2.gif
was created with
image = color_quan(image, 1, r, g, b, cube=6)
Note the speckle on the cloud feature to the right of the white box. The
speckle is more apparent when gamma is adjusted to give a pleasing image
brightness.
Cheers,
Liam.
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|
Re: color_quan & gif files [message #16564 is a reply to message #16489] |
Fri, 30 July 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Simon Hall (Simon.Hall@atm.ch.cam.ac.uk) writes:
>> A couple of quick questions before I make a stab at an
>> answer:
>>
>> 1. Are you certain you are in 24-bit color and not
>> 16-bit color?
>
> Definitely 24 bit.
>
>> 2. Why do you think the white background is gray? :-)
>> I guess I am asking, where are you viewing these GIF
>> images? If you read them into IDL after writing them,
>> do they look OK? What about displaying them in Photoshop?
>> If you are viewing them in a browser, which one, specifically?
>
> They look grey in netscape 4.5, IE5 and if I load them into
> PaintShop Pro the background is [248,248,248]
Well, here is what I think is happening and how I fixed
it in my example program.
I think it has to do with how the color space is partitioned.
There must be several ways to do this and IDL provides two
different methods. A statistical method, using a variation
of the Median Cut Algorithm, is the default and usually
produces better colors when there are a lot of colors in
the image. But I think the Floyd-Steinburg dithering method
gives more accurate colors, when the image has just a few
colors. This method is selected by using the CUBE keyword
in the Color_Quan function.
I found this code produced white whites (255, 255, 255) for me. :-)
Here is my example image:
window, xsize=200, ysize=200
device, decomposed=10
polyfill, [0, 0.5, 0.5, 0, 0], [0, 0, 0.5, 0.5, 0], $
/Normal, Color=getColor("red", 1)
polyfill, [1.0, 0.5, 0.5, 1.0, 1.0], [0, 0, 0.5, 0.5, 0], $
/Normal, Color=getColor("green", 2)
polyfill, [1.0, 0.5, 0.5, 1.0, 1.0], [0, 0, 0.5, 0.5, 0], $
/Normal, Color=getColor("blue", 3)
polyfill, [0, 0.5, 0.5, 0, 0], [1.0, 1.0, 0.5, 0.5, 1.0], $
/Normal, Color=getColor("white", 4)
And here is the code to produce the GIF file:
image3d = TVRD(True=1)
image2d = Color_Quan(image3d, 1, r, g, b, Cube=6)
Write_GIF, 'test.gif', image2d, r, g, b
A further advantage of the CUBE method is that the colors it
produces are independent of the input image. Thus, it is likely
to work better with primary colors of the sort used in plots.
Rather than, say, the colors used in images.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: color_quan & gif files [message #16565 is a reply to message #16489] |
Fri, 30 July 1999 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Simon Hall wrote:
> Any advance on Liam's hack?
Just to follow up: I did try experimenting with some of my own
multispectral images in true color mode. After I displayed the images in
the RGB channels, I then displayed a pure white box in one corner. I
then tried various switches in COLOR_QUAN (e.g. DITHER on and off), but
the 'white' color table entries always came out at 248 rather than 255.
Hence the hack.
Cheers,
Liam.
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|
Re: color_quan & gif files [message #16575 is a reply to message #16489] |
Fri, 30 July 1999 00:00  |
Simon Hall
Messages: 4 Registered: August 1998
|
Junior Member |
|
|
> A couple of quick questions before I make a stab at an
> answer:
>
> 1. Are you certain you are in 24-bit color and not
> 16-bit color?
Definitely 24 bit.
> 2. Why do you think the white background is gray? :-)
> I guess I am asking, where are you viewing these GIF
> images? If you read them into IDL after writing them,
> do they look OK? What about displaying them in Photoshop?
> If you are viewing them in a browser, which one, specifically?
They look grey in netscape 4.5, IE5 and if I load them into
PaintShop Pro the background is [248,248,248]
Any advance on Liam's hack?
Thanks again,
Simon Hall
Simon.Hall@atm.ch.cam.ac.uk
|
|
|