Visual Media Processing Using Matlab Beginner's Guide
上QQ阅读APP看书,第一时间看更新

An introduction to color image processing

Before we begin examining the differences of color image processing to grayscale image processing techniques, we must first understand the difference between color and grayscale images. As explained in previous chapters, a grayscale image can be represented as a two-dimensional, m-by-n matrix (m rows and n columns). Its elements, called pixels, have values spreading from 0 to 255 (in the case of 8-bit images). A value of zero represents black, a value of 255 represents white, while all the values in between represent different shades of gray.

In the case of color images, the matrices become three-dimensional. The first two dimensions, as in the case of grayscale images, are the number of rows and the number of columns (m-by-n). The difference is that the third dimension typically comprises three layers, representing colors. That is, color images are three-dimensional (usually m-by-n-by-3) matrices and can be thought of as three grayscale images combined together. Each image typically represents one of the colors (that is, Red, Green, and Blue) of the image, which is therefore characterized as RGB. These three layers are also called color channels of the color space (RGB in our case).

Similarly to the grayscale image case, when we have a case of color images of 8-bits per channel, a zero value in one channel represents non-presence of the color, while a 255 value suggests full color presence. The three color channels are mixed together to produce the final color for each pixel in the image. A pure fundamental color occurs when one of the three color channels has the maximum value and the two others are equal to zero. This means that a pixel with {R, G, B} values equal to {255, 0, 0} will be pure red. Similarly, a pixel with values {0, 255, 0} will be pure green and a pixel with values {0, 0, 255} will be pure blue. Different mixtures of values in the three basic color channels will ultimately produce different colors.

Note

A more extensive description of the basic concepts of RGB color images can be found in Chapter 2, Introduction, of the manual of the Image Processing Toolbox. It can be found freely available in pdf format on the website of Mathworks, at http://www.mathworks.com/help/pdf_doc/images/images_tb.pdf.

What you may have deduced from the previous description of color images, is the fact that in order to apply the methods covered in previous chapters for color image processing, we will have to repeat the same process three times (one for each color channel). This is typically correct, as we will see in the rest of this chapter. Let's start with the basic image manipulations covered in Chapter 1, Basic Image Manipulations.