How to calculate the different color area from RGB image

Hi everybody, Now i have a RGB image, red, white, black(background). Now i can move the black background from picture,and how can i calculate the each red and white area ratio?

Answers (2)

To detect the white area, the easiest way would be to extract the green or blue channels, threshold on that, and then sum(sum(TheArray))) to get the area of the white portion. Then, threshold on the red channel and turn off any pixel that occurs in the first thresholded result (e.g., Red & ~Green), and sum(sum()) to get the area of the red portion.
Do not simply threshold on red, as white has equal components of red, green, and blue, so any white area will show up strongly on the red channel.
I have several color segmentation demos on my File Exchange. If you understand those, you will see how to answer your question. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Categories

Find more on Images in Help Center and File Exchange

Asked:

rex
on 3 Oct 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!