Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert RGB to chromatic color space

Hi everyone..

Is there any example source code that can convert a normal RGB image to chromatic color space and display in a histogram (in 3D view if possible)? Or any suggestion on my attached simple program? Looks like it doesn't work for it..

I did it based on

r = R/(R+G+B) I only tried on chromatic Red
b = B/(R+G+B)

Thx

p.s. another small question...If we look at the equation only, the result of r or b is within 0 & 1. How can a pixel with a value of decimal? I can't figure out...or I need to multiple the result of r with 255 to get chromatic red? (I tried before but I got an image of black)

thx again
0 Kudos
Message 1 of 10
(6,111 Views)
Without going deeper into your code, I noticed that you are trying to operate on 8 bits images. You should work on 16 bits images if you want to do arithmetics on color planes. Otherwise, 255 + 255 = 254 ?!

CC
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 10
(6,103 Views)
hi...

it doesn't work...

if i change the last three's destination image to be 16 bit... it says incompatible image type
if i change all to be 16-bit...it says invalid image.. 🙂

plz help
0 Kudos
Message 3 of 10
(6,092 Views)
liaw82 -

I think changing the last three destination images to 16-bit, and then after you've extracted the R, G, and B planes, casting those images (the ones with names RED, GREEN, BLUE) to 16-bit will solve your problem.

Greg Stoll
IMAQ R & D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 4 of 10
(6,088 Views)
hi..

it works after i cast the RED, GREEN, and BLUE to 16-bit. But dunno y the plotted histogram is alwaz the same for the different type of input image..

Never Mind I will try to figure out myself..thz anyway
0 Kudos
Message 5 of 10
(6,080 Views)
Hello,

Thanks for posting about this, it has certainly been fun to play with! After reading through the original post, I have created a VI similar to the one you have been working on. In my situation, I was able to use several different images and receive different histograms. Additionally, it allowed me to display an image representing the percentage of any particular color plane within the original image. This made for some cool pictures.

If you are still having trouble or have any other questions, feel free to continue to post and we'd be glad to help out. Otherwise, good luck on your application.

Robert
0 Kudos
Message 6 of 10
(6,054 Views)
Hi..

do u mind to post me a sample of ur code? so that I can have a preference? coz i still cannot get it..

thx alot..

liaw
0 Kudos
Message 7 of 10
(6,027 Views)
Sure thing Liaw. Let me clean it up a little bit first, and I can put it up sometime soon.

Regards,

Robert
0 Kudos
Message 8 of 10
(6,008 Views)
Hello again,

Sorry about the delay, I just needed to make it readable!

Here is the VI that I had made. Hopefully I understand your question correctly. Let me know if you need anything else.


Robert
0 Kudos
Message 9 of 10
(5,983 Views)
thx... robert

thx for helping me to solve my problem.. I have roughly run through the code n seems working fine. I will get help from you again if i don understand it.

thx again..
0 Kudos
Message 10 of 10
(5,972 Views)