0% found this document useful (0 votes)
10 views

Module 4.2 - Colour Image Processing

Uploaded by

Harper
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Module 4.2 - Colour Image Processing

Uploaded by

Harper
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

Introduction

▪ Color is a powerful descriptor that often simplifies object


identification and extraction from a scene.
▪ Humans can discern thousands of color shades and
intensities, compared to about only two dozen shades of
gray.
▪ This factor is particularly important in manual image
analysis.
▪ Color image processing is divided into two major areas:
o Full-color processing - Images typically acquired with a full-
color sensor, such as a color TV camera or color scanner.
o Pseudocolor processing - Colours are assigned to a particular
monochrome intensity or range of intensities.
Colour
Fundamentals
▪ In 1666, Sir Isaac Newton - when a beam of sunlight
passes through a glass prism, the emerging beam of light
is not white but consists instead of a continuous
spectrum of colors ranging from violet at one end to red
at the other.
▪ Color spectrum may be divided into six broad regions:
violet, blue, green, yellow, orange, and red.
▪ No color in the spectrum ends abruptly, but rather each
color blends smoothly into the next.
▪ Colors perceived in an object are determined by the
nature of the light reflected from the object.
▪ Visible light is composed of a relatively narrow band of
frequencies in the electromagnetic spectrum.
▪ A body that reflects light that is balanced in all visible
wavelengths appears white to the observer.
▪ A body that favors reflectance in a limited range of the
visible spectrum exhibits some shades of color.
o Eg, Green objects reflect light with wavelengths primarily in
the 500 to 570 nm range while absorbing most of the energy at
other wavelengths.
▪ If the light is achromatic (void of color), its only
attribute is its intensity, or amount.
▪ Achromatic light is what viewers see on a black and
white television set.
▪ Gray level refers to a scalar measure of intensity that
ranges from black, to grays, and finally to white.
▪ Chromatic light spans the electromagnetic spectrum from
approximately 400 to 700 nm.
▪ Three basic quantities are used to describe the quality of
a chromatic light source:

o Radiance - Total amount of energy that flows from the light


source. Measured in watts (W).

o Luminance - Measure of the amount of energy an observer


perceives from a light source. Measured in lumens (lm),
➢ Eg - light emitted from a source operating in the far infrared region of
the spectrum could have significant energy (radiance), but an observer
would hardly perceive it - its luminance would be almost zero.

o Brightness – subjective descriptor that is practically


impossible to measure.
It is the achromatic notion of intensity and is one of the key
factors in describing color sensation.
▪ In human eye, cones are the sensors in the eye
responsible for color vision.
▪ Experimental evidence indicates that 6 to 7 million
cones in the human eye can be divided into three
principal sensing categories - red, green, and blue.
▪ Approximately 65% of all cones are sensitive to red
light.
▪ 33% are sensitive to green light
▪ About 2% are sensitive to blue (but the blue cones are
the most sensitive).
▪ Figure indicates average experimental curves detailing
the light absorption by the red, green, and blue cones in
the eye.

▪ Due to these absorption characteristics of the human eye,


colors are seen as variable combinations of primary
colors - red (R), green (G), and blue (B)
▪ For standardization, the CIE (Commission Internationale
de l'Eclairage - the International Commission on
Illumination) designated in 1931 the following specific
wavelength values to the three primary colors:
o Blue = 435.8 nm
o Green = 546.1 nm
o Red = 700 nm.
▪ The primary colors can be added to produce the
secondary colors of light:
o Magenta (red + blue)
o Cyan (green + blue)
o Yellow (red + green).
▪ Mixing the three primaries or a secondary with its
opposite primary color, in the right intensities produces
White light – Additive Colour Scheme
▪ Primary Colours of Pigments (Colorants) is different –
Subtractive Colour Scheme.
▪ Here, a primary color 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.
▪ The Secondary colors are Red, Green, and Blue.
▪ A proper combination of the three pigment primaries, or
a secondary with its opposite primary, produces Black.
▪ The characteristics used to distinguish one color from
another are:
o Brightness - the achromatic notion of intensity.
o Hue – associated with the dominant wavelength in a mixture of
light waves. Represents the dominant color as perceived by an
observer.
o Saturation – relative purity or the amount of white light mixed
with a hue. The pure spectrum colors are fully saturated.

▪ Degree of saturation is inversely proportional to the


amount of white light added.
▪ Hue and saturation taken together are called
chromaticity.
▪ The amounts of red, green, and blue needed to form any
particular color are called the tristimulus values and are
denoted, X, Y, and Z, respectively.
▪ A color is specified by its trichromatic coefficients,
defined as:
𝑋
𝑥=
𝑋+𝑌+𝑍
𝑌
𝑦=
𝑋+𝑌+𝑍
𝑍
𝑧=
𝑋+𝑌+𝑍

We notice that: 𝑥 + y + z = 1
▪ For any wavelength of light in the visible spectrum, the
tristimulus values needed to produce the color
corresponding to that wavelength can be obtained
directly from curves or tables that have been compiled
from extensive experimental results.
▪ Alternative approach – use the CIE chromaticity
diagram, which shows color composition as a function
of x (red) and y (green).
▪ For any value of x and y, the corresponding value of z
(blue) is obtained as
𝑧 = 1– (𝑥 + 𝑦)
▪ The positions of the various spectrum colors - from
violet at 380 nm to red at 780 nm - are indicated around
the boundary - pure colors.
▪ Any point not on the boundary but within the diagram
represents some mixture of spectrum colors.
▪ The point of equal energy - corresponds to equal
fractions of the three primary colors – the CIE standard
for white light.
▪ Any point located on the boundary of the chromaticity
chart is fully saturated.
▪ As a point leaves boundary and approaches the point of
equal energy, more white light is added to the color and it
▪ becomes less saturated.
▪ The saturation at the point of equal energy is zero.
▪ The chromaticity diagram is useful for color mixing.
▪ Straight-line segment joining any two points in the
diagram defines all the different color variations that can
be obtained by combining these two colors additively.
▪ Line drawn from the point of equal energy to any point
on the boundary of the chart will define all the shades of
that particular spectrum color.
▪ How do we extend this to 3 Colors?
o Simply draw connecting lines to each of the three color points.
The result is a Triangle, and any color on the boundary or inside
the triangle can be produced by various combinations of the 3
colours.
▪ A triangle with 3 fixed vertices cannot enclose the entire
colour region.
▪ Triangle in earlier image shows typical range of colours
produced by RGB monitors (Colour Gamut)
▪ Irregular region inside triangle represents the Colour
Gamut of modern high quality colour printing devices.
▪ Printer colour gamut boundary is irregular because
printing is a combination of additive and subtractive
colour mixing – very hard to control, compared to
displays.
Color Models
▪ Purpose of a color model (color space or color system) is
to facilitate the specification of colors in some standard,
generally accepted way.
▪ In essence, a color model is a specification of a
coordinate system and a subspace within that system
where each color is represented by a single point.
▪ Most color models are oriented either toward
o Hardware (such as for color monitors and printers)
o Applications where color manipulation is a goal (such as in the
creation of color graphics for animation).
▪ Most common colour models – RGB for colour
monitors, CMY or CMYK for printing, HSI model for
applications where processing is to be similar to human
eye.
RGB Colour Model
▪ Here, each color appears in its primary spectral
components of red, green, and blue.
▪ Model is based on a Cartesian coordinate system.
o RGB primary values are at three corners
o Secondary colors cyan, magenta, and yellow are at three other
corners
o Black is at the origin
o White is at the corner farthest from the origin.
o Gray scale (points of equal RGB values) extends from black to
white along the line joining these two points.
▪ For convenience, the assumption is that all color values
have been normalized (ie. In the range [0,1])
▪ Images represented in the RGB color model consist of
three component image, one for each primary color.
▪ In RGB monitor, 3 channels (layers) combine to form
composite colour image.
▪ The number of bits used to represent each pixel in RGB
space is called the pixel depth.
▪ In a RGB image where each of the red, green, and blue
images is an 8-bit image, each RGB color pixel [triplet
of values (R,G,B)] has depth of 24 bits (3 image planes
times the number of bits per plane).
▪ The term full-color image is used often to denote a 24-bit
RGB color image.
▪ The total number of colors in a 24-bit RGB image is
(28)3 = 16,777,216
▪ A convenient way to
view these colors is to
generate color planes
(faces or cross sections of
the cube).
▪ This is accomplished
simply by fixing one of
the three colors and
allowing the other two to
vary.
▪ Consider a cross-
sectional plane through
the center of the cube and
parallel to the GB-plane
in Fig. 6.8 is the plane
(127, G, B) for G, B = 0,
1,2, ... ,255.
▪ A color image can be acquired by using three filters sensitive
to red, green, and blue, respectively.
▪ When we view a color scene with a monochrome camera
equipped with one of these filters, the result is a monochrome
image whose intensity is proportional to the response of that
filter.
▪ Repeating this process with each filter produces three
monochrome images that are the RGB component images of
the color scene.
▪ While high-end display cards and monitors provide a
reasonable rendition of the colors in a 24-bit RGB image,
many systems are limited to 256 colors.
▪ In many applications we need only a few hundred (or
fewer) colours.
▪ So, we need a subset of colours that are likely to be
reproduced faithfully, reasonably independently of
viewer hardware capabilities.
▪ This subset of colors is called the set of safe RGB colors,
or the set of all-systems-safe colors.
▪ In Internet applications, they are called safe Web colors
or safe browser colors.
▪ Assuming 256 colors is the minimum number of colors
that can be reproduced faithfully by any display system,
we need a standard notation to refer to these colors.
▪ 40 of these 256 colours are processed differently by
various OSes. Remaining 216 colours are common to
most systems – de facto standard for safe colours.
▪ Each of the 216 safe colors is formed from three RGB
values as before, but each value can only be 0, 51, 102,
153, 204 or 255.
▪ Thus, RGB triplets give us a possible 63 = 216 colours.
▪ These numbers are usually represented in hex format.
▪ Since it takes three numbers to form an RGB color, each
safe color is formed from three of the two-digit hex
numbers in Table.
o Eg: Purest Red would be FF0000, Blue would be 0000FF,
Magenta would be FF00FF
o Black would be 000000, White would be FFFFFF
The CMY and CMYK Color Models
▪ Subtractive Colour Models, used for Pigmentation.
o Eg- when a surface coated with cyan pigment is illuminated with white light, no
red light is reflected from the surface. That is, cyan subtracts red light from
reflected white light.
▪ Most color printers and copiers require CMY data input or perform an
RGB to CMY conversion internally.
▪ When all colors are normalized, RGB to CMY Conversion is done as:
𝐶 1 𝑅
𝑀 = 1 − 𝐺
𝑌 1 𝐵
▪ This color model is used for generating hardcopy output, so the inverse
operation from CMY to RGB generally is of little practical interest.
▪ Equal amounts of the pigment primaries, cyan, magenta, and yellow
should produce black.
▪ In practice, combining these colors for printing produces a muddy-
looking black.
▪ So, in order to produce true black (predominant color in printing), a
fourth color, black, is added, giving rise to the CMYK color model.
The HSI Color Model
▪ RGB and CMY models are easy to implement and
convert, and are ideal for hardware implementations.
▪ They also match well with human visual system, which
is sensitive to R, G and B primaries.
▪ Unfortunately, these color models are not well suited for
describing colors in terms that are practical for human
interpretation.
o Eg: Human description does not express colours in terms of
composition of primary colours, but in terms of brightness,
saturation, hue, etc.
▪ This gives rise to the HSI (or HSV) model, where
colours are represented in terms of their Hue, Saturation
and Intensity – model decouples intensity information
from the chrominance information.
▪ RGB color image can be viewed as three monochrome
intensity images (representing red, green, and blue).
▪ Stand the RGB colour cube on the black (0,0,0) vertex,
with the white vertex (1, 1, 1) directly above it, as shown
in figure.

▪ We know intensity (gray scale) is along the vertical line


joining these two vertices.
▪ If we wanted to determine the intensity component of
any color point in Fig. 6.12, we would simply pass a
plane perpendicular to the intensity axis and containing
the color point.
▪ The intersection of the plane with the intensity axis
would give us a point with intensity value in the range
[0,1].
▪ Saturation (purity) of a color increases as a function of
distance from the intensity axis.
▪ Saturation of points on the intensity axis is zero, as
evidenced by the fact that all points along this axis are
gray.
▪ How can Hue be determined from given RGB point?
▪ Consider plane defined by three points (black, white, and
cyan).
▪ Black and white points are contained in the plane - the
intensity axis also is contained in the plane.
▪ We see that all points contained in the plane segment
defined by the intensity axis and the boundaries of the
cube have the same hue.
▪ If two points are black and white and the third is a color
point, all points on the triangle would have the same hue
because the black and white components cannot change
the hue.
▪ By rotating the shaded plane about the vertical intensity
axis, we would obtain different hues.
▪ In cube arrangement, HSI space is represented by a
vertical intensity axis and the locus of color points that
lie on planes perpendicular to this axis.
▪ As the planes move up and down the intensity axis, the
boundaries defined by the intersection of each plane
with the faces of the cube have either a triangular or
hexagonal shape.
▪ This can be visualized easily by looking at the cube
down its gray-scale axis, as shown.
▪ In this plane we see that
o Primary colors are separated by 120°.
o Secondary colors are 60° from the primaries, which means that
the angle between secondaries also is 120°.
▪ The hue of the point is determined by an angle from
some reference point.
▪ Usually, an angle of 0° from the red axis designates 0
hue, and the hue increases counterclockwise from there.
▪ The saturation (distance from the vertical axis) is the
length of the vector from the origin to the point.
▪ Origin is defined by the intersection of the color plane
with the vertical intensity axis.
▪ The important components of the HSI color space are:
o Vertical intensity axis
o Length of the vector to a color point,
o Angle this vector makes with the red axis
RGB to HSI Conversion
▪ Given an image in RGB color format, the H component
of each RGB pixel is:
𝜃 𝑖𝑓 𝐵 ≤ 𝐺
𝐻=
360° − 𝜃 𝑖𝑓 𝐵 > 𝐺

▪ Where:
1
𝑅 − 𝐺 + (𝑅 − 𝐵)
𝜃 = 𝑐𝑜𝑠 −1 2
1ൗ
(𝑅 − 𝐺)2 +(𝑅 − 𝐵)(𝐺 − 𝐵) 2
▪ Saturation Component is given by:
3
𝑆 =1− [min 𝑅, 𝐺, 𝐵 ]
𝑅+𝐺+𝐵
▪ Intensity Component is given by:
1
𝐼 = (𝑅 + 𝐺 + 𝐵)
3
▪ Assumptions:
o RGB values have been normalized to the range [0,1]
o Angle 𝜃 is measured with respect to red axis of the HSI space
▪ Hue normalized to the range [0,1] by dividing by 360°
▪ Other two HSI components already are in this range if
the given RGB values are in the interval [0,1].
HSI to RGB Conversion
▪ Given values of HSI in the interval [0, 1], Conversions
equations depend on the values of H.
▪ 3 sectors of interest, corresponding to the 120° intervals
in the separation of primaries.
▪ We begin by multiplying H by 360°, which returns the
hue to its original range of [0°, 360°].
➢RG sector (𝟎° ≤ 𝑯 < 𝟏𝟐𝟎°):
▪ When H is in this sector, the RGB components are given
by:

𝐵 =𝐼 1−𝑆

𝑆 cos 𝐻
𝑅 =𝐼 1+
cos(60° − 𝐻)

𝐺 = 3𝐼 − (𝑅 + 𝐵)
➢GB sector (𝟏𝟐𝟎° ≤ 𝑯 < 𝟐𝟒𝟎°):
▪ When H is in this sector, we first subtract 120° from it.
𝐻 = 𝐻 − 120°
▪ The RGB components are given by:

𝑅 =𝐼 1−𝑆

𝑆 cos 𝐻
𝐺 =𝐼 1+
cos(60° − 𝐻)

𝐵 = 3𝐼 − (𝑅 + 𝐺)
➢BR sector (𝟐𝟒𝟎° ≤ 𝑯 < 𝟑𝟔𝟎°):
▪ When H is in this sector, we first subtract 240° from it.
𝐻 = 𝐻 − 240°
▪ The RGB components are given by:

𝐺 =𝐼 1−𝑆

𝑆 cos 𝐻
𝐵 =𝐼 1+
cos(60° − 𝐻)

𝑅 = 3𝐼 − (𝐺 + 𝐵)
Problem
▪ Convert RGB = (0.683, 0.1608, 0.1922) to HSI model
values

▪ Solution: HSI Values = (0.9922, 0.5343, 0.3453)


▪ RGB = (0.6854,0.1608,0.1897)
Manipulating HSI component images
▪ Consider an image
6.16(a) composed of
the primary and
secondary RGB
colors.
▪ Figures 6.16(b)
through (d) show
the H, S, and I
components of this
image, generated
from equations.
▪ To change the individual color of any region in the RGB
image, we change the values of the corresponding region
in the hue image.
▪ Then we convert the new H image along with the
unchanged S and I images, back to RGB.
▪ To change the saturation (purity) of the color in any
region, we follow the same procedure, except we make
the changes in the saturation image in HSI space.
▪ To change the average intensity of the region, we follow
the same procedure, except we make the changes in the
intensity image in HSI space.
▪ Fig. 6.17(a) was obtained
by changing to 0 the
pixels corresponding to
the Blue and Green
regions in Hue Image.
▪ In Fig. 6.17(b) we reduced
by half the saturation of
the Cyan region in
Saturation Component.
▪ In Fig. 6.17(c) we reduced
by half the intensity of the
central white region in the
Intensity Image
▪ As expected, we see:
o All primaries are RED.
o Cyan is less saturated.
o Central region is grey.
Pseudocolor Image
Processing
Introduction
▪ Pseudocolor (also called false color) image processing
consists of assigning colors to gray level values, based
on specific criteria.
▪ Principal use is for human visualization and
interpretation of gray-scale events in an image or
sequence of images.
▪ One of the principal motivations for using color is the
fact that humans can discern thousands of color shades
and intensities, compared to only two dozen or so shades
of gray
Intensity Slicing
▪ Intensity (or density) slicing and color coding is one of the
simplest examples of pseudocolor image processing.
▪ If an image is interpreted as a 3-D function, the method can be
viewed as one of placing planes parallel to the coordinate plane of
the image
▪ Each plane then "slices" the function in the area of intersection.
▪ Here, we see use of plane
𝑓(𝑥, 𝑦) = 𝐼𝑖 for slicing image
into 2 levels.
▪ If a different color is assigned to each side of the plane,
any pixel whose intensity level is above the plane will be
coded with one color, and any pixel below the plane will
be coded with the other.
▪ Levels that lie on the plane itself may be arbitrarily
assigned one of the two colors.
▪ The result is two-color image whose relative appearance
can be controlled by moving the slicing plane up and
down the intensity axis.
▪ In general, the technique may be summarized as follows:
o Let [0, L – 1] represent the gray scale.
o Let level l0 represent black [𝑓(𝑥, 𝑦) = 0], and level lL-1
represent white [𝑓(𝑥, 𝑦) = 𝐿 − 1].
o Suppose that P planes perpendicular to the intensity axis are
defined at levels l1, l2, …, lp.
o Assuming that 0 < 𝑃 < 𝐿 − 1, the P planes partition the gray
scale into P + 1 intervals, V1, V2, …VP+
o Intensity to color assignments are made according to the
relation:

𝒇 𝒙, 𝒚 = 𝒄𝒌 if 𝒇 𝒙, 𝒚 ∈ 𝑽𝒌
where 𝑐𝑘 is the color associated with the 𝑘-th intensity interval 𝑉𝑘
defined by the partitioning planes at l=k-1 and l=k.
▪ Idea of planes is useful primarily for a geometric
interpretation of the intensity-slicing technique.
▪ Here is an alternative representation that defines the
same mapping as shown earlier:

▪ When more levels are used, the mapping function takes


on a staircase form.
▪ Intensity slicing assumes a much
more meaningful and useful role
when subdivision of the gray
scale is based on physical
characteristics of the image.
o Eg: Location of cracks and
porosities in an X-ray image of a
weld.
Intensity to Color Transformations
▪ More general and capable of achieving wider range of
pseudocolor enhancement results than simple slicing
technique.
▪ Perform three independent transformations on the
intensity of any input pixel.
▪ The three results are then fed separately into the red,
green, and blue channels of a color television monitor.
▪ This method produces a composite image whose color
content is modulated by the nature of transformation
functions.
▪ Note: These are transformations on intensity values of an
image and are not functions of position.
▪ Unlike earlier cases, where piecewise linear functions
were used for intensity slicing, these methods can be
based on smooth, nonlinear functions, which gives the
technique considerable flexibility.
▪ These sinusoidal functions contain regions of relatively
constant value around the peaks as well as regions that
change rapidly near the valleys.
▪ Changing the phase and frequency of each sinusoid can
emphasize (in color) ranges in the gray scale.
▪ For instance, if all three transformations have the same phase
and frequency, the output image will be monochrome.
▪ A small change in the phase between three transformations
produces little change in pixels whose intensities correspond
to peaks in the sinusoids, especially if the sinusoids have
broad profiles (low frequencies).
▪ Pixels with intensity values in the steep section of the
sinusoids are assigned a much stronger color content as a
result of significant differences between the amplitudes of the
three sinusoids caused by the phase displacement between
them .
▪ Often, it is of interest to combine several monochrome
images into a single color composite image.
▪ A frequent use of this approach is in multispectral image
processing, where different sensors produce individual
monochrome images, each in a different spectral band.
▪ The types of additional processes shown can be
techniques such as color balancing, combining images,
and selecting the three images for display based on
knowledge about response characteristics of the sensors
used to generate the images.
• Fig 1: full-color image obtained by combining first three images into RGB image.
• Full-color images of dense areas are difficult to interpret, but one notable feature of this
image is the difference in color in various parts of the Potomac River.
• Fig 2: This image was formed by replacing the red component of Fig. 1 with the near-
infrared image. This band is strongly responsive to the biomass components of a scene.
• Fig 2 shows quite clearly the difference between biomass (in red) and the human-made
features in the scene, composed primarily of concrete and asphalt, which appear bluish
in the image.
In the Pseudocolor image, bright
red depicts material newly
ejected from an active volcano
on Io, and the surrounding
yellow materials are older sulfur
deposits.

You might also like