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

Home » Public Forums » archive » Re: using TVRD(true=0) with a 24-bit image and decomposed=0
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: using TVRD(true=0) with a 24-bit image and decomposed=0 [message #38790 is a reply to message #38788] Mon, 29 March 2004 13:56 Go to previous messageGo to previous message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
"Chris ODell" <odell@aos.wisc.edu> wrote in message
news:2fafbdc3.0403291218.95f4491@posting.google.com...
> To all IDL color-masters,
>
> I am trying to simply read an image that was originally plotted like
> this:
>
> tv, image
>
> where image is a 2D byte-array of colors IN MY CURRENT COLORTABLE; ie,
> numbers from 0 to 255. However, I am on a 24-bit display. I have
> device, decomposed=0
> and backing-store set on retain=2.
>
> If i do this:
>
> im2 = tvrd()
> tv, im2
>
> I get way more color=255 than I should; i do not get back the precise
> original image. I understand that I can get the RGB triples by doing
> tvrd(true=1), but *I don't want the RGB triples*. I just want the
> simple numbers from 0 to 255 that I originally plotted. How do I get
> them using tvrd()?

The IDL docs for TVRD say:

"If the display is a 24-bit display, and both the CHANNEL and TRUE
parameters are absent, the maximum RGB value in each pixel is returned."

This probably explains why you don't get back exactly what you put in and
why you see more 255 values.

If you do a TV with 8-bit image data and a color table on a 24-bit display,
IDL is going to translate your 8-bit data to 24 bits via the color table and
write the 24-bit data to the screen. There is not much else IDL can do
here. It needs to set all 24 bits to get the right picture on the screen.

Once the image is stored in the 24-bit frame buffer, the 8-bit data is lost,
from the point of view of the TV routine. Your IDL program could save it
someplace if it is needed later.

When IDL does the TVRD from the 24-bit frame buffer in this situation, it
needs to translate it back to 8 bits somehow. Clearly, there are some
difficulties here. One approach is to take the current color table and try
to match every 24-bit pixel from the display to one of the color table
entries. This would be extremely time consuming and may not always "work".
The closest match may not be good enough, or if the color table contains two
entries with the same color, which of the two should be used? So, IDL
simply behaves as stated above.

Now, if you really wanted to, you could read all three channels with the
TRUE kwd, and then use COLOR_QUAN to get a color array and palette back out
of your 24-bit image. This is essentially the approach I mentioned above,
which you can go ahead and do. But I think you'd be better off saving the
original 8-bit data somehow.

Karl
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: How to set elements of arrays as blank (not zero)?
Next Topic: Finding the closest value in an array...

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

Current Time: Sat Oct 11 10:51:39 PDT 2025

Total time taken to generate the page: 0.47445 seconds