Lecture 11-Color Image Processing
Lecture 11-Color Image Processing
IMAGE PROCESSING
INSTRUCTOR: DR. NGUYEN NGOC TRUONG MINH
SCHOOL OF ELECTRICAL ENGINEERING, INTERNATIONAL UNIVERSITY (VNU-HCMC)
LECTURE XI –
COLOR IMAGE PROCESSING
INSTRUCTOR: DR. NGUYEN NGOC TRUONG MINH
SCHOOL OF ELECTRICAL ENGINEERING, INTERNATIONAL UNIVERSITY (VNU-HCMC)
LECTURE CONTENT
• What are the most important concepts and terms related to color
perception?
• What are the main color models used to represent and quantify color?
• How are color images represented in MATLAB?
• What is pseudo-color image processing and how does it differ from full-color
image processing?
• How can monochrome image processing techniques be extended to color
images?
• Chapter Summary – What we have learned?
• Problems
Lecture 11 – Color Image Processing 4
• The perception of several shades of gray between pure white and pure
black is usually referred to as achromatic. Objects that have more selective
properties are considered chromatic, and the range of the spectrum that
they reflect is often associated with a color name.
Lecture 11 – Color Image Processing 7
• For example, an object that absorbs most of the energy within the 565–
590 nm wavelength range is considered yellow.
• A chromatic light source can be described by three basic quantities:
➢ Intensity (or Radiance): the total amount of energy that flows from the light
source, measured in watts (W).
➢ Luminance: a measure of the amount of information an observer perceives
from a light source, measured in lumen (lm). It corresponds to the radiant
power of a light source weighted by a spectral sensitivity function
(characteristic of the HVS).
➢ Brightness: the subjective perception of (achromatic) luminous intensity.
Lecture 11 – Color Image Processing 8
• The human retina (the surface at the back of the eye where images are
projected) is coated with photosensitive receptors of two different types:
cones and rods.
• Rods cannot encode color but respond to lower luminance levels and
enable vision under darker conditions.
• Cones are primarily responsible for color perception and operate only
under bright conditions. There are three types of cone cells (L cones, M
cones, and S cones, corresponding to long (≈ 610 nm), medium (≈ 560
nm), and short (≈ 430 nm) wavelengths, respectively).
Lecture 11 – Color Image Processing 9
• The existence of three specialized types of cones in the human eye was
hypothesized more than a century before it could be confirmed
experimentally by Thomas Young and his trichromatic theory of vision in
1802.
• The use of the expression primary colors to refer to red, green, and blue may
lead to a common misinterpretation: that all visible colors can be obtained
by mixing different amounts of each primary color, which is not true.
• A related phenomenon of color perception, the existence of color
metamers, may have contributed to this confusion. Color metamers are
combinations of primary colors (e.g., red and green) perceived by the HVS
as another color (in this case, yellow) that could have been produced by a
spectral color of fixed wavelength (of ≈ 580 nm).
Lecture 11 – Color Image Processing 14
and
Lecture 11 – Color Image Processing 18
• The inner triangle in Figure 11.6a represents a color gamut, that is, a range
of colors that can be produced by a physical device, in this case a CRT
monitor. Different color image display and printing devices and
technologies exhibit gamuts of different shape and size, as shown in Figure
11.6.
• As a rule of thumb, the larger the gamut, the better the device’s color
reproduction capabilities.
Lecture 11 – Color Image Processing 21
In M AT L A B
• The IPT has an extensive support for conversion among CIE color spaces.
Converting from one color space to another is usually accomplished by
using function makecform (to create a color transformation structure that
defines the desired color space conversion) followed by applycform, which
takes the color transformation structure as a parameter.
Lecture 11 – Color Image Processing 26
• The YCbCr color model is the most popular color representation for digital
video. In this format, one component represents luminance (Y ), while the
other two are color-difference signals: Cb (the difference between the
blue component and a reference value) and Cr (the difference between
the red component and a reference value).
• Conversion from RGB to YCbCr is possible using the transformation
Lecture 11 – Color Image Processing 44
EXAMPLE 11.1
• The following MATLAB sequence can be used to open, verify the size (in
this case, 384 x 512 x 3) and data class (in this case, uint8), and display an
RGB color image (Figure 11.14).
I = imread(’peppers.png’);
size(I)
class(I)
subplot(2,2,1), imshow(I), title(’Color image (RGB)’);
subplot(2,2,2), imshow(I(:,:,1)), title(’Red component’);
subplot(2,2,3), imshow(I(:,:,2)), title(’Green component’);
subplot(2,2,4), imshow(I(:,:,3)), title(’Blue component’);
Lecture 11 – Color Image Processing 47
EXAMPLE 11.1
Lecture 11 – Color Image Processing 48
EXAMPLE 11.2
EXAMPLE 11.2
Lecture 11 – Color Image Processing 53
• The technique of intensity (or density) slicing is the simplest and best-
known pseudocoloring technique.
• If we look at a monochrome image as if it were a 3D plot of gray levels
versus spatial coordinates, where the most prominent peaks correspond
to the brightest pixels, the technique corresponds to placing several planes
parallel to the coordinate plane of the image (also known as the xy plane).
Lecture 11 – Color Image Processing 57
EXAMPLE 11.3
In M AT L A B
• Intensity slicing can be accomplished using the grayslice function.
• Figure 11.19 shows an example of pseudocoloring with intensity slicing
using 16 levels, the same input image (a), and three different color maps
summer (b), hsv (c), and jet (d).
Lecture 11 – Color Image Processing 61
EXAMPLE 11.3
Lecture 11 – Color Image Processing 62
G o al
• The goal of this tutorial is to learn how to display grayscale images using
pseudocolors in MATLAB.
O bjectives
P rocedure
We will start by exploring the grayslice function on a gradient image.
1. Create and display a gradient image.
I = repmat(uint8([0:255]),256,1);
figure, subplot(1,2,1), subimage(I), title(’Original Image’);
2. Slice the image and display the results.
I2 = grayslice(I,16);
subplot(1,2,2), subimage(I2,colormap(winter(16))), ...
title(’Pseudo-colored with "winter" colormap’)
Q uestio n 1. Why did w e use the subimage functio n to display the
images (instead o f the familiar imshow )?
Lecture 11 – Color Image Processing 64
G o al
• The goal of this tutorial is to learn how to convert between color spaces
and perform filtering on color images in MATLAB.
O bjectives
• Learn how to convert from RGB to HSV color space using the rgb2hsv function.
• Learn how to convert from HSV to RGB color space using the hsv2rgb function.
• Explore smoothing and sharpening in the RGB and HSV color spaces.
Lecture 11 – Color Image Processing 68
PROBLEMS
P ro blem 1. Use the MATLAB function patch to display the RGB cube in
Figure 11.9.
P ro blem 2. Write MATLAB code to add two RGB color images. Test it with
two test images (of the same size) of your choice. Are the results what you
had expected?
P ro blem 3. What is wrong with the following MATLAB code to add an
indexed color image to a constant for brightening purposes? Fix the code to
achieve the desired goal.
[X, map] = imread(’canoe.tif ’);
X = X + 20;
Lecture 11 – Color Image Processing 81
PROBLEMS
PROBLEMS
P ro blem 5. Use the edge function in MATLAB and write a script to compute
and display the edges of a color image for the following cases:
(a) RGB image, combining the edges from each color channel by adding them up.
(b) RGB image, combining the edges from each color channel with a logical OR
operation.
(c) YIQ image, combining the edges from each color channel by adding them up.
(d) YIQ image, combining the edges from each color channel with a logical OR
operation.
Lecture 11 – Color Image Processing 83
END OF LECTURE XI