How to compute the RGB Pixel frequency that represents the colour in whole channels.

2 views (last 30 days)
Hello Matlab experts,
To compute pixels frequency on RGB image, we usually use histogram on each individual channel. Here my question is how to compute the pixel colour occurrence that represent the color itself. For example, how to compute how many occurrence for the Red pixel (255,15,20).
I know how to do it by counting using 3 for loops, but my idea is very complicated and would like to know if there is more efficient way.

Accepted Answer

Image Analyst
Image Analyst on 8 Nov 2013
You need to do the full 3D histogram as you were thinking. Because a red that is (255,15,20) is a different color than the red that is (255,15,21). It's not complicated at all. In the spectrum from simple to complicated for MATLAB coding, this would be way, way, way towards the simple end. Doesn't even come close to "very complicated" or even a little bit complicated. I attach my color gamut visualizer below in case you want to see how I did it. Of course you can use fewer bins if you want a histogram that's smaller than 16.7 million colors. For example, you can quantize to 32x32x32 if you want.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!