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

Home » Public Forums » archive » Re: RGB Color reconstruction
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: RGB Color reconstruction [message #56470] Tue, 30 October 2007 12:53
rpertaub@gmail.com is currently offline  rpertaub@gmail.com
Messages: 43
Registered: January 2007
Member
On Oct 30, 3:16 pm, David Fanning <n...@dfanning.com> wrote:
> rpert...@gmail.com writes:
>> I changed the tvscl to tv, and indeed it makes no difference since I
>> already bytescaled previously. I use the maxes because my maximum
>> count for each channel is different (red is much more than green and
>> blue).
>
> Yes, but you scaled each channel individually, so each used
> the maximum value of that channel in the scaling! No need to
> force it to do that.
>
>> I also switched the blue and red to get a real RGB opposed to BGR. The
>> image does seem to have changed from an RGB to a BGR...an area which
>> used to be all red is now all blue...however, again clicking on it and
>> looking at counts at that blue pix for difference channels tells me
>> that the red frame had more intensity there than the blue frame, yet
>> the pixel color is blue. I would expect if the red frame to be much
>> higher intensity the pixel to be a reddish purple...not blue..!
>
> What version of IDL are you using? And how are you determining
> the image value at that pixel location?
>
>> still not understanding how true=1 creates an rgb image..
>
> It just loads the three planes of the 24-bit image into
> the three color channels. No magic there, at all. It would
> be the same as doing this:
>
> TV, BytScl(red), Channel=1
> TV, BytScl(green), Channel=2
> TV, BytScl(blue), Channel=3
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

I am using IDL 6.3
But I also wanted to say thanks, as your questions pointed me to my
mistake. I am doing hyperspectral imaging so it is a bit crazy with
the many wave bands etc...but thanks again for your help!
rp
Re: RGB Color reconstruction [message #56471 is a reply to message #56470] Tue, 30 October 2007 12:16 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rpertaub@gmail.com writes:

> I changed the tvscl to tv, and indeed it makes no difference since I
> already bytescaled previously. I use the maxes because my maximum
> count for each channel is different (red is much more than green and
> blue).

Yes, but you scaled each channel individually, so each used
the maximum value of that channel in the scaling! No need to
force it to do that.

> I also switched the blue and red to get a real RGB opposed to BGR. The
> image does seem to have changed from an RGB to a BGR...an area which
> used to be all red is now all blue...however, again clicking on it and
> looking at counts at that blue pix for difference channels tells me
> that the red frame had more intensity there than the blue frame, yet
> the pixel color is blue. I would expect if the red frame to be much
> higher intensity the pixel to be a reddish purple...not blue..!

What version of IDL are you using? And how are you determining
the image value at that pixel location?

> still not understanding how true=1 creates an rgb image..

It just loads the three planes of the 24-bit image into
the three color channels. No magic there, at all. It would
be the same as doing this:

TV, BytScl(red), Channel=1
TV, BytScl(green), Channel=2
TV, BytScl(blue), Channel=3

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: RGB Color reconstruction [message #56472 is a reply to message #56471] Tue, 30 October 2007 12:06 Go to previous message
rpertaub@gmail.com is currently offline  rpertaub@gmail.com
Messages: 43
Registered: January 2007
Member
On Oct 30, 2:38 pm, David Fanning <n...@dfanning.com> wrote:
> David Fanning writes:
>> Well, quite a lot going wrong here, I think. :-)
>
> Also, why would you use TVSCL after just scaling
> the data? TVSCL with 24-bit color images is just
> going to get you in a WORLD of hurt, sooner or later.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

I changed the tvscl to tv, and indeed it makes no difference since I
already bytescaled previously. I use the maxes because my maximum
count for each channel is different (red is much more than green and
blue).

I also switched the blue and red to get a real RGB opposed to BGR. The
image does seem to have changed from an RGB to a BGR...an area which
used to be all red is now all blue...however, again clicking on it and
looking at counts at that blue pix for difference channels tells me
that the red frame had more intensity there than the blue frame, yet
the pixel color is blue. I would expect if the red frame to be much
higher intensity the pixel to be a reddish purple...not blue..! still
not understanding how true=1 creates an rgb image..
Re: RGB Color reconstruction [message #56473 is a reply to message #56472] Tue, 30 October 2007 11:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Well, quite a lot going wrong here, I think. :-)

Also, why would you use TVSCL after just scaling
the data? TVSCL with 24-bit color images is just
going to get you in a WORLD of hurt, sooner or later.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: RGB Color reconstruction [message #56474 is a reply to message #56473] Tue, 30 October 2007 11:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
rpertaub@gmail.com writes:

> I am doing some RGB color reconstruction and I am confused by some of
> the display. I tried to paste my image for greater clarity, but could
> not, so will try to explain as clearly as possible. Here is the simple
> code I am using with three image frames for the 3 RGB channels:
>
> maxes=lonarr(3)
> maxes[0]=max(final_red)
> maxes[1]=max(final_grn)
> maxes[2]=max(final_blu)
>
> final_image=lonarr(3,1272,1052)
> final_Image[0,*,*] = bytscl(final_blu,max=maxes[2])
> final_Image[1,*,*] = bytscl(final_red,max=maxes[0])
> final_Image[2,*,*] = bytscl(final_grn,max=maxes[1])
>
> window,3,title='Reconstructed Cube RGB Image',xsize=1200,ysize=900
> tvscl,final_image,true=1
>
> I get my RGB image thus. Then, I look at one region that is clearly
> blue in color and click on it to get the int of each channel. My print
> out int is thus:
>
> 450nm (blue-ish):3871
> 550nm(green-ish):12518
> 650nm(red-ish):14212
>
> Clearly from the intensities, red channel has the highest intensity.
> Blue is in fact the lowest. Yet, the image at that pixel was BLUE! I
> am obviously not understanding how tvscl,final_image,true=1 works...
>
> Any idea?

Well, quite a lot going wrong here, I think. :-)

First of all, you created a BGR image, instead of an RGB image.
Now I think about it, maybe that is the source of ALL your
problems. :-)

But I don't see why your are fooling around with the MAXES.
That part makes no sense at all to me, since BYTSCL would
do all this on its own.

I don't understand what you are doing to get "the int of
each channel", but perhaps if you get the image planes
in the right order this would be moot.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: New Color Table Loading Tool
Next Topic: Re: Minimum Noise Fraction Doubts...

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

Current Time: Wed Oct 08 18:07:15 PDT 2025

Total time taken to generate the page: 0.00604 seconds