1. An RGB color image is an M N 3 array of color pixels.
2. Each color pixel is a triplet corresponding to red, green and blue
components of an RGB image at a specific spatial location.
3. An RGB image can be viewed as a stack of a three gray-scale images
that produce a color image on the screen when fed into red, green and
blue inputs of a color monitor.
4. The three images forming an RGB color image are referred to as the red,
green and blue component images.
5. The data class of the component images determines their range of
6. The number of bits used to
represent the pixel values of
the component images
determines the bit depth of an
7. The number of possible colors
in RGB image is (2^b)^3.
8. The cat operator is used to stack the three component images, having
rgb_image = cat (3, fR, fG, fB)
9. The three component images can be extracted by using the syntax:
fR = rgb_image (: , : , 1)
fG = rgb_image (: , : , 2)
fB = rgb_image (: , : , 3)
10. The RGB color space is shown graphically as an RGB color cube.
11. The vertices of the cube are the primary and secondary colors of light.
12. Moreover, function rgbcube is used to view the color cube from any perspective as:
rgbcube(vx, vy, vz)
1. An indexed image has two components: a data matrix of integers, X, and
a colormap matrix, map.
2. An indexed image uses direct mapping of pixel intensity values to
3. An indexed image can be displayed as:
imshow (X, map)
or, image (X)
4. The function imapprox is used to approximate an indexed image by
fewer colors, having syntax:
[Y, newmap] = imapprox (X, map, n)
5. When number of rows in map is less than the number of distinct integer
values in X, same color is used to display multiple values of X.
6. Color map can be specified by using the statement:
map (k, 🙂 = [r(k) g(k) b(k)]
7. The function whitebg is used to change the background color of the
figure, having syntax:
or, whitebg (‘color_short_name’)
or, whitebg ([RGB_values])
Conversion between RGB, Indexed, and Gray-scale Intensity Images
NTSC Color Space
1. In this, image data consists of three components: luminance (Y), hue (I),
and saturation (Q).
2. The YIQ components are obtained from the RGB components by using
function rgb2ntsc, having syntax:
yiq_image = rgb2ntsc (rgb_image)
3. Similarly, the function ntsc2rgb is used to transform YIQ components to
RGB components, having syntax:
rgb_image = ntsc2rgb (yiq_image)
YCbCr Color Space
1. In this, image data consists of three components: luminance (Y),
difference between blue component and reference value (Cb), and
difference between red component and reference value (Cr).
2. The conversion from RGB to YCbCr is done by using function rgb2ycbcr,
ycbcr_image = rgb2ycbcr (rgb_image)
3. Similarly, the function ycbcr2rgb is used to transform YCbCr image to
RGB, having syntax:
rgb_image = ycbcr2rgb (ycbcr_image)
HSV Color Space
1. HSV is hue, saturation, value that refers to tint shade and tone.
2. It is formulated by looking at the gray axis of the RGB color cube which results in the hexagonally
spaced color palette.
3. Along the vertical (gray) axis, there is a change in the size of the hexagonal plane that yields
the volume depicted in figure.
4. Function rgb2hsv is used to convert image from RGB to HSV, having
hsv_image = rgb2hsv (rgb_image)
5. Similarly, the function hsv2rgb is used to transform HSV image back to
RGB, having syntax:
rgb_image = hsv2rgb (hsv_image)
CMY and CMYK Color Spaces
1. The secondary colors of light are Cyan, Magenta,and Yellow.
2. These colors are also considered as the primary colors of pigments.
3. Cyan pigment can be obtained by subtracting red light from reflected
4. Similarly, pure magenta doesn’t reflect green and pure yellow doesn’t
5. Black pigment can be obtained from the equal amounts of cyan,
magenta, and yellow.
6. Fourth color black can be added to produce true black, giving rise to
CMYK color space.
7. To convert from RGB to CMY and vice-versa, imcomplement function is
used, having syntax:
cmy_image = imcomplement (rgb_image)
and, rgb_image = imcomplement (cmy_image)
HSI Color Space
1. HSI (hue, saturation, intensity) color space decouples the
intensity component from the color-carrying information in a
2. Figure shows the HSI model based on color triangles and circles.
1. Linear interpolation can be implemented by using interp1q function,
z = interp1q (x, y, xi)
2. The function spline can be used to implement cubic spline interpolation,
z = spline (x, y, xi)
Color Image Smoothing
1. RGB color image smoothing with linear spatial filtering consists of the
a. Extract three component images:
fR = fc ( : , : , 1); fG = fc ( : , : , 2); fB = fc ( : , : , 3);
b. Filter each component individually:
fR_filtered = imfilter (fR, w)
c. Reconstruct the filtered RGB image:
fc_filtered = cat (3, fR_filtered, fG_filtered, fB_filtered)
Color Image Sharpening
1. Laplacian filter mask can be used to sharpen the blurred image, fb,
lapmask = [1 1 1; 1 -8 1; 1 1 1];
2. Enhanced image can be computed and displayed using command:
fen = imsubtract (fb, imfilter(fb, lapmask, ‘replicate’)