To categorize jet colormap by pixels of some colors

enter image description here

Data I want to categorize it by counting the following pixels through HSV (Hue-Saturation-Lightness)

To show RGB channels (source) without HSV

x = linspace(0,1, size(Map)(1)); figure(Fignr) lw = 4; plot( x, Map(:,1),'color',[1,0,0],'linewidth',lw, x, Map(:,2),'color',[0,1,0],'linewidth',lw, x, Map(:,3),'color',[0,0,1],'linewidth',lw, x, mean(Map,2),'color',[0.7,0.7,0.7],'o') xlabel 'fraction' ylabel 'intensity' end 

where example showRGBchannels(1,summer(500)) gives

enter image description here

This is just an example about one mapping where you can see fractions of different colors Red, Green and Blue about one figure. However, the color map must be extended to colors yellow, green and dark blue too.

You can assume that

However, I think this is not way to go, since HSV can a good choice here. I was also recommended to use other colors than Rainbow for the visualization (continuous red-blue, publication here).

There are many implementations to separate colors and argumentation about which color seem to use. Let's focus here on RGB colors and their separation. Possibly, through HSV or any other appropriate method not mentioned.

How can you categorize and count the appropriate pixels i.e. colours of the first picture through HSV? Any classes and/or papers for it?

Léo Léopold Hertz 준영 asked Feb 23, 2015 at 23:41 Léo Léopold Hertz 준영 Léo Léopold Hertz 준영 139k 185 185 gold badges 456 456 silver badges 707 707 bronze badges To separate colours RGB space is not nice. You should use HSV, Commented Feb 23, 2015 at 23:46

@AnderBiguri Yes, HSV is ok too. Can you give an example how to do color categorisation in HSV. I got also a recommendation use Moreland's paper color-scheme. However, let's stick to one scheme and understand it better.

Commented Feb 24, 2015 at 7:10

1 Answer 1

Note Before reading. You seem to be confusing the choice of colormap with colour segmentation. It is important to note:

EDIT: ADDITIONAL DISCUSSION ABOUT USING COLORMAPS

As a student working in medical imaging, I can tell that for sure colours are NOT used for segmentation, but the numerical values of data (usually single channel) itself. The use of different colourmaps its only for visualization pourposes.

There are a wide range of opinions in here, but generally centred in: The jet colormap is not clear enough (and its the most widely used!). The Moreland colormaps for example, rely in having a clear midpoint in the visualization, so it is clear for the user to see which values are above the average and which below.

Even Matlab is starting to agree with the idea of stop using the jet colormap, as the default colormap of matlab is not any-more jet (R2014b). Read more here.

Another opinion is that the jet colormap does not translate good to gryscale. Read more here.

However, note that all this discussion has ABSOLUTELY nothing to do with how the colour is described. You can describe any of the colormaps discussed about in RGB, HSV, CIE Lab* or any other colour representation you'd want.

Original answer

So, rather than giving you code (that you can fin in SO also) I will just put an small example of how the HSV space work. As you have seen, in RGB, separating colours by their numerical values seems to be not possible. Therefore some other colour space is needed.

One of the most common approaches is to use the HSV space.

enter image description here

As you can see in the picture, this space has 3 values. Hue (the angle), Saturation and Value. Among the three of them, they create a cylindrical coordinate system, that points you to an specific color. From the figure, you can notice that while S and V change the "brightness" and "amount of colour" -like parameters, HUE is the only one that actually changes the chroma of the colour. So all Reds are in the same range of H, inddependently of the values of S and V.

See in the next figure a slice of this cylinder:

enter image description here

We can conclude from this image, that all yellow coloured values are around 30-90 degrees of H.

This information and the smart use of Matlab functions such as rgb2hsv should get you going in the right direction.

HINT: You want to do something with that 360-0 transaction for red coloured values.