Color spaces

Although its definition can vary, in general, a color space (sometimes referred to as a color model) is a method that is used for interpreting, storing, and reproducing a set of colors. Let's break this down with an example—a grayscale color space. In a grayscale color space, each pixel is represented with a single 8-bit unsigned integer value that corresponds to brightness or gray-intensity of that pixel. This makes it possible to store 256 different levels of grayscale, in which zero corresponds to absolute black and 255 corresponds to the absolute white. In other words, the higher the value of a pixel, the brighter it is, and vice versa. The following image displays all possible colors that exist within the grayscale color space:

Another commonly-used color space is RGB, in which each pixel is represented by three different 8-bit integer values that correspond to the red, green, and blue color intensity of that pixel. This color space is particularly known for being used in TVs, LCDs, and similar displays. You can check this out for yourself by looking at the surface of your monitor using a magnifier. It relies on the simple fact that all colors can be represented by combining various amounts of red, green, and blue. The following image depicts how all other colors (such as yellow or pink) between the three main colors are formed:

An RGB image that has the same R, G, and B values in each of its individual pixels would result in a grayscale image. In other words, the same intensity of red, green, and blue would result in a shade of gray.

Another color space that is widely used in computer vision is the HSV (Hue, Saturation, and Value) color space. In this color space, each pixel is represented by three values for hue (the color), saturation (the color strength), and value (how bright or dark it is). Hue, as seen in the following image, can be a value between 0 and 360 (degrees), which represents the color of that pixel. For instance, zero and nearby degrees correspond to red and other similar colors:

This color space is especially popular in computer vision detection and tracking algorithms that are based on the color of an object, as you'll see later on in this book. The reason for this is that the HSV color space allows us to work with colors regardless of how dark or bright they are. This is not easy to achieve with RGB and similar color spaces, as looking at an individual pixel channel value cannot tell us its color.

The following image is another representation of the HSV color space, which shows the variation of hue (from left to right), saturation, and value in one image, thus producing all possible colors:

Besides the color spaces mentioned in this section, there are many other color spaces, each with their own use cases. For instance, the four channel CMYK color space (Cyan, Maroon, Yellow, and Key/Black) has proven to be most effective in printing systems.

Make sure to learn about other popular color spaces from the internet and how they might be useful for any particular computer vision problem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.22.23