0% found this document useful (0 votes)
34 views69 pages

MSC DIP 7th Lecture

Chapter 6 discusses color image processing, highlighting the significance of color in automated image analysis and the human eye's ability to perceive a wide range of colors. It covers concepts such as pseudo-color and full-color processing, color models (RGB, CMYK, HSI), and the characteristics of color perception including hue, saturation, and brightness. Additionally, it explains the technical aspects of color mixing and the application of color models in hardware and image processing algorithms.

Uploaded by

rababrongon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views69 pages

MSC DIP 7th Lecture

Chapter 6 discusses color image processing, highlighting the significance of color in automated image analysis and the human eye's ability to perceive a wide range of colors. It covers concepts such as pseudo-color and full-color processing, color models (RGB, CMYK, HSI), and the characteristics of color perception including hue, saturation, and brightness. Additionally, it explains the technical aspects of color mixing and the application of color models in hardware and image processing algorithms.

Uploaded by

rababrongon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 69

Chapter 6

Color Image Processing

1
Remember?

2
Color Image Processing

Background

• In automated image analysis, color is a powerful


descriptor, which simplifies object
identification and extraction.

• The human eye can distinguish between thousands


of color shades and intensities but only about
20-30 shades of gray. Hence, use of color in
human image processing would be very
effective.
Color Image Processing
Color Image Processing

In color theory,

 Tint is a mixture of a color with white, which


reduces darkness,

 Shade is a mixture with black, which increases


darkness.

 Intensity refers to the degree of purity of a


color. A highly intense color is bright and a
low-intensity color is more neutral or muted.
Color Image Processing

Color image processing consists of two parts:

 Pseudo-color processing and

 Full color processing.


Color Image Processing

In pseudo-color processing, (false) colors are assigned to a


monochrome image.

 Monochrome images consist of only black and white


colors. The color code will be RGB(0,0,0) for black
and RGB(255,255,255) for white.

 A monochromic image is composed of one color


(or values of one color), more likely grayscale image

 A false-color image is an image that depicts an object


in colors that differ from those a photograph (a true-
color image) would show.
Color Image Processing
Color Image Processing
Color Image Processing

 In full-color processing, images are acquired with full


color sensors/cameras.

 This has become common in the last decade or so, due


to the easy and cheap availability of color sensors and
hardware.
Color Image Processing
Color Fundamentals

When a beam of sunlight is passed through a glass prism,


the emerging beam of light is not white but consists of a
continuous spectrum of colors (Sir Isaac Newton, 1666).

color spectrum - the distribution of colors produced when


light is dispersed by a prism.

The color spectrum can be divided into six broad regions:


violet, blue, green, yellow, orange, and red.
Color spectrum/prism
Color spectrum/prism
Color spectrum/prism
Color Image Processing
 The different colors in the spectrum do not end
abruptly (suddenly) but each color blends smoothly
into the next.

 Color perceived by the human eye depends on the


nature of light reflected by an object.

 Light that is relatively balanced in all visible


wavelengths is perceived as white.

 Objects that appear green reflect more light in the 500-


570 nm range (absorbing other wavelengths of light).

 Characterization of light is important for the


understanding of color.
Color spectrum/prism
Color Image Processing
Color Image Processing
Color Image Processing

If the light is achromatic (devoid of color), its only attribute


is its intensity (amount of light). This is what we have
been dealing with so far.

The term gray level refers to the scalar measure of the


intensity of light --- black to grays to white. •

Chromatic light spans the electromagnetic (EM) spectrum


from approximately 400 nm to 700 nm.

Three basic quantities are used to describe the quality of a


chromatic source of light:
Color Image Processing

Radiance is the total amount of light that flows from a


light source (measured in Watts).

Luminance gives a measure of the amount of energy an


observer perceives from a light source (measured in
lumens).

Brightness is a subjective descriptor that is impossible to


measure.
Color Image Processing

 Cones in the retina are responsible for color perception


in the human eye.

 Six to seven million cones in the human eye can be


divided into three categories: red light sensitive cones
(65%), green light sensitive cones (33%) and blue
light sensitive cones (2%).
Color Image Processing

Absorption of light by the three types of cones is illustrated


in the figure below:
Color Image Processing

Due to the absorption characteristics of the human eye, all


colors perceived by the human can be considered as a
variable combination of the so called three primary
colors:

• Red (R) (700 nm)

• Green (G) (546.1 nm)

• Blue (B) (435.8 nm)


Color Image Processing

 The wavelengths for the three primary colors are


established by standardization by the CIE
(International Commission on Illumination). They
correspond to the experimental curve only
approximately.

 Note that the specific color wavelengths are used


mainly for standardization. It is not possible to
produce all colors purely by combining these specific
wavelengths.
Color Image Processing

Pigment: a
substance that
imparts black
or white or a
color to other
materials;
Color Image Processing

• Primary colors

a) Red
b) Green
c) Blue

When primary colors are added produce secondary


colors:

• Magenta (red + blue)


• Cyan (green + blue)
• Yellow (red + green)
Color Image Processing
Mixing the three primaries, or a secondary with its
opposite primary, in the right intensities produces white
light.

A primary color of pigment is defined as one that


subtracts or absorbs a primary color of light and reflects or
transmits the other two.

Therefore, the primary colors of pigments are magenta,


cyan, and yellow, and the secondary pigment colors are
red, green, and blue.

Mixing the three pigment primaries, or a secondary with


its opposite primary, in the right intensities produces black.
Color Image Processing

Color television or a computer monitor is an example of


additive nature of the color of light. The inside of the
screen is coated with dots of phosphor, each being capable
of producing one of the three primary colors. A
combination of light of the three primary colors produces
all the different colors we see.

Printing is an example of the subtractive nature of color


pigments. For example, a pigment of red color actually
absorbs light of all wavelengths, except that corresponding
to red color.
Color Image Processing

• The characteristics used to distinguish one color from


another are:

• Brightness (or value) embodies the chromatic notion of


intensity.

• Hue is an attribute associated with the dominant


wavelength in a mixture of light waves. It represents
the dominant color as perceived by an observer (ex.
orange, red, violet).
Color Image Processing

• Saturation refers to the relative purity or the amount of


white light mixed with a hue. Pure colors are fully
saturated. Colors such as pink (red + white) and
lavendar (violet + white) are less saturated.

The intensity is determined by the actual amount of light,


with more light corresponding to more intense colours.
Color Image Processing

Hue and saturation together are called chromaticity. A


color can be described in terms of its brightness and
chromaticity.
Color Image Processing

Tristimulus values

The amounts of red, green, and blue needed to form any


particular color are called the tristimulus values and are
denoted by X, Y, and Z, respectively.
Color Image Processing

For any value of x (red) and y (green), the corresponding


value of z (blue) is given by z = 1− (x + y).
Color Image Processing

Color Models

The purpose of a color model (or color space or color


system) is to facilitate the specification of color in some
standard fashion.

A color model is a specification of a 3-D coordinate


system and a subspace within that system where each color
is represented by a single point.

Most color models in use today are either based on


hardware (color camera, printer) or on applications
involving color manipulation (computer graphics,
animation).
Color Image Processing

In image processing, the hardware based color models


mainly used are: RGB, CMYK, and HSI.

• The RGB (red, green, blue) color system is used mainly


in color monitors and video cameras.

• The CMYK (cyan, magenta, yellow, black) color system


is used in printing devices.

• The HSI (hue, saturation, intensity) is based on the way


humans describe and interpret color. It also helps in
separating the color and grayscale information in an image.
Color Image Processing

RGB Color model

• Each color appears in its primary spectral components of


red (R), green (G), and blue (B).

• Mainly used for hardware such as color monitors and


color video camera.
Color Image Processing
Color Image Processing

It is based on a Cartesian coordinate system. All color


values are normalized so that the values of R, G, and B
are in the range [0,1]. Thus, the color subspace of
interest is the unit cube.

The primary colors red, green, and blue correspond to


three corners of the cube, whereas the secondary colors
cyan, magenta, and yellow correspond to three other
corners. Origin (0,0,0) represents black and (1,1,1)
represents white. • Grayscale (monochrome) is
represented by the diagonal joining black to white.
Color Image Processing

The number of bits used to represent each pixel in


RGB space is called pixel depth.

 For example, if eight bits are used to represent each of


the primary components, each RGB color pixel would
have a depth of 24 bits. This is usually referred to as a
full color image.

 There are 16,777,216 unique colors possible in this


system.
Color Image Processing
Color Image Processing
Color Image Processing

I = imread('D:/Matlab_Folder/car.jpg');
figure, imshow(I);
figure, imshow(I);
R = I(:,:,1);
imhist(R);
figure, imshow(R);
figure, imshow(R);
G = I(:,:,2);
imhist(G);
figure, imshow(G);
figure, imshow(G);
B = I(:,:,3);
imhist(B);
figure, imshow(B);
Color Image Processing
I = imread('D:/Matlab_Folder/car.jpg');
figure, imshow(I);
figure, imshow(I);
R = I(:,:,1);
imhist(R);
R = histeq(R);
figure, imshow(R);
figure, imshow(R);
G = I(:,:,2);
imhist(G);
G = histeq(G);
figure, imshow(G);
figure, imshow(G);
B = I(:,:,3);
imhist(B);
B = histeq(B);
figure, imshow(B);
J = cat(3,R,G,B);
figure, imshow(J);
Color Image Processing
Color Image Processing
Color Image Processing

Why does blue paint plus yellow paint give green?

As all schoolchildren know, the way to make green paint is


to mix blue paint with yellow. But how does this work? If
blue paint absorbs all but blue light, and yellow absorbs blue
only, when combined no light should be reflected and black
paint result.

However, what actually happens is that imperfections in the


paint are exploited. In practice, blue paint reflects not only
blue, but also some green. Since the yellow paint also
reflects green (since yellow = green + red), some green is
reflected by both pigments, and all other colors are
absorbed, resulting in green paint.
Color Image Processing
RGB and CMY models

Ideally suited for hardware implementation.

RGB and CMY not suitable for describing colors for


human interpretation.
Color Image Processing

HSI color model

Hue,

Saturation,

Intensity

Human description of images/colors

∗ In terms of hue, saturation, and brightness


Color Image Processing

HSI model is an ideal tool for developing image processing


algorithms

Natural and intuitive to humans


Color Image Processing

The HSI model, showing the HSI solid on the left, and the
HSI triangle on the right, formed by taking a horizontal slice
through the HSI solid at a particular intensity. Hue is
measured from red, and saturation is given by distance from
the axis. Colours on the surface of the solid are fully
saturated, i.e. pure colours, and the greyscale spectrum is on
the axis of the solid. For these colours, hue is undefined.
Color Image Processing
Color Image Processing

close all;
I = imread('D:/Matlab_Folder/car.jpg');
figure, imshow(I);

%Represent the RGB image in [0 1] range


I=double(I)/255;

R=I(:,:,1);
G=I(:,:,2);
B=I(:,:,3);
Color Image Processing

%Hue
N=1/2*((R-G)+(R-B));
D=((R-G).^2+((R-B).*(G-B))).^0.5;

%To avoid divide by zero exception add a small number


H=acosd(N./(D+0.000001));

%If B>G then H= 360-Theta


H(B>G)=360-H(B>G);

%Normalize to the range [0 1]


H=H/360;
Color Image Processing

%Saturation
S=1- (3./(sum(I,3)+0.000001)).*min(I,[],3);

%Intensity
I=sum(I,3)./3;

%HSI
HSI = cat(3,H,S,I);

figure,imshow(HSI);
title('HSI Image');
Color Image Processing
Color Image Processing

%Obtain the Hue, Saturation and Intensity components


H1=HSI(:,:,1);
S1=HSI(:,:,2);
I1=HSI(:,:,3);

%Multiply Hue by 360 to represent in the range [0 360]


H1=H1*360;

%Pre-allocate the R,G and B components


R1=zeros(size(H1));
G1=zeros(size(H1));
B1=zeros(size(H1));
RGB1=zeros([size(H1),3]);
Color Image Processing

%RG Sector(0<=H<120)
%When H is in the above sector, the RGB components equations are

B1(H1<120)=I1(H1<120).*(1-S1(H1<120));
R1(H1<120)=I1(H1<120).*(1+((S1(H1<120).*cosd(H1(H1<120)))./cosd(60-
H1(H1<120))));
G1(H1<120)=3.*I1(H1<120)-(R1(H1<120)+B1(H1<120));

%GB Sector(120<=H<240)
%When H is in the above sector, the RGB components equations are
Color Image Processing

%Subtract 120 from Hue


H2=H1-120;

R1(H1>=120&H1<240)=I1(H1>=120&H1<240).*(1-
S1(H1>=120&H1<240));

G1(H1>=120&H1<240)=I1(H1>=120&H1<240).*(1+((S1(H1>=120&H
1<240).*cosd(H2(H1>=120&H1<240)))./cosd(60-
H2(H1>=120&H1<240))));
B1(H1>=120&H1<240)=3.*I1(H1>=120&H1<240)-
(R1(H1>=120&H1<240)+G1(H1>=120&H1<240));

%BR Sector(240<=H<=360)
%When H is in the above sector, the RGB components equations are
Color Image Processing
%Subtract 240 from Hue
H2=H1-240;

G1(H1>=240&H1<=360)=I1(H1>=240&H1<=360).*(1-
S1(H1>=240&H1<=360));

B1(H1>=240&H1<=360)=I1(H1>=240&H1<=360).*(1+((S1(H1>=240&H1<=
360).*cosd(H2(H1>=240&H1<=360)))./cosd(60-H2(H1>=240&H1<=360))));
R1(H1>=240&H1<=360)=3.*I1(H1>=240&H1<=360)-
(G1(H1>=240&H1<=360)+B1(H1>=240&H1<=360));

%Form RGB Image


RGB1(:,:,1)=R1;
RGB1(:,:,2)=G1;
RGB1(:,:,3)=B1;

%Represent the image in the range [0 255]


RGB1=im2uint8(RGB1);
figure,imshow(RGB1);title('RGB Image');
Color Image Processing
Color Image Processing

HSV color space

Projects the RGB color cube onto a non-linear

1. chroma angle (H),

2. a radial saturation percentage (S), and

3. a luminance inspired value (V)

• Similar to HSI color space


Color Image Processing
close all;
I = imread('D:/Matlab_Folder/car.jpg');
figure, imshow(I);
figure, imshow(I);
R = I(:,:,1);
imhist(R);
R = histeq(R);
figure, imshow(R);
figure, imshow(R);
G = I(:,:,2);
imhist(G);
G = histeq(G);
figure, imshow(G);
figure, imshow(G);
B = I(:,:,3);
imhist(B);
B = histeq(B);
figure, imshow(B);
J = cat(3,R,G,B);
figure, imshow(J);
Color Image Processing
Color Image Processing

Histogram Equalization on RGB Color model


Color Image Processing

Histogram Equalization on HSI Color model


Color Image Processing

Histogram Equalization on HSV Color model


Color Image Processing

Histogram Equalization on HSV Color model


Thanks !!!

You might also like