Why do we use the HSV colour space so often in vision and image processing?

I see the HSV colour space used all over the place: for tracking, human detection, etc... I'm wondering, why? What is it about this colour space that makes it better than using RGB?

• This is a very good question. In my opinion, it would benefit from being a bit more detailed: what is HSV, what is RGB. As most answers are comparing HSV to RGB, the title could be rephrased to compare these two color spaces. – PhilMacKay Oct 19 '12 at 20:45
• Another good question might be, "Why is HSV being used all over the place instead of HSL?" – posfan12 Oct 24 '16 at 18:05

The simple answer is that unlike RGB, HSV separates luma, or the image intensity, from chroma or the color information. This is very useful in many applications. For example, if you want to do histogram equalization of a color image, you probably want to do that only on the intensity component, and leave the color components alone. Otherwise you will get very strange colors.

In computer vision you often want to separate color components from intensity for various reasons, such as robustness to lighting changes, or removing shadows.

Note, however, that HSV is one of many color spaces that separate color from intensity (See YCbCr, Lab, etc.). HSV is often used simply because the code for converting between RGB and HSV is widely available and can also be easily implemented. For example, the Image Processing Toolbox for MATLAB includes functions rgb2hsv and hsv2rgb.

The color information is usually much more noisy than the HSV information.

Let me give you an example: Me and some friends were involved in a project dealing with the recognition of traffic signs in real scene videos (noise, shadows and sometimes occlusion present). It was a part of a bigger project, so that allowed us time to try out different approaches to this particular problem (and re-use older approaches). I did not try color-based approach myself, but I remember an interesting information: _The dominant RGB component in a STOP sign was often not red! (mostly due to shadows)

You can usually get better information from a HSV colorspace. Let me try and give a personal experience example again: Try imagining you have an image of a single-color plane with a shadow on it. In RGB colorspace, the shadow part will most likely have very different characteristics than the part without shadows. In HSV colorspace, the hue component of both patches is more likely to be similar: the shadow will primarily influence the value, or maybe satuation component, while the hue, indicating the primary "color" (without it's brightness and diluted-ness by white/black) should not change so much.

If this explanations do not sound intuitive to you, I suggest:

• try and better understand components used to represent a color in HSV colorspace, and renew you knowledge of RGB

• try and see the reasons why these kinds of color representation were developed: it is always in some way, based on some view of human interpretation of color

e.g. children do not actually like highly colored == valued objects, they prefer highly satuated objects, objects in which the color is intense and non-diluted

• after you get this and develop some intuition, you should play with images: try decomposing various images in their R-G-B and H-S-V components

Your goal would be to see and understand a difference in these decompositions for images that contain shadows, strong illumination, light reflection.

• if you have a particular type of images you like to play with, try decomposing them: who knows, maybe RGB really is more suited for your needs than HSV :)

• If it is a shadow, it should change only brightness - not saturation. – Andrey Rubshtein Oct 18 '12 at 16:02
• @Andrey as I said, I did not work on the color-based approach myself, but I can speculate that if was not only a shadow -- probably some indirect lighting from the surroundings or something similar also played a role. – penelope Oct 19 '12 at 8:24
• You are right. However, in the case of indirect lighting the Hue might change as well. – Andrey Rubshtein Oct 19 '12 at 9:09
• @Andrey Hence my wording: "more likely", "similar", "primarily influence", ... After all, I was not explaining HSV, just giving some examples and educated guesses based on experience. And, the best way to choose the most suited color-space for any application is to play around with your image database and different color-spaces – penelope Oct 19 '12 at 9:46
• Anything in shadow and hence not lit by the primary light source (the sun) is being lit by the secondary light source - the sky, which is a giant, bright, and very blue light. To human eyes red still looks red since our eyes make relative color measurements instead of absolue color, which is why your indoor, non-flash photos look more yellow than you think they should. And I am in absolute agreement about playing around with your actually image database. – John Robertson Nov 6 '12 at 16:33

Using only the Hue component makes the algorithm less sensitive (if not invariant) to lighting variations.

Another popular option is LAB color space, where the AB channels represent the color and euclidean distances in AB space better match the human perception of color. Again, ignoring the L channel (Luminance) makes the algorithm more robust to lighting differences.

The best answer I can figure is: RGB has to do with "implementation details" regarding the way RGB displays color, and HSV has to do with the "actual color" components. Another way to say this would be RGB is the way computers treats color, and HSV try to capture the components of the way we humans perceive color.

I'll elaborate:

Color is a perception based on electromagnetic waves. Natural properties of these waves are,for example intensity and frequency. If we sweep the frequency of a lightwave from infra-red to ultra-violet, we would visually perceive a color variation along the rainbow colors. Rainbow colors could be considered "pure colors" because they are represented by single-frequency waves.

Now the human eye can only respond, or "resonate" to three main light frequencies, not surprisingly red, green and blue. The fact is that this response is non-linear, so the retina can distinguish a given pure color (and implicitly its "frequency") by the combined response of the three color components.

The RGB color space exists as such only to mimic the internal workings of our retina, so that a vast majority of colors can be represented on computer displays by means of a convenient (from a computer point of view) 24 bits-per-pixel color coding. The RGB color space has no intrinsic relation to the natural color properties, neither to human interpretation of color.

For example, any arithmetical operation performed channel-wise in RGB space (for example, generation of color gradients) gives very crude or even plainly "wrong" results. That's why it is advised to create colormaps by converting the color stops from RGB to other color spaces (HLS, Lab, etc.), performing the interpolations, then converting the interpolated values back to RGB.

Hope this helps!

• I'd disagree. There are three domains, not two: human, computer and physics. The RGB model is derived from the human eye, which has three color receptors. – MSalters Jul 5 '12 at 15:40
• @MSalters I think we are talking about the same things (although perhaps I haven't made myself completely clear). The RGB displays are made to match our color-perception system. They have a computer counter-part, the (R,G,B) "coordinates". Since these coordinates map to implementation rather to the physical, "real nature" properties of color, they are not suited to perform some mathematical processing, e.g. perceptually linear gradient interpolation, color correction, brightness and saturation ops, etc. – heltonbiker Jul 5 '12 at 17:11

HSV stands for Hue-Saturation-Value. It is actually a type of color plane representation (like RGB, YCbCr etc.).

It is a device independent color representation format: The HSV color representation is useful to detect specific color types, e.g.: skin color, fire color etc.

Matlab function to convert an RGB image to HSV plane is rgb2hsv('/inputimage_name').

I will give you an example to understand. Like our hand has many parts palm, back palm, and below that. we can see different color variation in these areas, but the hue for all these regions don't vary much, so hue value can be useful in hand segmentation.

There is nothing I know of that is especially better with HSV as compared to YUV or LAB that would make it better for the feature extraction and illumination invariance or visualization. I guess HSV is the more commonly used one because of convention and continuity: its easier to compare results and communicate with each other if you both use the same colorspace.

With that said, HSV (as opposed to RGB) is used in computer vision for 2 reasons I know of:

1. Visualization. Whenever you have directional information densely over an image, then HSV is a good color space for visualization. Instead of plotting little vectors over an image(they will clutter everything), you can plot color with HSV, by putting the directional vector mapped to the H (vector angle) and S(vector magnitude). This leaves the Value component, which can be set in any number of ways depending on what you want to achieve. See below example from the middlebury optical flow dataset. HSV is used to display directions densely.

1. Feature extraction and illumination invariance, as explained in the other answers.

As others mentioned, it is beneficial to separate the luma from the chroma. The luma varies greatly in the scene based on the amount of light falling on the object. Chroma, on the other hand, correlates better with the object's intrinsic properties, and for properly white-balanced images is more-or-less invariant.

However, I would like to add that HSV, HSL, or in fact any color space with polar parametrization of the chroma plane, are bad choices for that purpose. That is because they introduce a singularity on the line of grays (which hue is gray?), making them very sensitive to noise and white-balance. Additionally comparing between two colors in a polar coordinate system isn't as straight forward. Also note that neither the value in HSV nor lightness in HSL correspond to the human perceived lightness or any other physical measure of energy.

There are plenty of linear color spaces that give the same luma-chroma separation while preserving linearity (YCbCr, YUV) or model human vision properly (LUV, LAB). With those you can compare two colors using a Euclidean L2 norm on their chromaticities, resulting in a more robust algorithm overall.

Why HSV/HSL are used so often then? Hard to give an objective answer. From my experience it's mostly due to ignorance and the availability of RGB->HSV conversion routines. Had to work with code whose authors didn't understand gamma-correction, let alone different color-spaces. Seen code that converted RGB to HSV then segmented the image based on the hue, disregarding the fact that it's a modular quantity. I think we can agree that those weren't conscious decisions backed by any reason.

HSV color model is more correlated to how humans see colored objects, as compared to RGB, YUV, Lab etc.

We see what color the object is (Hue), how much is it saturated (Saturation) and how much white light is falling on it (Intesity).