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

Chapter 2 Digital Image Fundamentals

The document is a preview of the third edition of 'Digital Image Processing' by Rafael C. Gonzalez and Richard E. Woods, which introduces fundamental concepts in digital image processing. It covers the mechanics of the human visual system, imaging sensors, image sampling, intensity quantization, and basic pixel relationships. Additionally, it emphasizes the importance of understanding human visual perception in the context of digital imaging techniques.

Uploaded by

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

Chapter 2 Digital Image Fundamentals

The document is a preview of the third edition of 'Digital Image Processing' by Rafael C. Gonzalez and Richard E. Woods, which introduces fundamental concepts in digital image processing. It covers the mechanics of the human visual system, imaging sensors, image sampling, intensity quantization, and basic pixel relationships. Additionally, it emphasizes the importance of understanding human visual perception in the context of digital imaging techniques.

Uploaded by

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

Digital Image

Processing
Third Edition

Rafael C. Gonzalez
University of Tennessee

Richard E. Woods
MedData Interactive

Upper Saddle River, NJ 07458


Library of Congress Cataloging-in-Publication Data on File

Vice President and Editorial Director, ECS: Marcia J. Horton


Executive Editor: Michael McDonald
Associate Editor: Alice Dworkin
Editorial Assistant: William Opaluch
Managing Editor: Scott Disanno
Production Editor: Rose Kernan
Director of Creative Services: Paul Belfanti
Creative Director: Juan Lopez
Art Director: Heather Scott
Art Editors: Gregory Dulles and Thomas Benfatti
Manufacturing Manager: Alexis Heydt-Long
Manufacturing Buyer: Lisa McDowell
Senior Marketing Manager: Tim Galligan

© 2008 by Pearson Education, Inc.


Pearson Prentice Hall
Pearson Education, Inc.
Upper Saddle River, New Jersey 07458

All rights reserved. No part of this book may be reproduced, in any form, or by any means, without
permission in writing from the publisher.
Pearson Prentice Hall® is a trademark of Pearson Education, Inc.
The authors and publisher of this book have used their best efforts in preparing this book. These efforts include
the development, research, and testing of the theories and programs to determine their effectiveness. The authors
and publisher make no warranty of any kind, expressed or implied, with regard to these programs or the
documentation contained in this book. The authors and publisher shall not be liable in any event for incidental or
consequential damages with, or arising out of, the furnishing, performance, or use of these programs.
Printed in the United States of America.
10 9 8 7 6 5 4 3 2 1
ISBN 0-13-168728-x
978-0-13-168728-8
Pearson Education Ltd., London
Pearson Education Australia Pty. Ltd., Sydney
Pearson Education Singapore, Pte., Ltd.
Pearson Education North Asia Ltd., Hong Kong
Pearson Education Canada, Inc., Toronto
Pearson Educación de Mexico, S.A. de C.V.
Pearson Education—Japan, Tokyo
Pearson Education Malaysia, Pte. Ltd.
Pearson Education, Inc., Upper Saddle River, New Jersey
2 Digital Image
Fundamentals

Those who wish to succeed must ask the right


preliminary questions.
Aristotle

Preview
The purpose of this chapter is to introduce you to a number of basic concepts
in digital image processing that are used throughout the book. Section 2.1
summarizes the mechanics of the human visual system, including image for-
mation in the eye and its capabilities for brightness adaptation and discrimi-
nation. Section 2.2 discusses light, other components of the electromagnetic
spectrum, and their imaging characteristics. Section 2.3 discusses imaging
sensors and how they are used to generate digital images. Section 2.4 intro-
duces the concepts of uniform image sampling and intensity quantization.
Additional topics discussed in that section include digital image representa-
tion, the effects of varying the number of samples and intensity levels in an
image, the concepts of spatial and intensity resolution, and the principles of
image interpolation. Section 2.5 deals with a variety of basic relationships
between pixels. Finally, Section 2.6 is an introduction to the principal math-
ematical tools we use throughout the book. A second objective of that sec-
tion is to help you begin developing a “feel” for how these tools are used in
a variety of basic image processing tasks. The scope of these tools and their
application are expanded as needed in the remainder of the book.

35
36 Chapter 2 ■ Digital Image Fundamentals

2.1 Elements of Visual Perception


Although the field of digital image processing is built on a foundation of math-
ematical and probabilistic formulations, human intuition and analysis play a
central role in the choice of one technique versus another, and this choice
often is made based on subjective, visual judgments. Hence, developing a basic
understanding of human visual perception as a first step in our journey
through this book is appropriate. Given the complexity and breadth of this
topic, we can only aspire to cover the most rudimentary aspects of human vi-
sion. In particular, our interest is in the mechanics and parameters related to
how images are formed and perceived by humans. We are interested in learn-
ing the physical limitations of human vision in terms of factors that also are
used in our work with digital images. Thus, factors such as how human and
electronic imaging devices compare in terms of resolution and ability to adapt
to changes in illumination are not only interesting, they also are important
from a practical point of view.

2.1.1 Structure of the Human Eye


Figure 2.1 shows a simplified horizontal cross section of the human eye. The
eye is nearly a sphere, with an average diameter of approximately 20 mm.
Three membranes enclose the eye: the cornea and sclera outer cover; the
choroid; and the retina. The cornea is a tough, transparent tissue that covers

FIGURE 2.1 Cornea


Simplified Iris
diagram of a cross
section of the
dy

human eye. Anterior chamber Ciliary muscle


bo
y
ar
ili
C

Lens

Ciliary fibers

Visual axis

Vitreous humor
Retina

Blind spot
Fovea
Sclera
Choroid

Ner
ve &
she
ath
2.1 ■ Elements of Visual Perception 37

the anterior surface of the eye. Continuous with the cornea, the sclera is an
opaque membrane that encloses the remainder of the optic globe.
The choroid lies directly below the sclera. This membrane contains a net-
work of blood vessels that serve as the major source of nutrition to the eye.
Even superficial injury to the choroid, often not deemed serious, can lead to
severe eye damage as a result of inflammation that restricts blood flow. The
choroid coat is heavily pigmented and hence helps to reduce the amount of ex-
traneous light entering the eye and the backscatter within the optic globe. At
its anterior extreme, the choroid is divided into the ciliary body and the iris.
The latter contracts or expands to control the amount of light that enters the
eye. The central opening of the iris (the pupil) varies in diameter from approx-
imately 2 to 8 mm. The front of the iris contains the visible pigment of the eye,
whereas the back contains a black pigment.
The lens is made up of concentric layers of fibrous cells and is suspended by
fibers that attach to the ciliary body. It contains 60 to 70% water, about 6% fat,
and more protein than any other tissue in the eye. The lens is colored by a
slightly yellow pigmentation that increases with age. In extreme cases, exces-
sive clouding of the lens, caused by the affliction commonly referred to as
cataracts, can lead to poor color discrimination and loss of clear vision. The
lens absorbs approximately 8% of the visible light spectrum, with relatively
higher absorption at shorter wavelengths. Both infrared and ultraviolet light
are absorbed appreciably by proteins within the lens structure and, in exces-
sive amounts, can damage the eye.
The innermost membrane of the eye is the retina, which lines the inside of
the wall’s entire posterior portion. When the eye is properly focused, light
from an object outside the eye is imaged on the retina. Pattern vision is afford-
ed by the distribution of discrete light receptors over the surface of the retina.
There are two classes of receptors: cones and rods. The cones in each eye num-
ber between 6 and 7 million. They are located primarily in the central portion
of the retina, called the fovea, and are highly sensitive to color. Humans can re-
solve fine details with these cones largely because each one is connected to its
own nerve end. Muscles controlling the eye rotate the eyeball until the image
of an object of interest falls on the fovea. Cone vision is called photopic or
bright-light vision.
The number of rods is much larger: Some 75 to 150 million are distributed
over the retinal surface. The larger area of distribution and the fact that sever-
al rods are connected to a single nerve end reduce the amount of detail dis-
cernible by these receptors. Rods serve to give a general, overall picture of the
field of view. They are not involved in color vision and are sensitive to low lev-
els of illumination. For example, objects that appear brightly colored in day-
light when seen by moonlight appear as colorless forms because only the rods
are stimulated. This phenomenon is known as scotopic or dim-light vision.
Figure 2.2 shows the density of rods and cones for a cross section of the
right eye passing through the region of emergence of the optic nerve from the
eye. The absence of receptors in this area results in the so-called blind spot (see
Fig. 2.1). Except for this region, the distribution of receptors is radially sym-
metric about the fovea. Receptor density is measured in degrees from the
38 Chapter 2 ■ Digital Image Fundamentals

FIGURE 2.2 180,000


Distribution of Blind spot
rods and cones in Cones
the retina. Rods

No. of rods or cones per mm2


135,000

90,000

45,000

80 60 40 20 0 20 40 60 80


Degrees from visual axis (center of fovea)

fovea (that is, in degrees off axis, as measured by the angle formed by the visu-
al axis and a line passing through the center of the lens and intersecting the
retina). Note in Fig. 2.2 that cones are most dense in the center of the retina (in
the center area of the fovea). Note also that rods increase in density from the
center out to approximately 20° off axis and then decrease in density out to the
extreme periphery of the retina.
The fovea itself is a circular indentation in the retina of about 1.5 mm in di-
ameter. However, in terms of future discussions, talking about square or rec-
tangular arrays of sensing elements is more useful. Thus, by taking some
liberty in interpretation, we can view the fovea as a square sensor array of size
1.5 mm * 1.5 mm. The density of cones in that area of the retina is approxi-
mately 150,000 elements per mm2. Based on these approximations, the number
of cones in the region of highest acuity in the eye is about 337,000 elements.
Just in terms of raw resolving power, a charge-coupled device (CCD) imaging
chip of medium resolution can have this number of elements in a receptor
array no larger than 5 mm * 5 mm. While the ability of humans to integrate
intelligence and experience with vision makes these types of number compar-
isons somewhat superficial, keep in mind for future discussions that the basic
ability of the eye to resolve detail certainly is comparable to current electronic
imaging sensors.

2.1.2 Image Formation in the Eye


In an ordinary photographic camera, the lens has a fixed focal length, and fo-
cusing at various distances is achieved by varying the distance between the
lens and the imaging plane, where the film (or imaging chip in the case of a
digital camera) is located. In the human eye, the converse is true; the distance
between the lens and the imaging region (the retina) is fixed, and the focal
length needed to achieve proper focus is obtained by varying the shape of the
lens. The fibers in the ciliary body accomplish this, flattening or thickening the
2.1 ■ Elements of Visual Perception 39

FIGURE 2.3
Graphical
C
representation of
15 m
the eye looking at
a palm tree. Point
C is the optical
center of the lens.
100 m 17 mm

lens for distant or near objects, respectively. The distance between the center
of the lens and the retina along the visual axis is approximately 17 mm. The
range of focal lengths is approximately 14 mm to 17 mm, the latter taking
place when the eye is relaxed and focused at distances greater than about 3 m.
The geometry in Fig. 2.3 illustrates how to obtain the dimensions of an
image formed on the retina. For example, suppose that a person is looking at a
tree 15 m high at a distance of 100 m. Letting h denote the height of that object
in the retinal image, the geometry of Fig. 2.3 yields 15>100 = h>17 or
h = 2.55 mm. As indicated in Section 2.1.1, the retinal image is focused pri-
marily on the region of the fovea. Perception then takes place by the relative
excitation of light receptors, which transform radiant energy into electrical im-
pulses that ultimately are decoded by the brain.

2.1.3 Brightness Adaptation and Discrimination


Because digital images are displayed as a discrete set of intensities, the eye’s
ability to discriminate between different intensity levels is an important consid-
eration in presenting image processing results. The range of light intensity levels
to which the human visual system can adapt is enormous—on the order of 1010—
from the scotopic threshold to the glare limit. Experimental evidence indicates
that subjective brightness (intensity as perceived by the human visual system) is a
logarithmic function of the light intensity incident on the eye. Figure 2.4, a plot

FIGURE 2.4
Glare limit
Range of
subjective
brightness
sensations
Subjective brightness

showing a
Adaptation range

Ba particular
adaptation level.
Bb

Scotopic

Scotopic Photopic
threshold
6 4 2 0 2 4
Log of intensity (mL)
40 Chapter 2 ■ Digital Image Fundamentals

of light intensity versus subjective brightness, illustrates this characteristic. The


long solid curve represents the range of intensities to which the visual system
can adapt. In photopic vision alone, the range is about 106. The transition from
scotopic to photopic vision is gradual over the approximate range from 0.001
to 0.1 millilambert ( -3 to -1 mL in the log scale), as the double branches of
the adaptation curve in this range show.
The essential point in interpreting the impressive dynamic range depicted in
Fig. 2.4 is that the visual system cannot operate over such a range simultaneously.
Rather, it accomplishes this large variation by changing its overall sensitivity, a
phenomenon known as brightness adaptation. The total range of distinct inten-
sity levels the eye can discriminate simultaneously is rather small when com-
pared with the total adaptation range. For any given set of conditions, the
current sensitivity level of the visual system is called the brightness adaptation
level, which may correspond, for example, to brightness Ba in Fig. 2.4. The
short intersecting curve represents the range of subjective brightness that the
eye can perceive when adapted to this level. This range is rather restricted,
having a level Bb at and below which all stimuli are perceived as indistinguish-
able blacks. The upper portion of the curve is not actually restricted but, if ex-
tended too far, loses its meaning because much higher intensities would simply
raise the adaptation level higher than Ba.
The ability of the eye to discriminate between changes in light intensity at
any specific adaptation level is also of considerable interest. A classic experi-
ment used to determine the capability of the human visual system for bright-
ness discrimination consists of having a subject look at a flat, uniformly
illuminated area large enough to occupy the entire field of view. This area typ-
ically is a diffuser, such as opaque glass, that is illuminated from behind by a
light source whose intensity, I, can be varied. To this field is added an incre-
ment of illumination, ¢I, in the form of a short-duration flash that appears as
a circle in the center of the uniformly illuminated field, as Fig. 2.5 shows.
If ¢I is not bright enough, the subject says “no,” indicating no perceivable
change. As ¢I gets stronger, the subject may give a positive response of “yes,” in-
dicating a perceived change. Finally, when ¢I is strong enough, the subject will
give a response of “yes” all the time. The quantity ¢Ic>I, where ¢Ic is the incre-
ment of illumination discriminable 50% of the time with background illumination
I, is called the Weber ratio. A small value of ¢Ic>I means that a small percentage
change in intensity is discriminable. This represents “good” brightness discrimi-
nation. Conversely, a large value of ¢Ic>I means that a large percentage change
in intensity is required. This represents “poor” brightness discrimination.

FIGURE 2.5 Basic


experimental
setup used to I  I
characterize
brightness
discrimination.

I
2.1 ■ Elements of Visual Perception 41

1.0 FIGURE 2.6


Typical Weber
0.5 ratio as a function
of intensity.
log Ic/I 0

0.5

1.0

1.5

2.0
4 3 2 1 0 1 2 3 4
log I

A plot of log ¢Ic>I as a function of log I has the general shape shown in
Fig. 2.6. This curve shows that brightness discrimination is poor (the Weber
ratio is large) at low levels of illumination, and it improves significantly (the
Weber ratio decreases) as background illumination increases. The two branch-
es in the curve reflect the fact that at low levels of illumination vision is carried
out by the rods, whereas at high levels (showing better discrimination) vision is
the function of cones.
If the background illumination is held constant and the intensity of the
other source, instead of flashing, is now allowed to vary incrementally from
never being perceived to always being perceived, the typical observer can dis-
cern a total of one to two dozen different intensity changes. Roughly, this re-
sult is related to the number of different intensities a person can see at any one
point in a monochrome image. This result does not mean that an image can be
represented by such a small number of intensity values because, as the eye
roams about the image, the average background changes, thus allowing a
different set of incremental changes to be detected at each new adaptation
level. The net consequence is that the eye is capable of a much broader range
of overall intensity discrimination. In fact, we show in Section 2.4.3 that the eye
is capable of detecting objectionable contouring effects in monochrome im-
ages whose overall intensity is represented by fewer than approximately two
dozen levels.
Two phenomena clearly demonstrate that perceived brightness is not a
simple function of intensity. The first is based on the fact that the visual sys-
tem tends to undershoot or overshoot around the boundary of regions of dif-
ferent intensities. Figure 2.7(a) shows a striking example of this phenomenon.
Although the intensity of the stripes is constant, we actually perceive a bright-
ness pattern that is strongly scalloped near the boundaries [Fig. 2.7(c)]. These
seemingly scalloped bands are called Mach bands after Ernst Mach, who first
described the phenomenon in 1865.
The second phenomenon, called simultaneous contrast, is related to the fact
that a region’s perceived brightness does not depend simply on its intensity, as
Fig. 2.8 demonstrates. All the center squares have exactly the same intensity.
42 Chapter 2 ■ Digital Image Fundamentals

a
b
c
FIGURE 2.7
Illustration of the
Mach band effect.
Perceived
intensity is not a
simple function of
Actual intensity
actual intensity.

Perceived intensity

However, they appear to the eye to become darker as the background gets
lighter. A more familiar example is a piece of paper that seems white when
lying on a desk, but can appear totally black when used to shield the eyes while
looking directly at a bright sky.
Other examples of human perception phenomena are optical illusions, in
which the eye fills in nonexisting information or wrongly perceives geometri-
cal properties of objects. Figure 2.9 shows some examples. In Fig. 2.9(a), the
outline of a square is seen clearly, despite the fact that no lines defining such a
figure are part of the image. The same effect, this time with a circle, can be seen
in Fig. 2.9(b); note how just a few lines are sufficient to give the illusion of a

a b c
FIGURE 2.8 Examples of simultaneous contrast. All the inner squares have the same
intensity, but they appear progressively darker as the background becomes lighter.
2.2 ■ Light and the Electromagnetic Spectrum 43

a b
c d
FIGURE 2.9 Some
well-known
optical illusions.

complete circle. The two horizontal line segments in Fig. 2.9(c) are of the same
length, but one appears shorter than the other. Finally, all lines in Fig. 2.9(d) that
are oriented at 45° are equidistant and parallel.Yet the crosshatching creates the
illusion that those lines are far from being parallel. Optical illusions are a char-
acteristic of the human visual system that is not fully understood.

2.2 Light and the Electromagnetic Spectrum


The electromagnetic spectrum was introduced in Section 1.3. We now consider
this topic in more detail. In 1666, Sir Isaac Newton discovered that when a beam
of sunlight is passed 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.As Fig. 2.10 shows, the range of colors we perceive
in visible light represents a very small portion of the electromagnetic spectrum.
On one end of the spectrum are radio waves with wavelengths billions of times
longer than those of visible light. On the other end of the spectrum are gamma
rays with wavelengths millions of times smaller than those of visible light. The
electromagnetic spectrum can be expressed in terms of wavelength, frequency,
or energy. Wavelength (l) and frequency (n) are related by the expression
c
l = (2.2-1)
n
44 Chapter 2 ■ Digital Image Fundamentals

Energy of one photon (electron volts)


106 105 104 103 102 101 1 101 102 103 104 105 106 107 108 109

Frequency (Hz)
21 20 19 18 17 16 15
10 10 10 10 10 10 10 1014 1013 1012 1011 1010 109 108 107 106 105

Wavelength (meters)
12 11 10 9 8 7
10 10 10 10 10 10 106 105 104 103 102 101 1 101 102 103

Gamma rays X-rays Ultraviolet Infrared Microwaves Radio waves

Visible spectrum

0.4  106 0.5  106 0.6  106 0.7  106


Ultraviolet Violet Blue Green Yellow Orange Red Infrared

FIGURE 2.10 The electromagnetic spectrum. The visible spectrum is shown zoomed to facilitate explanation,
but note that the visible spectrum is a rather narrow portion of the EM spectrum.

where c is the speed of light (2.998 * 108 m>s). The energy of the various com-
ponents of the electromagnetic spectrum is given by the expression
E = hn (2.2-2)
where h is Planck’s constant. The units of wavelength are meters, with the terms
microns (denoted m and equal to 10-6 m) and nanometers (denoted nm and
equal to 10 -9 m) being used just as frequently. Frequency is measured in Hertz
(Hz), with one Hertz being equal to one cycle of a sinusoidal wave per second.
A commonly used unit of energy is the electron-volt.
Electromagnetic waves can be visualized as propagating sinusoidal waves
with wavelength l (Fig. 2.11), or they can be thought of as a stream of massless
particles, each traveling in a wavelike pattern and moving at the speed of light.
Each massless particle contains a certain amount (or bundle) of energy. Each

FIGURE 2.11 l
Graphical
representation of
one wavelength.
2.2 ■ Light and the Electromagnetic Spectrum 45

bundle of energy is called a photon. We see from Eq. (2.2-2) that energy is
proportional to frequency, so the higher-frequency (shorter wavelength) elec-
tromagnetic phenomena carry more energy per photon. Thus, radio waves
have photons with low energies, microwaves have more energy than radio
waves, infrared still more, then visible, ultraviolet, X-rays, and finally gamma
rays, the most energetic of all. This is the reason why gamma rays are so dan-
gerous to living organisms.
Light is a particular type of electromagnetic radiation that can be sensed by
the human eye. The visible (color) spectrum is shown expanded in Fig. 2.10 for
the purpose of discussion (we consider color in much more detail in Chapter 6).
The visible band of the electromagnetic spectrum spans the range from approxi-
mately 0.43 m (violet) to about 0.79 m (red). For convenience, the color spec-
trum is divided into six broad regions: violet, blue, green, yellow, orange, and red.
No color (or other component of the electromagnetic spectrum) ends abruptly,
but rather each range blends smoothly into the next, as shown in Fig. 2.10.
The colors that humans perceive in an object are determined by the nature
of the light reflected from the object. A body that reflects light relatively bal-
anced in all visible wavelengths appears white to the observer. However, a
body that favors reflectance in a limited range of the visible spectrum exhibits
some shades of color. For example, green objects reflect light with wavelengths
primarily in the 500 to 570 nm range while absorbing most of the energy at
other wavelengths.
Light that is void of color is called monochromatic (or achromatic) light.
The only attribute of monochromatic light is its intensity or amount. Because
the intensity of monochromatic light is perceived to vary from black to grays
and finally to white, the term gray level is used commonly to denote mono-
chromatic intensity. We use the terms intensity and gray level interchangeably
in subsequent discussions. The range of measured values of monochromatic
light from black to white is usually called the gray scale, and monochromatic
images are frequently referred to as gray-scale images.
Chromatic (color) light spans the electromagnetic energy spectrum from
approximately 0.43 to 0.79 m, as noted previously. In addition to frequency,
three basic quantities are used to describe the quality of a chromatic light
source: radiance, luminance, and brightness. Radiance is the total amount of
energy that flows from the light source, and it is usually measured in watts
(W). Luminance, measured in lumens (lm), gives a measure of the amount of
energy an observer perceives from a light source. For example, 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 lu-
minance would be almost zero. Finally, as discussed in Section 2.1, brightness is
a subjective descriptor of light perception that is practically impossible to
measure. It embodies the achromatic notion of intensity and is one of the key
factors in describing color sensation.
Continuing with the discussion of Fig. 2.10, we note that at the short-
wavelength end of the electromagnetic spectrum, we have gamma rays and
X-rays. As discussed in Section 1.3.1, gamma radiation is important for medical
and astronomical imaging, and for imaging radiation in nuclear environments.
46 Chapter 2 ■ Digital Image Fundamentals

Hard (high-energy) X-rays are used in industrial applications. Chest and


dental X-rays are in the lower energy (soft) end of the X-ray band. The soft
X-ray band transitions into the far ultraviolet light region, which in turn
blends with the visible spectrum at longer wavelengths. Moving still higher in
wavelength, we encounter the infrared band, which radiates heat, a fact that
makes it useful in imaging applications that rely on “heat signatures.” The part
of the infrared band close to the visible spectrum is called the near-infrared re-
gion. The opposite end of this band is called the far-infrared region. This latter
region blends with the microwave band. This band is well known as the source
of energy in microwave ovens, but it has many other uses, including communi-
cation and radar. Finally, the radio wave band encompasses television as well
as AM and FM radio. In the higher energies, radio signals emanating from cer-
tain stellar bodies are useful in astronomical observations. Examples of images
in most of the bands just discussed are given in Section 1.3.
In principle, if a sensor can be developed that is capable of detecting energy
radiated by a band of the electromagnetic spectrum, we can image events of
interest in that band. It is important to note, however, that the wavelength of
an electromagnetic wave required to “see” an object must be of the same size
as or smaller than the object. For example, a water molecule has a diameter on
the order of 10-10 m. Thus, to study molecules, we would need a source capable
of emitting in the far ultraviolet or soft X-ray region. This limitation, along
with the physical properties of the sensor material, establishes the fundamen-
tal limits on the capability of imaging sensors, such as visible, infrared, and
other sensors in use today.
Although imaging is based predominantly on energy radiated by electro-
magnetic waves, this is not the only method for image generation. For ex-
ample, as discussed in Section 1.3.7, sound reflected from objects can be
used to form ultrasonic images. Other major sources of digital images are
electron beams for electron microscopy and synthetic images used in graphics
and visualization.

2.3 Image Sensing and Acquisition


Most of the images in which we are interested are generated by the combina-
tion of an “illumination” source and the reflection or absorption of energy
from that source by the elements of the “scene” being imaged. We enclose
illumination and scene in quotes to emphasize the fact that they are consider-
ably more general than the familiar situation in which a visible light source il-
luminates a common everyday 3-D (three-dimensional) scene. For example,
the illumination may originate from a source of electromagnetic energy such
as radar, infrared, or X-ray system. But, as noted earlier, it could originate
from less traditional sources, such as ultrasound or even a computer-generated
illumination pattern. Similarly, the scene elements could be familiar objects,
but they can just as easily be molecules, buried rock formations, or a human
brain. Depending on the nature of the source, illumination energy is reflected
from, or transmitted through, objects. An example in the first category is light
2.3 ■ Image Sensing and Acquisition 47

reflected from a planar surface. An example in the second category is when


X-rays pass through a patient’s body for the purpose of generating a diagnos-
tic X-ray film. In some applications, the reflected or transmitted energy is fo-
cused onto a photoconverter (e.g., a phosphor screen), which converts the
energy into visible light. Electron microscopy and some applications of gamma
imaging use this approach.
Figure 2.12 shows the three principal sensor arrangements used to trans-
form illumination energy into digital images. The idea is simple: Incoming en-
ergy is transformed into a voltage by the combination of input electrical power
and sensor material that is responsive to the particular type of energy being
detected. The output voltage waveform is the response of the sensor(s), and a
digital quantity is obtained from each sensor by digitizing its response. In this
section, we look at the principal modalities for image sensing and generation.
Image digitizing is discussed in Section 2.4.

Energy a
b
Filter c
FIGURE 2.12
(a) Single imaging
Sensing material
Power in sensor.
(b) Line sensor.
(c) Array sensor.
Voltage waveform out
Housing
48 Chapter 2 ■ Digital Image Fundamentals

FIGURE 2.13 Film


Combining a
single sensor with
motion to
generate a 2-D Sensor Rotation
image.

Linear motion
One image line out
per increment of rotation
and full linear displacement
of sensor from left to right

2.3.1 Image Acquisition Using a Single Sensor


Figure 2.12(a) shows the components of a single sensor. Perhaps the most fa-
miliar sensor of this type is the photodiode, which is constructed of silicon ma-
terials and whose output voltage waveform is proportional to light. The use of
a filter in front of a sensor improves selectivity. For example, a green (pass) fil-
ter in front of a light sensor favors light in the green band of the color spec-
trum. As a consequence, the sensor output will be stronger for green light than
for other components in the visible spectrum.
In order to generate a 2-D image using a single sensor, there has to be rela-
tive displacements in both the x- and y-directions between the sensor and the
area to be imaged. Figure 2.13 shows an arrangement used in high-precision
scanning, where a film negative is mounted onto a drum whose mechanical ro-
tation provides displacement in one dimension. The single sensor is mounted
on a lead screw that provides motion in the perpendicular direction. Because
mechanical motion can be controlled with high precision, this method is an in-
expensive (but slow) way to obtain high-resolution images. Other similar me-
chanical arrangements use a flat bed, with the sensor moving in two linear
directions. These types of mechanical digitizers sometimes are referred to as
microdensitometers.
Another example of imaging with a single sensor places a laser source coin-
cident with the sensor. Moving mirrors are used to control the outgoing beam
in a scanning pattern and to direct the reflected laser signal onto the sensor.
This arrangement can be used also to acquire images using strip and array sen-
sors, which are discussed in the following two sections.

2.3.2 Image Acquisition Using Sensor Strips


A geometry that is used much more frequently than single sensors consists of an
in-line arrangement of sensors in the form of a sensor strip, as Fig. 2.12(b) shows.
The strip provides imaging elements in one direction. Motion perpendicular to the
strip provides imaging in the other direction, as shown in Fig. 2.14(a). This is the
type of arrangement used in most flat bed scanners. Sensing devices with 4000 or
more in-line sensors are possible. In-line sensors are used routinely in airborne
imaging applications, in which the imaging system is mounted on an aircraft that
2.3 ■ Image Sensing and Acquisition 49

One image line out per


increment of linear motion

Imaged area
Image
reconstruction
Cross-sectional images
Linear motion of 3-D object

Sensor strip

3-D object

X-ray source

tion
ar mo
L ine
Sensor ring

a b
FIGURE 2.14 (a) Image acquisition using a linear sensor strip. (b) Image acquisition using a circular sensor strip.

flies at a constant altitude and speed over the geographical area to be imaged.
One-dimensional imaging sensor strips that respond to various bands of the
electromagnetic spectrum are mounted perpendicular to the direction of
flight. The imaging strip gives one line of an image at a time, and the motion of
the strip completes the other dimension of a two-dimensional image. Lenses
or other focusing schemes are used to project the area to be scanned onto the
sensors.
Sensor strips mounted in a ring configuration are used in medical and in-
dustrial imaging to obtain cross-sectional (“slice”) images of 3-D objects, as
Fig. 2.14(b) shows. A rotating X-ray source provides illumination and the sen-
sors opposite the source collect the X-ray energy that passes through the ob-
ject (the sensors obviously have to be sensitive to X-ray energy). This is the
basis for medical and industrial computerized axial tomography (CAT) imag-
ing as indicated in Sections 1.2 and 1.3.2. It is important to note that the output
of the sensors must be processed by reconstruction algorithms whose objective
is to transform the sensed data into meaningful cross-sectional images (see
Section 5.11). In other words, images are not obtained directly from the sen-
sors by motion alone; they require extensive processing. A 3-D digital volume
consisting of stacked images is generated as the object is moved in a direction
50 Chapter 2 ■ Digital Image Fundamentals

perpendicular to the sensor ring. Other modalities of imaging based on the


CAT principle include magnetic resonance imaging (MRI) and positron emis-
sion tomography (PET). The illumination sources, sensors, and types of images
are different, but conceptually they are very similar to the basic imaging ap-
proach shown in Fig. 2.14(b).

2.3.3 Image Acquisition Using Sensor Arrays


Figure 2.12(c) shows individual sensors arranged in the form of a 2-D array.
Numerous electromagnetic and some ultrasonic sensing devices frequently
are arranged in an array format. This is also the predominant arrangement
found in digital cameras. A typical sensor for these cameras is a CCD array,
which can be manufactured with a broad range of sensing properties and can
be packaged in rugged arrays of 4000 * 4000 elements or more. CCD sen-
sors are used widely in digital cameras and other light sensing instruments.
The response of each sensor is proportional to the integral of the light ener-
gy projected onto the surface of the sensor, a property that is used in astro-
nomical and other applications requiring low noise images. Noise reduction
is achieved by letting the sensor integrate the input light signal over minutes
or even hours. Because the sensor array in Fig. 2.12(c) is two-dimensional, its
key advantage is that a complete image can be obtained by focusing the en-
ergy pattern onto the surface of the array. Motion obviously is not necessary,
as is the case with the sensor arrangements discussed in the preceding two
sections.
The principal manner in which array sensors are used is shown in Fig. 2.15.
In some cases, we image This figure shows the energy from an illumination source being reflected
the source directly, as in
obtaining images of the from a scene element (as mentioned at the beginning of this section, the en-
sun. ergy also could be transmitted through the scene elements). The first function
performed by the imaging system in Fig. 2.15(c) is to collect the incoming
energy and focus it onto an image plane. If the illumination is light, the front
end of the imaging system is an optical lens that projects the viewed scene
onto the lens focal plane, as Fig. 2.15(d) shows. The sensor array, which is
Image intensities can coincident with the focal plane, produces outputs proportional to the integral
become negative during
processing or as a result of the light received at each sensor. Digital and analog circuitry sweep these
of interpretation. For outputs and convert them to an analog signal, which is then digitized by an-
example, in radar images
objects moving toward a other section of the imaging system. The output is a digital image, as shown
radar system often are diagrammatically in Fig. 2.15(e). Conversion of an image into digital form is
interpreted as having
negative velocities while the topic of Section 2.4.
objects moving away are
interpreted as having
positive velocities. Thus, a
velocity image might be
2.3.4 A Simple Image Formation Model
coded as having both
positive and negative
As introduced in Section 1.1, we denote images by two-dimensional func-
values. When storing and tions of the form f(x, y). The value or amplitude of f at spatial coordinates
displaying images, we
normally scale the inten-
(x, y) is a positive scalar quantity whose physical meaning is determined by
sities so that the smallest the source of the image. When an image is generated from a physical process,
negative value becomes 0
(see Section 2.6.3 regard-
its intensity values are proportional to energy radiated by a physical source
ing intensity scaling). (e.g., electromagnetic waves). As a consequence, f(x, y) must be nonzero
2.3 ■ Image Sensing and Acquisition 51

Illumination (energy)
source

Output (digitized) image

Imaging system

(Internal) image plane

Scene element
a
c d e
b
FIGURE 2.15 An example of the digital image acquisition process. (a) Energy (“illumination”) source. (b) An
element of a scene. (c) Imaging system. (d) Projection of the scene onto the image plane. (e) Digitized image.

and finite; that is,


0 6 f(x, y) 6 q (2.3-1)
The function f(x, y) may be characterized by two components: (1) the amount
of source illumination incident on the scene being viewed, and (2) the amount of il-
lumination reflected by the objects in the scene.Appropriately, these are called the
illumination and reflectance components and are denoted by i(x, y) and r(x, y),
respectively.The two functions combine as a product to form f(x, y):
f(x, y) = i (x, y) r (x, y) (2.3-2)
where
0 6 i (x, y) 6 q (2.3-3)
and
0 6 r (x, y) 6 1 (2.3-4)
Equation (2.3-4) indicates that reflectance is bounded by 0 (total absorption)
and 1 (total reflectance). The nature of i (x, y) is determined by the illumina-
tion source, and r (x, y) is determined by the characteristics of the imaged ob-
jects. It is noted that these expressions also are applicable to images formed
via transmission of the illumination through a medium, such as a chest X-ray.
52 Chapter 2 ■ Digital Image Fundamentals

In this case, we would deal with a transmissivity instead of a reflectivity func-


tion, but the limits would be the same as in Eq. (2.3-4), and the image function
formed would be modeled as the product in Eq. (2.3-2).

EXAMPLE 2.1: ■ The values given in Eqs. (2.3-3) and (2.3-4) are theoretical bounds. The fol-
Some typical lowing average numerical figures illustrate some typical ranges of i (x, y) for
values of visible light. On a clear day, the sun may produce in excess of 90,000 lm>m2
illumination and
reflectance. of illumination on the surface of the Earth. This figure decreases to less than
10,000 lm>m2 on a cloudy day. On a clear evening, a full moon yields about
0.1 lm>m2 of illumination. The typical illumination level in a commercial office
is about 1000 lm>m2. Similarly, the following are typical values of r (x, y): 0.01
for black velvet, 0.65 for stainless steel, 0.80 for flat-white wall paint, 0.90 for
silver-plated metal, and 0.93 for snow. ■

Let the intensity (gray level) of a monochrome image at any coordinates


(x0, y0) be denoted by
/ = f(x0, y0) (2.3-5)
From Eqs. (2.3-2) through (2.3-4), it is evident that / lies in the range
Lmin … / … Lmax (2.3-6)
In theory, the only requirement on Lmin is that it be positive, and on Lmax that
it be finite. In practice, Lmin = i min r min and Lmax = i max r max. Using the pre-
ceding average office illumination and range of reflectance values as guide-
lines, we may expect Lmin L 10 and Lmax L 1000 to be typical limits for indoor
values in the absence of additional illumination.
The interval [Lmin, Lmax] is called the gray (or intensity) scale. Common
practice is to shift this interval numerically to the interval [0, L - 1], where
/ = 0 is considered black and / = L - 1 is considered white on the gray scale.
All intermediate values are shades of gray varying from black to white.

2.4 Image Sampling and Quantization


The discussion of From the discussion in the preceding section, we see that there are numerous
sampling in this section is
of an intuitive nature. We
ways to acquire images, but our objective in all is the same: to generate digital
consider this topic in images from sensed data. The output of most sensors is a continuous voltage
depth in Chapter 4.
waveform whose amplitude and spatial behavior are related to the physical
phenomenon being sensed. To create a digital image, we need to convert the
continuous sensed data into digital form. This involves two processes: sampling
and quantization.

2.4.1 Basic Concepts in Sampling and Quantization


The basic idea behind sampling and quantization is illustrated in Fig. 2.16.
Figure 2.16(a) shows a continuous image f that we want to convert to digital
form. An image may be continuous with respect to the x- and y-coordinates,
and also in amplitude. To convert it to digital form, we have to sample the
2.4 ■ Image Sampling and Quantization 53

a b
c d
A B FIGURE 2.16
Generating a
digital image.
(a) Continuous
image. (b) A scan
line from A to B
A B in the continuous
image, used to
illustrate the
concepts of
sampling and
quantization.
(c) Sampling and
A B A B quantization.
(d) Digital
scan line.
Quantization

Sampling

function in both coordinates and in amplitude. Digitizing the coordinate values


is called sampling. Digitizing the amplitude values is called quantization.
The one-dimensional function in Fig. 2.16(b) is a plot of amplitude (intensity
level) values of the continuous image along the line segment AB in Fig. 2.16(a).
The random variations are due to image noise. To sample this function, we take
equally spaced samples along line AB, as shown in Fig. 2.16(c). The spatial loca-
tion of each sample is indicated by a vertical tick mark in the bottom part of the
figure. The samples are shown as small white squares superimposed on the func-
tion.The set of these discrete locations gives the sampled function. However, the
values of the samples still span (vertically) a continuous range of intensity val-
ues. In order to form a digital function, the intensity values also must be con-
verted (quantized) into discrete quantities. The right side of Fig. 2.16(c) shows
the intensity scale divided into eight discrete intervals, ranging from black to
white. The vertical tick marks indicate the specific value assigned to each of the
eight intensity intervals. The continuous intensity levels are quantized by assign-
ing one of the eight values to each sample.The assignment is made depending on
the vertical proximity of a sample to a vertical tick mark. The digital samples
resulting from both sampling and quantization are shown in Fig. 2.16(d). Start-
ing at the top of the image and carrying out this procedure line by line produces
a two-dimensional digital image. It is implied in Fig. 2.16 that, in addition to the
number of discrete levels used, the accuracy achieved in quantization is highly
dependent on the noise content of the sampled signal.
Sampling in the manner just described assumes that we have a continuous
image in both coordinate directions as well as in amplitude. In practice, the
54 Chapter 2 ■ Digital Image Fundamentals

method of sampling is determined by the sensor arrangement used to generate


the image. When an image is generated by a single sensing element combined
with mechanical motion, as in Fig. 2.13, the output of the sensor is quantized in
the manner described above. However, spatial sampling is accomplished by se-
lecting the number of individual mechanical increments at which we activate
the sensor to collect data. Mechanical motion can be made very exact so, in
principle, there is almost no limit as to how fine we can sample an image using
this approach. In practice, limits on sampling accuracy are determined by
other factors, such as the quality of the optical components of the system.
When a sensing strip is used for image acquisition, the number of sensors in
the strip establishes the sampling limitations in one image direction. Mechani-
cal motion in the other direction can be controlled more accurately, but it
makes little sense to try to achieve sampling density in one direction that ex-
ceeds the sampling limits established by the number of sensors in the other.
Quantization of the sensor outputs completes the process of generating a dig-
ital image.
When a sensing array is used for image acquisition, there is no motion and
the number of sensors in the array establishes the limits of sampling in both di-
rections. Quantization of the sensor outputs is as before. Figure 2.17 illustrates
this concept. Figure 2.17(a) shows a continuous image projected onto the
plane of an array sensor. Figure 2.17(b) shows the image after sampling and
quantization. Clearly, the quality of a digital image is determined to a large de-
gree by the number of samples and discrete intensity levels used in sampling
and quantization. However, as we show in Section 2.4.3, image content is also
an important consideration in choosing these parameters.

a b
FIGURE 2.17 (a) Continuous image projected onto a sensor array. (b) Result of image
sampling and quantization.
2.4 ■ Image Sampling and Quantization 55

2.4.2 Representing Digital Images


Let f(s, t) represent a continuous image function of two continuous variables,
s and t. We convert this function into a digital image by sampling and quanti-
zation, as explained in the previous section. Suppose that we sample the
continuous image into a 2-D array, f(x, y), containing M rows and N
columns, where (x, y) are discrete coordinates. For notational clarity and
convenience, we use integer values for these discrete coordinates:
x = 0, 1, 2, Á , M - 1 and y = 0, 1, 2, Á , N - 1. Thus, for example, the
value of the digital image at the origin is f(0, 0), and the next coordinate
value along the first row is f(0, 1). Here, the notation (0, 1) is used to signify
the second sample along the first row. It does not mean that these are the val-
ues of the physical coordinates when the image was sampled. In general, the
value of the image at any coordinates (x, y) is denoted f(x, y), where x and y
are integers. The section of the real plane spanned by the coordinates of an
image is called the spatial domain, with x and y being referred to as spatial
variables or spatial coordinates.
As Fig. 2.18 shows, there are three basic ways to represent f(x, y).
Figure 2.18(a) is a plot of the function, with two axes determining spatial location

f (x, y) a
b c
FIGURE 2.18
(a) Image plotted
as a surface.
(b) Image
displayed as a
visual intensity
array.
(c) Image shown
as a 2-D
y numerical array
x (0, .5, and 1
represent black,
gray, and white,
Origin Origin respectively).
y 0 0 0 0 0 0 0  0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0  0 0 0 0

0 0 0   .5 .5 .5   0 0 0
0 0 0 .5 .5 0 0 0
 .5   
  1 1 1  
  
1 1
0 0 0 1  0 0 0
0 0 0  0 0 0

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0  0 0 0 0 0 0 0
x
56 Chapter 2 ■ Digital Image Fundamentals

and the third axis being the values of f (intensities) as a function of the two spa-
tial variables x and y. Although we can infer the structure of the image in this
example by looking at the plot, complex images generally are too detailed and
difficult to interpret from such plots. This representation is useful when work-
ing with gray-scale sets whose elements are expressed as triplets of the form
(x, y, z), where x and y are spatial coordinates and z is the value of f at coordi-
nates (x, y). We work with this representation in Section 2.6.4.
The representation in Fig. 2.18(b) is much more common. It shows f(x, y)
as it would appear on a monitor or photograph. Here, the intensity of each
point is proportional to the value of f at that point. In this figure, there are only
three equally spaced intensity values. If the intensity is normalized to the in-
terval [0, 1], then each point in the image has the value 0, 0.5, or 1. A monitor
or printer simply converts these three values to black, gray, or white, respec-
tively, as Fig. 2.18(b) shows. The third representation is simply to display the
numerical values of f(x, y) as an array (matrix). In this example, f is of size
600 * 600 elements, or 360,000 numbers. Clearly, printing the complete array
would be cumbersome and convey little information. When developing algo-
rithms, however, this representation is quite useful when only parts of the
image are printed and analyzed as numerical values. Figure 2.18(c) conveys
this concept graphically.
We conclude from the previous paragraph that the representations in
Figs. 2.18(b) and (c) are the most useful. Image displays allow us to view re-
sults at a glance. Numerical arrays are used for processing and algorithm devel-
opment. In equation form, we write the representation of an M * N numerical
array as

f(0, 0) f(0, 1) Á f(0, N - 1)


f(1, 0) f(1, 1) Á f(1, N - 1)
f(x, y) = D T (2.4-1)
o o o
f(M - 1, 0) f(M - 1, 1) Á f(M - 1, N - 1)

Both sides of this equation are equivalent ways of expressing a digital image
quantitatively. The right side is a matrix of real numbers. Each element of this
matrix is called an image element, picture element, pixel, or pel. The terms
image and pixel are used throughout the book to denote a digital image and
its elements.
In some discussions it is advantageous to use a more traditional matrix no-
tation to denote a digital image and its elements:

a0, 0 a0, 1 Á a0, N - 1


a1, 0 a1, 1 Á a1, N - 1
A = D T (2.4-2)
o o o
aM - 1, 0 aM - 1, 1 Á aM - 1, N - 1
2.4 ■ Image Sampling and Quantization 57

Clearly, aij = f(x = i, y = j) = f(i, j), so Eqs. (2.4-1) and (2.4-2) are identical
matrices. We can even represent an image as a vector, v. For example, a column
vector of size MN * 1 is formed by letting the first M elements of v be the first
column of A, the next M elements be the second column, and so on. Alterna-
tively, we can use the rows instead of the columns of A to form such a vector.
Either representation is valid, as long as we are consistent.
Returning briefly to Fig. 2.18, note that the origin of a digital image is at the
top left, with the positive x-axis extending downward and the positive y-axis
extending to the right. This is a conventional representation based on the fact
that many image displays (e.g., TV monitors) sweep an image starting at the
top left and moving to the right one row at a time. More important is the fact
that the first element of a matrix is by convention at the top left of the array, so
choosing the origin of f(x, y) at that point makes sense mathematically. Keep
in mind that this representation is the standard right-handed Cartesian coordi-
nate system with which you are familiar.† We simply show the axes pointing
downward and to the right, instead of to the right and up.
Expressing sampling and quantization in more formal mathematical terms
can be useful at times. Let Z and R denote the set of integers and the set of
real numbers, respectively. The sampling process may be viewed as partition-
ing the xy-plane into a grid, with the coordinates of the center of each cell in
the grid being a pair of elements from the Cartesian product Z2, which is the
set of all ordered pairs of elements (zi, zj), with zi and zj being integers from
Z. Hence, f(x, y) is a digital image if (x, y) are integers from Z2 and f is a
function that assigns an intensity value (that is, a real number from the set
of real numbers, R) to each distinct pair of coordinates (x, y). This functional
assignment is the quantization process described earlier. If the intensity lev-
els also are integers (as usually is the case in this and subsequent chapters),
Z replaces R, and a digital image then becomes a 2-D function whose coor-
dinates and amplitude values are integers.
This digitization process requires that decisions be made regarding the val-
ues for M, N, and for the number, L, of discrete intensity levels. There are no
restrictions placed on M and N, other than they have to be positive integers.
However, due to storage and quantizing hardware considerations, the number
Often, it is useful for
of intensity levels typically is an integer power of 2: computation or for
algorithm development
L = 2k (2.4-3) purposes to scale the L
intensity values to the
We assume that the discrete levels are equally spaced and that they are inte- range [0, 1], in which case
they cease to be integers.
gers in the interval [0, L - 1]. Sometimes, the range of values spanned by the However, in most cases
gray scale is referred to informally as the dynamic range. This is a term used in these values are scaled
back to the integer range
different ways in different fields. Here, we define the dynamic range of an imag- [0, L - 1] for image
ing system to be the ratio of the maximum measurable intensity to the minimum storage and display.


Recall that a right-handed coordinate system is such that, when the index of the right hand points in the di-
rection of the positive x-axis and the middle finger points in the (perpendicular) direction of the positive
y-axis, the thumb points up. As Fig. 2.18(a) shows, this indeed is the case in our image coordinate system.
58 Chapter 2 ■ Digital Image Fundamentals

FIGURE 2.19 An
image exhibiting
saturation and Saturation
noise. Saturation is
the highest value
beyond which all
intensity levels are
clipped (note how
the entire
saturated area has
a high, constant Noise
intensity level).
Noise in this case
appears as a grainy
texture pattern.
Noise, especially in
the darker regions
of an image (e.g.,
the stem of the
rose) masks the
lowest detectable
true intensity level.

detectable intensity level in the system. As a rule, the upper limit is determined
by saturation and the lower limit by noise (see Fig. 2.19). Basically, dynamic
range establishes the lowest and highest intensity levels that a system can repre-
sent and, consequently, that an image can have. Closely associated with this con-
cept is image contrast, which we define as the difference in intensity between
the highest and lowest intensity levels in an image. When an appreciable num-
ber of pixels in an image have a high dynamic range, we can expect the image
to have high contrast. Conversely, an image with low dynamic range typically
has a dull, washed-out gray look. We discuss these concepts in more detail in
Chapter 3.
The number, b, of bits required to store a digitized image is

b = M * N * k (2.4-4)

When M = N, this equation becomes

b = N2k (2.4-5)

Table 2.1 shows the number of bits required to store square images with vari-
ous values of N and k. The number of intensity levels corresponding to each
value of k is shown in parentheses. When an image can have 2 k intensity levels,
it is common practice to refer to the image as a “k-bit image.” For example, an
image with 256 possible discrete intensity values is called an 8-bit image. Note
that storage requirements for 8-bit images of size 1024 * 1024 and higher are
not insignificant.
2.4 ■ Image Sampling and Quantization 59

TABLE 2.1
Number of storage bits for various values of N and k. L is the number of intensity levels.

N/k 1 (L = 2) 2 (L = 4) 3 (L = 8) 4 (L = 16) 5 (L = 32) 6 (L = 64) 7 (L = 128) 8 (L = 256)

32 1,024 2,048 3,072 4,096 5,120 6,144 7,168 8,192


64 4,096 8,192 12,288 16,384 20,480 24,576 28,672 32,768
128 16,384 32,768 49,152 65,536 81,920 98,304 114,688 131,072
256 65,536 131,072 196,608 262,144 327,680 393,216 458,752 524,288
512 262,144 524,288 786,432 1,048,576 1,310,720 1,572,864 1,835,008 2,097,152
1024 1,048,576 2,097,152 3,145,728 4,194,304 5,242,880 6,291,456 7,340,032 8,388,608
2048 4,194,304 8,388,608 12,582,912 16,777,216 20,971,520 25,165,824 29,369,128 33,554,432
4096 16,777,216 33,554,432 50,331,648 67,108,864 83,886,080 100,663,296 117,440,512 134,217,728
8192 67,108,864 134,217,728 201,326,592 268,435,456 335,544,320 402,653,184 469,762,048 536,870,912

2.4.3 Spatial and Intensity Resolution


Intuitively, spatial resolution is a measure of the smallest discernible detail in
an image. Quantitatively, spatial resolution can be stated in a number of ways,
with line pairs per unit distance, and dots (pixels) per unit distance being
among the most common measures. Suppose that we construct a chart with
alternating black and white vertical lines, each of width W units (W can be
less than 1). The width of a line pair is thus 2W, and there are 1>2W line pairs
per unit distance. For example, if the width of a line is 0.1 mm, there are 5 line
pairs per unit distance (mm). A widely used definition of image resolution is
the largest number of discernible line pairs per unit distance (e.g., 100 line
pairs per mm). Dots per unit distance is a measure of image resolution used
commonly in the printing and publishing industry. In the U.S., this measure
usually is expressed as dots per inch (dpi). To give you an idea of quality,
newspapers are printed with a resolution of 75 dpi, magazines at 133 dpi,
glossy brochures at 175 dpi, and the book page at which you are presently
looking is printed at 2400 dpi.
The key point in the preceding paragraph is that, to be meaningful, mea-
sures of spatial resolution must be stated with respect to spatial units. Image
size by itself does not tell the complete story. To say that an image has, say, a
resolution 1024 * 1024 pixels is not a meaningful statement without stating
the spatial dimensions encompassed by the image. Size by itself is helpful only
in making comparisons between imaging capabilities. For example, a digital
camera with a 20-megapixel CCD imaging chip can be expected to have a
higher capability to resolve detail than an 8-megapixel camera, assuming that
both cameras are equipped with comparable lenses and the comparison im-
ages are taken at the same distance.
Intensity resolution similarly refers to the smallest discernible change in in-
tensity level. We have considerable discretion regarding the number of sam-
ples used to generate a digital image, but this is not true regarding the number
60 Chapter 2 ■ Digital Image Fundamentals

of intensity levels. Based on hardware considerations, the number of intensity


levels usually is an integer power of two, as mentioned in the previous section.
The most common number is 8 bits, with 16 bits being used in some applica-
tions in which enhancement of specific intensity ranges is necessary. Intensity
quantization using 32 bits is rare. Sometimes one finds systems that can digi-
tize the intensity levels of an image using 10 or 12 bits, but these are the excep-
tion, rather than the rule. Unlike spatial resolution, which must be based on a
per unit of distance basis to be meaningful, it is common practice to refer to
the number of bits used to quantize intensity as the intensity resolution. For ex-
ample, it is common to say that an image whose intensity is quantized into 256
levels has 8 bits of intensity resolution. Because true discernible changes in in-
tensity are influenced not only by noise and saturation values but also by the
capabilities of human perception (see Section 2.1), saying than an image has 8
bits of intensity resolution is nothing more than a statement regarding the
ability of an 8-bit system to quantize intensity in fixed increments of 1>256
units of intensity amplitude.
The following two examples illustrate individually the comparative effects
of image size and intensity resolution on discernable detail. Later in this sec-
tion, we discuss how these two parameters interact in determining perceived
image quality.

EXAMPLE 2.2: ■ Figure 2.20 shows the effects of reducing spatial resolution in an image.
Illustration of the The images in Figs. 2.20(a) through (d) are shown in 1250, 300, 150, and 72
effects of reducing dpi, respectively. Naturally, the lower resolution images are smaller than the
image spatial
resolution. original. For example, the original image is of size 3692 * 2812 pixels, but the
72 dpi image is an array of size 213 * 162. In order to facilitate comparisons,
all the smaller images were zoomed back to the original size (the method
used for zooming is discussed in Section 2.4.4). This is somewhat equivalent to
“getting closer” to the smaller images so that we can make comparable state-
ments about visible details.
There are some small visual differences between Figs. 2.20(a) and (b), the
most notable being a slight distortion in the large black needle. For the most
part, however, Fig. 2.20(b) is quite acceptable. In fact, 300 dpi is the typical
minimum image spatial resolution used for book publishing, so one would
not expect to see much difference here. Figure 2.20(c) begins to show visible
degradation (see, for example, the round edges of the chronometer and the
small needle pointing to 60 on the right side). Figure 2.20(d) shows degrada-
tion that is visible in most features of the image. As we discuss in Section
4.5.4, when printing at such low resolutions, the printing and publishing in-
dustry uses a number of “tricks” (such as locally varying the pixel size) to
produce much better results than those in Fig. 2.20(d). Also, as we show in
Section 2.4.4, it is possible to improve on the results of Fig. 2.20 by the choice
of interpolation method used. ■
2.4 ■ Image Sampling and Quantization 61

a b
c d
FIGURE 2.20 Typical effects of reducing spatial resolution. Images shown at: (a) 1250
dpi, (b) 300 dpi, (c) 150 dpi, and (d) 72 dpi. The thin black borders were added for
clarity. They are not part of the data.
62 Chapter 2 ■ Digital Image Fundamentals

EXAMPLE 2.3: ■ In this example, we keep the number of samples constant and reduce the
Typical effects of number of intensity levels from 256 to 2, in integer powers of 2. Figure 2.21(a)
varying the
is a 452 * 374 CT projection image, displayed with k = 8 (256 intensity levels).
number of
intensity levels in Images such as this are obtained by fixing the X-ray source in one position,
a digital image. thus producing a 2-D image in any desired direction. Projection images are
used as guides to set up the parameters for a CT scanner, including tilt, number
of slices, and range.
Figures 2.21(b) through (h) were obtained by reducing the number of bits
from k = 7 to k = 1 while keeping the image size constant at 452 * 374 pixels.
The 256-, 128-, and 64-level images are visually identical for all practical pur-
poses. The 32-level image in Fig. 2.21(d), however, has an imperceptible set of

a b
c d
FIGURE 2.21
(a) 452 * 374,
256-level image.
(b)–(d) Image
displayed in 128,
64, and 32
intensity levels,
while keeping the
image size
constant.
2.4 ■ Image Sampling and Quantization 63

very fine ridge-like structures in areas of constant or nearly constant intensity


(particularly in the skull). This effect, caused by the use of an insufficient num-
ber of intensity levels in smooth areas of a digital image, is called false con-
touring, so called because the ridges resemble topographic contours in a map.
False contouring generally is quite visible in images displayed using 16 or less
uniformly spaced intensity levels, as the images in Figs. 2.21(e) through (h) show.
As a very rough rule of thumb, and assuming integer powers of 2 for conve-
nience, images of size 256 * 256 pixels with 64 intensity levels and printed on a
size format on the order of 5 * 5 cm are about the lowest spatial and intensity
resolution images that can be expected to be reasonably free of objectionable
sampling checkerboards and false contouring. ■

e f
g h

FIGURE 2.21
(Continued)
(e)–(h) Image
displayed in 16, 8,
4, and 2 intensity
levels. (Original
courtesy of
Dr. David R.
Pickens,
Department of
Radiology &
Radiological
Sciences,
Vanderbilt
University
Medical Center.)
64 Chapter 2 ■ Digital Image Fundamentals

a b c
FIGURE 2.22 (a) Image with a low level of detail. (b) Image with a medium level of detail. (c) Image with a
relatively large amount of detail. (Image (b) courtesy of the Massachusetts Institute of Technology.)

The results in Examples 2.2 and 2.3 illustrate the effects produced on image
quality by varying N and k independently. However, these results only partially
answer the question of how varying N and k affects images because we have not
considered yet any relationships that might exist between these two parame-
ters. An early study by Huang [1965] attempted to quantify experimentally the
effects on image quality produced by varying N and k simultaneously. The ex-
periment consisted of a set of subjective tests. Images similar to those shown in
Fig. 2.22 were used. The woman’s face is representative of an image with rela-
tively little detail; the picture of the cameraman contains an intermediate
amount of detail; and the crowd picture contains, by comparison, a large amount
of detail.
Sets of these three types of images were generated by varying N and k, and
observers were then asked to rank them according to their subjective quality.
Results were summarized in the form of so-called isopreference curves in the
Nk-plane. (Figure 2.23 shows average isopreference curves representative of
curves corresponding to the images in Fig. 2.22.) Each point in the Nk-plane
represents an image having values of N and k equal to the coordinates of that
point. Points lying on an isopreference curve correspond to images of equal
subjective quality. It was found in the course of the experiments that the iso-
preference curves tended to shift right and upward, but their shapes in each of
the three image categories were similar to those in Fig. 2.23. This is not unex-
pected, because a shift up and right in the curves simply means larger values
for N and k, which implies better picture quality.
The key point of interest in the context of the present discussion is that iso-
preference curves tend to become more vertical as the detail in the image in-
creases. This result suggests that for images with a large amount of detail
only a few intensity levels may be needed. For example, the isopreference
curve in Fig. 2.23 corresponding to the crowd is nearly vertical. This indicates
that, for a fixed value of N, the perceived quality for this type of image is
2.4 ■ Image Sampling and Quantization 65

FIGURE 2.23
Typical
isopreference
5 curves for the
three types of
images in
Fig. 2.22.
Face
k
Cameraman

Crowd
4

32 64 128 256
N

nearly independent of the number of intensity levels used (for the range of in-
tensity levels shown in Fig. 2.23). It is of interest also to note that perceived
quality in the other two image categories remained the same in some intervals
in which the number of samples was increased, but the number of intensity
levels actually decreased. The most likely reason for this result is that a de-
crease in k tends to increase the apparent contrast, a visual effect that humans
often perceive as improved quality in an image.

2.4.4 Image Interpolation


Interpolation is a basic tool used extensively in tasks such as zooming, shrink-
ing, rotating, and geometric corrections. Our principal objective in this section
is to introduce interpolation and apply it to image resizing (shrinking and
zooming), which are basically image resampling methods. Uses of interpola-
tion in applications such as rotation and geometric corrections are discussed in
Section 2.6.5. We also return to this topic in Chapter 4, where we discuss image
resampling in more detail.
Fundamentally, interpolation is the process of using known data to estimate
values at unknown locations. We begin the discussion of this topic with a sim-
ple example. Suppose that an image of size 500 * 500 pixels has to be en-
larged 1.5 times to 750 * 750 pixels. A simple way to visualize zooming is to
create an imaginary 750 * 750 grid with the same pixel spacing as the original,
and then shrink it so that it fits exactly over the original image. Obviously, the
pixel spacing in the shrunken 750 * 750 grid will be less than the pixel spacing
in the original image. To perform intensity-level assignment for any point in
the overlay, we look for its closest pixel in the original image and assign the in-
tensity of that pixel to the new pixel in the 750 * 750 grid. When we are fin-
ished assigning intensities to all the points in the overlay grid, we expand it to
the original specified size to obtain the zoomed image.
66 Chapter 2 ■ Digital Image Fundamentals

The method just discussed is called nearest neighbor interpolation because it


assigns to each new location the intensity of its nearest neighbor in the original
image (pixel neighborhoods are discussed formally in Section 2.5). This ap-
proach is simple but, as we show later in this section, it has the tendency to
produce undesirable artifacts, such as severe distortion of straight edges. For
this reason, it is used infrequently in practice. A more suitable approach is
bilinear interpolation, in which we use the four nearest neighbors to estimate
the intensity at a given location. Let (x, y) denote the coordinates of the loca-
tion to which we want to assign an intensity value (think of it as a point of the
grid described previously), and let v(x, y) denote that intensity value. For bi-
linear interpolation, the assigned value is obtained using the equation

Contrary to what the v(x, y) = ax + by + cxy + d (2.4-6)


name suggests, note that
bilinear interpolation is
not linear because of the
where the four coefficients are determined from the four equations in four un-
xy term. knowns that can be written using the four nearest neighbors of point (x, y). As
you will see shortly, bilinear interpolation gives much better results than near-
est neighbor interpolation, with a modest increase in computational burden.
The next level of complexity is bicubic interpolation, which involves the six-
teen nearest neighbors of a point. The intensity value assigned to point (x, y) is
obtained using the equation
3 3
v(x, y) = a a a ij x iy j (2.4-7)
i=0 j=0

where the sixteen coefficients are determined from the sixteen equations in
sixteen unknowns that can be written using the sixteen nearest neighbors of
point (x, y). Observe that Eq. (2.4-7) reduces in form to Eq. (2.4-6) if the lim-
its of both summations in the former equation are 0 to 1. Generally, bicubic in-
terpolation does a better job of preserving fine detail than its bilinear
counterpart. Bicubic interpolation is the standard used in commercial image
editing programs, such as Adobe Photoshop and Corel Photopaint.

EXAMPLE 2.4: ■ Figure 2.24(a) is the same image as Fig. 2.20(d), which was obtained by re-
Comparison of ducing the resolution of the 1250 dpi image in Fig. 2.20(a) to 72 dpi (the size
interpolation shrank from the original size of 3692 * 2812 to 213 * 162 pixels) and then
approaches for
image shrinking zooming the reduced image back to its original size. To generate Fig. 2.20(d)
and zooming. we used nearest neighbor interpolation both to shrink and zoom the image. As
we commented before, the result in Fig. 2.24(a) is rather poor. Figures 2.24(b)
and (c) are the results of repeating the same procedure but using, respectively,
bilinear and bicubic interpolation for both shrinking and zooming. The result
obtained by using bilinear interpolation is a significant improvement over near-
est neighbor interpolation. The bicubic result is slightly sharper than the bilin-
ear image. Figure 2.24(d) is the same as Fig. 2.20(c), which was obtained using
nearest neighbor interpolation for both shrinking and zooming. We comment-
ed in discussing that figure that reducing the resolution to 150 dpi began show-
ing degradation in the image. Figures 2.24(e) and (f) show the results of using
2.4 ■ Image Sampling and Quantization 67

a b c
d e f
FIGURE 2.24 (a) Image reduced to 72 dpi and zoomed back to its original size (3692 * 2812 pixels) using
nearest neighbor interpolation. This figure is the same as Fig. 2.20(d). (b) Image shrunk and zoomed using
bilinear interpolation. (c) Same as (b) but using bicubic interpolation. (d)–(f) Same sequence, but shrinking
down to 150 dpi instead of 72 dpi [Fig. 2.24(d) is the same as Fig. 2.20(c)]. Compare Figs. 2.24(e) and (f),
especially the latter, with the original image in Fig. 2.20(a).

bilinear and bicubic interpolation, respectively, to shrink and zoom the image.
In spite of a reduction in resolution from 1250 to 150, these last two images
compare reasonably favorably with the original, showing once again the
power of these two interpolation methods. As before, bicubic interpolation
yielded slightly sharper results. ■
68 Chapter 2 ■ Digital Image Fundamentals

It is possible to use more neighbors in interpolation, and there are more


complex techniques, such as using splines and wavelets, that in some instances
can yield better results than the methods just discussed. While preserving fine
detail is an exceptionally important consideration in image generation for 3-D
graphics (Watt [1993], Shirley [2002]) and in medical image processing
(Lehmann et al. [1999]), the extra computational burden seldom is justifiable
for general-purpose digital image processing, where bilinear or bicubic inter-
polation typically are the methods of choice.

2.5 Some Basic Relationships between Pixels


In this section, we consider several important relationships between pixels in a
digital image. As mentioned before, an image is denoted by f(x, y). When refer-
ring in this section to a particular pixel, we use lowercase letters, such as p and q.

2.5.1 Neighbors of a Pixel


A pixel p at coordinates (x, y) has four horizontal and vertical neighbors whose
coordinates are given by
(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)
This set of pixels, called the 4-neighbors of p, is denoted by N4(p). Each pixel is
a unit distance from (x, y), and some of the neighbor locations of p lie outside
the digital image if (x, y) is on the border of the image. We deal with this issue
in Chapter 3.
The four diagonal neighbors of p have coordinates
(x + 1, y + 1), (x + 1, y - 1), (x - 1, y + 1), (x - 1, y - 1)
and are denoted by ND(p). These points, together with the 4-neighbors, are called
the 8-neighbors of p, denoted by N8(p). As before, some of the neighbor locations
in ND(p) and N8(p) fall outside the image if (x, y) is on the border of the image.

2.5.2 Adjacency, Connectivity, Regions, and Boundaries


Let V be the set of intensity values used to define adjacency. In a binary image,
V = 516 if we are referring to adjacency of pixels with value 1. In a gray-scale
image, the idea is the same, but set V typically contains more elements. For exam-
ple, in the adjacency of pixels with a range of possible intensity values 0 to 255, set
V could be any subset of these 256 values. We consider three types of adjacency:
We use the symbols ¨
and ´ to denote set (a) 4-adjacency. Two pixels p and q with values from V are 4-adjacent if q is in
intersection and union,
respectively. Given sets
the set N4(p).
A and B, recall that their (b) 8-adjacency. Two pixels p and q with values from V are 8-adjacent if q is in
intersection is the set of
elements that are mem-
the set N8(p).
bers of both A and B. (c) m-adjacency (mixed adjacency). Two pixels p and q with values from V are
The union of these two
sets is the set of elements
m-adjacent if
that are members of A, (i) q is in N4(p), or
of B, or of both. We
discuss sets in more
(ii) q is in ND(p) and the set N4(p) ¨ N4(q) has no pixels whose values
detail in Section 2.6.4. are from V.
2.5 ■ Some Basic Relationships between Pixels 69

Mixed adjacency is a modification of 8-adjacency. It is introduced to eliminate the


ambiguities that often arise when 8-adjacency is used. For example, consider the
pixel arrangement shown in Fig. 2.25(a) for V = 516. The three pixels at the top
of Fig. 2.25(b) show multiple (ambiguous) 8-adjacency, as indicated by the dashed
lines. This ambiguity is removed by using m-adjacency, as shown in Fig. 2.25(c).
A (digital) path (or curve) from pixel p with coordinates (x, y) to pixel q
with coordinates (s, t) is a sequence of distinct pixels with coordinates
(x0, y0), (x1, y1), Á , (xn, yn)
where (x0, y0) = (x, y), (xn, yn) = (s, t), and pixels (xi, yi) and (xi - 1, yi - 1) are
adjacent for 1 … i … n. In this case, n is the length of the path. If
(x0, y0) = (xn, yn), the path is a closed path. We can define 4-, 8-, or m-paths
depending on the type of adjacency specified. For example, the paths shown in
Fig. 2.25(b) between the top right and bottom right points are 8-paths, and the
path in Fig. 2.25(c) is an m-path.
Let S represent a subset of pixels in an image. Two pixels p and q are said to
be connected in S if there exists a path between them consisting entirely of pix-
els in S. For any pixel p in S, the set of pixels that are connected to it in S is
called a connected component of S. If it only has one connected component,
then set S is called a connected set.
Let R be a subset of pixels in an image. We call R a region of the image if R
is a connected set. Two regions, Ri and Rj are said to be adjacent if their union
forms a connected set. Regions that are not adjacent are said to be disjoint. We
consider 4- and 8-adjacency when referring to regions. For our definition to
make sense, the type of adjacency used must be specified. For example, the two
regions (of 1s) in Fig. 2.25(d) are adjacent only if 8-adjacency is used (according
to the definition in the previous paragraph, a 4-path between the two regions
does not exist, so their union is not a connected set).

0 1 1 0 1 1 0 1 1
0 1 0 0 1 0 0 1 0
0 0 1 0 0 1 0 0 1

1 1 1 0 0 0 0 0 0 0 0
1 0 1 Ri 0 1 1 0 0 0 1 0
0 1 0 0 1 1 0 0 0 1 0
0 0 1 0 1 1 1 0 0 1 0
1 1 1 Rj 0 1 1 1 0 0 1 0
1 1 1 0 0 0 0 0 0 0 0

a b c
d e f
FIGURE 2.25 (a) An arrangement of pixels. (b) Pixels that are 8-adjacent (adjacency is
shown by dashed lines; note the ambiguity). (c) m-adjacency. (d) Two regions (of 1s) that
are adjacent if 8-adjecency is used. (e) The circled point is part of the boundary of the
1-valued pixels only if 8-adjacency between the region and background is used. (f) The
inner boundary of the 1-valued region does not form a closed path, but its outer
boundary does.
70 Chapter 2 ■ Digital Image Fundamentals

Suppose that an image contains K disjoint regions, Rk, k = 1, 2, Á , K,


none of which touches the image border.† Let Ru denote the union of all the K
regions, and let (Ru)c denote its complement (recall that the complement of a
set S is the set of points that are not in S). We call all the points in Ru the
foreground, and all the points in (Ru)c the background of the image.
The boundary (also called the border or contour) of a region R is the set of
points that are adjacent to points in the complement of R. Said another way,
the border of a region is the set of pixels in the region that have at least one
background neighbor. Here again, we must specify the connectivity being
used to define adjacency. For example, the point circled in Fig. 2.25(e) is not a
member of the border of the 1-valued region if 4-connectivity is used between
the region and its background. As a rule, adjacency between points in a region
and its background is defined in terms of 8-connectivity to handle situations
like this.
The preceding definition sometimes is referred to as the inner border of
the region to distinguish it from its outer border, which is the corresponding
border in the background. This distinction is important in the development of
border-following algorithms. Such algorithms usually are formulated to fol-
low the outer boundary in order to guarantee that the result will form a
closed path. For instance, the inner border of the 1-valued region in Fig.
2.25(f) is the region itself. This border does not satisfy the definition of a
closed path given earlier. On the other hand, the outer border of the region
does form a closed path around the region.
If R happens to be an entire image (which we recall is a rectangular set of
pixels), then its boundary is defined as the set of pixels in the first and last rows
and columns of the image. This extra definition is required because an image
has no neighbors beyond its border. Normally, when we refer to a region, we
are referring to a subset of an image, and any pixels in the boundary of the
region that happen to coincide with the border of the image are included im-
plicitly as part of the region boundary.
The concept of an edge is found frequently in discussions dealing with re-
gions and boundaries. There is a key difference between these concepts, how-
ever. The boundary of a finite region forms a closed path and is thus a
“global” concept. As discussed in detail in Chapter 10, edges are formed from
pixels with derivative values that exceed a preset threshold. Thus, the idea of
an edge is a “local” concept that is based on a measure of intensity-level dis-
continuity at a point. It is possible to link edge points into edge segments, and
sometimes these segments are linked in such a way that they correspond to
boundaries, but this is not always the case. The one exception in which edges
and boundaries correspond is in binary images. Depending on the type of
connectivity and edge operators used (we discuss these in Chapter 10), the
edge extracted from a binary region will be the same as the region boundary.


We make this assumption to avoid having to deal with special cases. This is done without loss of gener-
ality because if one or more regions touch the border of an image, we can simply pad the image with a
1-pixel-wide border of background values.
2.5 ■ Some Basic Relationships between Pixels 71

This is intuitive. Conceptually, until we arrive at Chapter 10, it is helpful to


think of edges as intensity discontinuities and boundaries as closed paths.

2.5.3 Distance Measures


For pixels p, q, and z, with coordinates (x, y), (s, t), and (v, w), respectively, D
is a distance function or metric if
(a) D(p, q) Ú 0 (D(p, q) = 0 iff p = q),
(b) D(p, q) = D(q, p), and
(c) D(p, z) … D(p, q) + D(q, z).
The Euclidean distance between p and q is defined as
De(p, q) = C(x - s)2 + (y - t)2 D
1
2
(2.5-1)
For this distance measure, the pixels having a distance less than or equal to
some value r from (x, y) are the points contained in a disk of radius r centered
at (x, y).
The D4 distance (called the city-block distance) between p and q is defined as
D4(p, q) = ƒ x - s ƒ + ƒ y - t ƒ (2.5-2)
In this case, the pixels having a D4 distance from (x, y) less than or equal to
some value r form a diamond centered at (x, y). For example, the pixels with
D4 distance … 2 from (x, y) (the center point) form the following contours of
constant distance:
2
2 1 2
2 1 0 1 2
2 1 2
2

The pixels with D4 = 1 are the 4-neighbors of (x, y).


The D8 distance (called the chessboard distance) between p and q is defined as
D8(p, q) = max( ƒ x - s ƒ , ƒ y - t ƒ ) (2.5-3)
In this case, the pixels with D8 distance from (x, y) less than or equal to some
value r form a square centered at (x, y). For example, the pixels with
D8 distance … 2 from (x, y) (the center point) form the following contours of
constant distance:
2 2 2 2 2
2 1 1 1 2
2 1 0 1 2
2 1 1 1 2
2 2 2 2 2
The pixels with D8 = 1 are the 8-neighbors of (x, y).
72 Chapter 2 ■ Digital Image Fundamentals

Note that the D4 and D8 distances between p and q are independent of any
paths that might exist between the points because these distances involve only
the coordinates of the points. If we elect to consider m-adjacency, however, the
Dm distance between two points is defined as the shortest m-path between the
points. In this case, the distance between two pixels will depend on the values
of the pixels along the path, as well as the values of their neighbors. For in-
stance, consider the following arrangement of pixels and assume that p, p2, and
p4 have value 1 and that p1 and p3 can have a value of 0 or 1:
p3 p4
p1 p2
p
Suppose that we consider adjacency of pixels valued 1 (i.e., V = 516). If p1
and p3 are 0, the length of the shortest m-path (the Dm distance) between p
and p4 is 2. If p1 is 1, then p2 and p will no longer be m-adjacent (see the defi-
nition of m-adjacency) and the length of the shortest m-path becomes 3 (the
path goes through the points pp1p2p4). Similar comments apply if p3 is 1 (and
p1 is 0); in this case, the length of the shortest m-path also is 3. Finally, if both
p1 and p3 are 1, the length of the shortest m-path between p and p4 is 4. In this
case, the path goes through the sequence of points pp1p2p3p4.

2.6 An Introduction to the Mathematical Tools Used


in Digital Image Processing
This section has two principal objectives: (1) to introduce you to the various
Before proceeding, you mathematical tools we use throughout the book; and (2) to help you begin de-
may find it helpful to
download and study the veloping a “feel” for how these tools are used by applying them to a variety of
review material available basic image-processing tasks, some of which will be used numerous times in
in the Tutorials section of
the book Web site. The subsequent discussions. We expand the scope of the tools and their application
review covers introduc- as necessary in the following chapters.
tory material on matrices
and vectors, linear sys-
tems, set theory, and 2.6.1 Array versus Matrix Operations
probability.
An array operation involving one or more images is carried out on a pixel-by-
pixel basis. We mentioned earlier in this chapter that images can be viewed
equivalently as matrices. In fact, there are many situations in which opera-
tions between images are carried out using matrix theory (see Section 2.6.6).
It is for this reason that a clear distinction must be made between array and
matrix operations. For example, consider the following 2 * 2 images:

a11 a12 b11 b12


Ba a22 R and B R
21 b21 b22

The array product of these two images is

a11 a12 b11 b12 a11b11 a12b12


Ba a22 R B b21 b22
R = Ba b a22b22
R
21 21 21
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 73

On the other hand, the matrix product is given by

a11 a12 b11 b12 a11b11 + a12b21 a11b12 + a12b22


Ba a22 R B b21 b22
R = B
a21b11 + a22b21 a21b12 + a22b22
R
21

We assume array operations throughout the book, unless stated otherwise.


For example, when we refer to raising an image to a power, we mean that
each individual pixel is raised to that power; when we refer to dividing an
image by another, we mean that the division is between corresponding pixel
pairs, and so on.

2.6.2 Linear versus Nonlinear Operations


One of the most important classifications of an image-processing method is
whether it is linear or nonlinear. Consider a general operator, H, that produces
an output image, g(x, y), for a given input image, f (x, y):

H C f(x, y) D = g(x, y) (2.6-1)

H is said to be a linear operator if

H C ai fi (x, y) + aj fj (x, y) D = ai H C fi (x, y) D + aj H C fj (x, y) D


(2.6-2)
= ai gi (x, y) + aj gj (x, y)

where a i , aj , fi (x, y), and fj (x, y) are arbitrary constants and images (of the
same size), respectively. Equation (2.6-2) indicates that the output of a linear
operation due to the sum of two inputs is the same as performing the opera-
tion on the inputs individually and then summing the results. In addition, the
output of a linear operation to a constant times an input is the same as the out-
put of the operation due to the original input multiplied by that constant. The
first property is called the property of additivity and the second is called the
property of homogeneity.
As a simple example, suppose that H is the sum operator, ©; that is, the
function of this operator is simply to sum its inputs. To test for linearity, we
start with the left side of Eq. (2.6-2) and attempt to prove that it is equal to the
right side:

a C ai fi (x, y) + aj fj (x, y) D = a ai fi (x, y) + a aj fj (x, y)


These are array summa-
tions, not the sums of all
the elements of the
images. As such, the sum
= ai a fi (x, y) + aj a fj (x, y) of a single image is the
image itself.

= ai gi (x, y) + aj gj (x, y)

where the first step follows from the fact that summation is distributive. So, an
expansion of the left side is equal to the right side of Eq. (2.6-2), and we con-
clude that the sum operator is linear.
74 Chapter 2 ■ Digital Image Fundamentals

On the other hand, consider the max operation, whose function is to find
the maximum value of the pixels in an image. For our purposes here, the sim-
plest way to prove that this operator is nonlinear, is to find an example that
fails the test in Eq. (2.6-2). Consider the following two images

0 2 6 5
f1 = B R and f2 = B R
2 3 4 7

and suppose that we let a1 = 1 and a2 = -1. To test for linearity, we again
start with the left side of Eq. (2.6-2):

0 2 6 5 -6 -3
max b (1) B R + (-1) B R r = max b B Rr
2 3 4 7 -2 -4

= -2
Working next with the right side, we obtain

0 2 6 5
(1) max b B R r + (-1) max b B R r = 3 + (-1)7
2 3 4 7

= -4

The left and right sides of Eq. (2.6-2) are not equal in this case, so we have
proved that in general the max operator is nonlinear.
As you will see in the next three chapters, especially in Chapters 4 and 5, lin-
ear operations are exceptionally important because they are based on a large
body of theoretical and practical results that are applicable to image process-
ing. Nonlinear systems are not nearly as well understood, so their scope of ap-
plication is more limited. However, you will encounter in the following
chapters several nonlinear image processing operations whose performance
far exceeds what is achievable by their linear counterparts.

2.6.3 Arithmetic Operations


Arithmetic operations between images are array operations which, as discussed
in Section 2.6.1, means that arithmetic operations are carried out between cor-
responding pixel pairs. The four arithmetic operations are denoted as

s(x, y) = f(x, y) + g(x, y)


d(x, y) = f(x, y) - g(x, y)
(2.6-3)
p(x, y) = f(x, y) * g(x, y)
v(x, y) = f(x, y) , g(x, y)

It is understood that the operations are performed between corresponding


pixel pairs in f and g for x = 0, 1, 2, Á , M - 1 and y = 0, 1, 2, Á , N - 1
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 75

where, as usual, M and N are the row and column sizes of the images. Clearly,
s, d, p, and v are images of size M * N also. Note that image arithmetic in the
manner just defined involves images of the same size. The following examples
are indicative of the important role played by arithmetic operations in digital
image processing.

■ Let g(x, y) denote a corrupted image formed by the addition of noise, EXAMPLE 2.5:
h(x, y), to a noiseless image f(x, y); that is, Addition
(averaging) of
noisy images for
g(x, y) = f(x, y) + h(x, y) (2.6-4) noise reduction.

where the assumption is that at every pair of coordinates (x, y) the noise is un-
correlated† and has zero average value. The objective of the following proce-
dure is to reduce the noise content by adding a set of noisy images, 5gi (x, y)6.
This is a technique used frequently for image enhancement.
If the noise satisfies the constraints just stated, it can be shown (Problem 2.20)
that if an image g(x, y) is formed by averaging K different noisy images,

1 K
K ia
g(x, y) = gi (x, y) (2.6-5)
=1

then it follows that

E5g(x, y)6 = f(x, y) (2.6-6)

and

1 2
sq2g(x,y) = s (2.6-7)
K h(x,y)
where E5g(x, y)6 is the expected value of g, and sq2g(x,y) and sh(x,y)2
are the
variances of g and h, respectively, all at coordinates (x, y). The standard devia-
tion (square root of the variance) at any point in the average image is
1
sqg(x,y) = sh(x,y) (2.6-8)
2K
As K increases, Eqs. (2.6-7) and (2.6-8) indicate that the variability (as measured
by the variance or the standard deviation) of the pixel values at each location
(x, y) decreases. Because E5g(x, y)6 = f(x, y), this means that g(x, y) ap-
proaches f(x, y) as the number of noisy images used in the averaging process
increases. In practice, the images gi (x, y) must be registered (aligned) in order to
avoid the introduction of blurring and other artifacts in the output image.


Recall that the variance of a random variable z with mean m is defined as E[(z - m)2], where E5 # 6 is
the expected value of the argument. The covariance of two random variables zi and zj is defined as
E[(zi - mi)(zj - mj)]. If the variables are uncorrelated, their covariance is 0.
76 Chapter 2 ■ Digital Image Fundamentals

a b c
d e f
FIGURE 2.26 (a) Image of Galaxy Pair NGC 3314 corrupted by additive Gaussian noise. (b)–(f) Results of
averaging 5, 10, 20, 50, and 100 noisy images, respectively. (Original image courtesy of NASA.)

The images shown in this An important application of image averaging is in the field of astronomy,
example are from a
galaxy pair called NGC where imaging under very low light levels frequently causes sensor noise to
3314, taken by NASA’s render single images virtually useless for analysis. Figure 2.26(a) shows an 8-bit
Hubble Space Telescope.
NGC 3314 lies about 140 image in which corruption was simulated by adding to it Gaussian noise with
million light-years from zero mean and a standard deviation of 64 intensity levels. This image, typical of
Earth, in the direction of
the southern-hemisphere noisy images taken under low light conditions, is useless for all practical pur-
constellation Hydra. The poses. Figures 2.26(b) through (f) show the results of averaging 5, 10, 20, 50, and
bright stars forming a
pinwheel shape near the 100 images, respectively. We see that the result in Fig. 2.26(e), obtained with
center of the front galaxy K = 50, is reasonably clean. The image Fig. 2.26(f), resulting from averaging
were formed from inter-
stellar gas and dust. 100 noisy images, is only a slight improvement over the image in Fig. 2.26(e).
Addition is a discrete version of continuous integration. In astronomical
observations, a process equivalent to the method just described is to use the in-
tegrating capabilities of CCD (see Section 2.3.3) or similar sensors for noise
reduction by observing the same scene over long periods of time. Cooling also
is used to reduce sensor noise.The net effect, however, is analogous to averaging
a set of noisy digital images. ■
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 77

■ A frequent application of image subtraction is in the enhancement of EXAMPLE 2.6:


differences between images. For example, the image in Fig. 2.27(b) was obtained Image subtraction
for enhancing
by setting to zero the least-significant bit of every pixel in Fig. 2.27(a). Visually,
differences.
these images are indistinguishable. However, as Fig. 2.27(c) shows, subtracting
one image from the other clearly shows their differences. Black (0) values in
this difference image indicate locations where there is no difference between
the images in Figs. 2.27(a) and (b).
As another illustration, we discuss briefly an area of medical imaging called
mask mode radiography, a commercially successful and highly beneficial use
of image subtraction. Consider image differences of the form

g(x, y) = f(x, y) - h(x, y) (2.6-9) Change detection via


image subtraction is used
also in image segmenta-
In this case h(x, y), the mask, is an X-ray image of a region of a patient’s body tion, which is the topic of
captured by an intensified TV camera (instead of traditional X-ray film) locat- Chapter 10.

ed opposite an X-ray source. The procedure consists of injecting an X-ray con-


trast medium into the patient’s bloodstream, taking a series of images called
live images [samples of which are denoted as f(x, y)] of the same anatomical
region as h(x, y), and subtracting the mask from the series of incoming live im-
ages after injection of the contrast medium. The net effect of subtracting the
mask from each sample live image is that the areas that are different between
f(x, y) and h(x, y) appear in the output image, g(x, y), as enhanced detail.
Because images can be captured at TV rates, this procedure in essence gives
a movie showing how the contrast medium propagates through the various
arteries in the area being observed.
Figure 2.28(a) shows a mask X-ray image of the top of a patient’s head prior
to injection of an iodine medium into the bloodstream, and Fig. 2.28(b) is a
sample of a live image taken after the medium was injected. Figure 2.28(c) is

a b c
FIGURE 2.27 (a) Infrared image of the Washington, D.C. area. (b) Image obtained by setting to zero the least
significant bit of every pixel in (a). (c) Difference of the two images, scaled to the range [0, 255] for clarity.
78 Chapter 2 ■ Digital Image Fundamentals

a b
c d
FIGURE 2.28
Digital
subtraction
angiography.
(a) Mask image.
(b) A live image.
(c) Difference
between (a) and
(b). (d) Enhanced
difference image.
(Figures (a) and
(b) courtesy of
The Image
Sciences Institute,
University
Medical Center,
Utrecht, The
Netherlands.)

the difference between (a) and (b). Some fine blood vessel structures are visi-
ble in this image. The difference is clear in Fig. 2.28(d), which was obtained by
enhancing the contrast in (c) (we discuss contrast enhancement in the next
chapter). Figure 2.28(d) is a clear “map” of how the medium is propagating
through the blood vessels in the subject’s brain. ■

EXAMPLE 2.7: ■ An important application of image multiplication (and division) is shading


Using image correction. Suppose that an imaging sensor produces images that can be mod-
multiplication and eled as the product of a “perfect image,” denoted by f(x, y), times a shading
division for
shading function, h(x, y); that is, g(x, y) = f(x, y)h(x, y). If h(x, y) is known, we can
correction. obtain f(x, y) by multiplying the sensed image by the inverse of h(x, y) (i.e., di-
viding g by h). If h(x, y) is not known, but access to the imaging system is pos-
sible, we can obtain an approximation to the shading function by imaging a
target of constant intensity. When the sensor is not available, we often can es-
timate the shading pattern directly from the image, as we discuss in Section
9.6. Figure 2.29 shows an example of shading correction.
Another common use of image multiplication is in masking, also called
region of interest (ROI), operations. The process, illustrated in Fig. 2.30, con-
sists simply of multiplying a given image by a mask image that has 1s in the
ROI and 0s elsewhere. There can be more than one ROI in the mask image,
and the shape of the ROI can be arbitrary, although rectangular shapes are
used frequently for ease of implementation. ■

A few comments about implementing image arithmetic operations are in


order before we leave this section. In practice, most images are displayed
using 8 bits (even 24-bit color images consist of three separate 8-bit channels).
Thus, we expect image values to be in the range from 0 to 255. When images
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 79

a b c
FIGURE 2.29 Shading correction. (a) Shaded SEM image of a tungsten filament and support, magnified
approximately 130 times. (b) The shading pattern. (c) Product of (a) by the reciprocal of (b). (Original image
courtesy of Michael Shaffer, Department of Geological Sciences, University of Oregon, Eugene.)

are saved in a standard format, such as TIFF or JPEG, conversion to this


range is automatic. However, the approach used for the conversion depends
on the system used. For example, the values in the difference of two 8-bit im-
ages can range from a minimum of -255 to a maximum of 255, and the values
of a sum image can range from 0 to 510. Many software packages simply set
all negative values to 0 and set to 255 all values that exceed this limit when
converting images to 8 bits. Given an image f, an approach that guarantees
that the full range of an arithmetic operation between images is “captured”
into a fixed number of bits is as follows. First, we perform the operation

fm = f - min(f) (2.6-10)

a b c
FIGURE 2.30 (a) Digital dental X-ray image. (b) ROI mask for isolating teeth with fillings (white corresponds to
1 and black corresponds to 0). (c) Product of (a) and (b).
80 Chapter 2 ■ Digital Image Fundamentals

which creates an image whose minimum value is 0. Then, we perform the


operation
fs = K C fm>max( fm ) D (2.6-11)
which creates a scaled image, fs, whose values are in the range [0, K]. When
working with 8-bit images, setting K = 255 gives us a scaled image whose in-
tensities span the full 8-bit scale from 0 to 255. Similar comments apply to 16-bit
images or higher. This approach can be used for all arithmetic operations.
When performing division, we have the extra requirement that a small number
should be added to the pixels of the divisor image to avoid division by 0.

2.6.4 Set and Logical Operations


In this section, we introduce briefly some important set and logical operations.
We also introduce the concept of a fuzzy set.

Basic set operations


Let A be a set composed of ordered pairs of real numbers. If a = (a1, a2) is an
element of A, then we write
aHA (2.6-12)
Similarly, if a is not an element of A, we write
axA (2.6-13)
The set with no elements is called the null or empty set and is denoted by the
symbol .
A set is specified by the contents of two braces: 5 # 6. For example, when we
write an expression of the form C = 5w ƒ w = -d, d H D6, we mean that set C
is the set of elements, w, such that w is formed by multiplying each of the ele-
ments of set D by -1. One way in which sets are used in image processing is to
let the elements of sets be the coordinates of pixels (ordered pairs of integers)
representing regions (objects) in an image.
If every element of a set A is also an element of a set B, then A is said to be
a subset of B, denoted as
A8B (2.6-14)
The union of two sets A and B, denoted by
C = A´B (2.6-15)
is the set of elements belonging to either A, B, or both. Similarly, the
intersection of two sets A and B, denoted by
D = A¨B (2.6-16)
is the set of elements belonging to both A and B.Two sets A and B are said to be
disjoint or mutually exclusive if they have no common elements, in which case,
A¨B =  (2.6-17)
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 81

The set universe, U, is the set of all elements in a given application. By defi-
nition, all set elements in a given application are members of the universe de-
fined for that application. For example, if you are working with the set of real
numbers, then the set universe is the real line, which contains all the real num-
bers. In image processing, we typically define the universe to be the rectangle
containing all the pixels in an image.
The complement of a set A is the set of elements that are not in A:

Ac = 5w ƒ w x A6 (2.6-18)

The difference of two sets A and B, denoted A - B, is defined as

A - B = 5w ƒ w H A, w x B6 = A ¨ B c (2.6-19)

We see that this is the set of elements that belong to A, but not to B. We could,
for example, define Ac in terms of U and the set difference operation:
Ac = U - A.
Figure 2.31 illustrates the preceding concepts, where the universe is the set
of coordinates contained within the rectangle shown, and sets A and B are the
sets of coordinates contained within the boundaries shown. The result of the
set operation indicated in each figure is shown in gray.†
In the preceding discussion, set membership is based on position (coordi-
nates). An implicit assumption when working with images is that the intensity
of all pixels in the sets is the same, as we have not defined set operations in-
volving intensity values (e.g., we have not specified what the intensities in the
intersection of two sets is). The only way that the operations illustrated in Fig.
2.31 can make sense is if the images containing the sets are binary, in which case
we can talk about set membership based on coordinates, the assumption being
that all member of the sets have the same intensity. We discuss this in more de-
tail in the following subsection.
When dealing with gray-scale images, the preceding concepts are not ap-
plicable, because we have to specify the intensities of all the pixels resulting
from a set operation. In fact, as you will see in Sections 3.8 and 9.6, the union
and intersection operations for gray-scale values usually are defined as the
max and min of corresponding pixel pairs, respectively, while the complement
is defined as the pairwise differences between a constant and the intensity of
every pixel in an image. The fact that we deal with corresponding pixel pairs
tells us that gray-scale set operations are array operations, as defined in
Section 2.6.1. The following example is a brief illustration of set operations in-
volving gray-scale images. We discuss these concepts further in the two sec-
tions mentioned above.


The operations in Eqs. (2.6-12)–(2.6-19) are the basis for the algebra of sets, which starts with properties
such as the commutative laws: A ´ B = B ´ A and A ¨ B = B ¨ A, and from these develops a broad
theory based on set operations. A treatment of the algebra of sets is beyond the scope of the present dis-
cussion, but you should be aware of its existence.
82 Chapter 2 ■ Digital Image Fundamentals

a b c
d e
FIGURE 2.31
(a) Two sets of
coordinates, A and B,
in 2-D space. (b) The A
union of A and B. A B A B
(c) The intersection B
of A and B. (d) The
complement of A. U
(e) The difference
between A and B. In
(b)–(e) the shaded
areas represent the
members of the set
operation indicated.
AB

Ac

EXAMPLE 2.8: ■ Let the elements of a gray-scale image be represented by a set A whose
Set operations elements are triplets of the form (x, y, z), where x and y are spatial coordi-
involving image nates and z denotes intensity, as mentioned in Section 2.4.2. We can define
the complement of A as the set Ac = 5(x, y, K - z) ƒ (x, y, z) H A6, which
intensities.
simply denotes the set of pixels of A whose intensities have been subtracted
from a constant K. This constant is equal to 2k - 1, where k is the number of
intensity bits used to represent z. Let A denote the 8-bit gray-scale image in
Fig. 2.32(a), and suppose that we want to form the negative of A using set

a b c
FIGURE 2.32 Set
operations
involving gray-
scale images.
(a) Original
image. (b) Image
negative obtained
using set
complementation.
(c) The union of
(a) and a constant
image.
(Original image
courtesy of G.E.
Medical Systems.)
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 83

operations. We simply form the set An = Ac = 5(x, y, 255 - z) ƒ (x, y, z) H A6.


Note that the coordinates are carried over, so An is an image of the same size
as A. Figure 2.32(b) shows the result.
The union of two gray-scale sets A and B may be defined as the set

A ´ B = e max(a, b) ƒ a H A, b H B f
z

That is, the union of two gray-scale sets (images) is an array formed from the
maximum intensity between pairs of spatially corresponding elements. Again,
note that coordinates carry over, so the union of A and B is an image of the
same size as these two images. As an illustration, suppose that A again repre-
sents the image in Fig. 2.32(a), and let B denote a rectangular array of the
same size as A, but in which all values of z are equal to 3 times the mean in-
tensity, m, of the elements of A. Figure 2.32(c) shows the result of performing
the set union, in which all values exceeding 3m appear as values from A and all
other pixels have value 3m, which is a mid-gray value. ■

Logical operations
When dealing with binary images, we can think of foreground (1-valued) and
background (0-valued) sets of pixels. Then, if we define regions (objects) as
being composed of foreground pixels, the set operations illustrated in Fig. 2.31
become operations between the coordinates of objects in a binary image.
When dealing with binary images, it is common practice to refer to union, in-
tersection, and complement as the OR, AND, and NOT logical operations,
where “logical” arises from logic theory in which 1 and 0 denote true and false,
respectively.
Consider two regions (sets) A and B composed of foreground pixels. The
OR of these two sets is the set of elements (coordinates) belonging either to A
or B or to both. The AND operation is the set of elements that are common to
A and B. The NOT operation of a set A is the set of elements not in A. Be-
cause we are dealing with images, if A is a given set of foreground pixels,
NOT(A) is the set of all pixels in the image that are not in A, these pixels
being background pixels and possibly other foreground pixels. We can think
of this operation as turning all elements in A to 0 (black) and all the elements
not in A to 1 (white). Figure 2.33 illustrates these operations. Note in the
fourth row that the result of the operation shown is the set of foreground pix-
els that belong to A but not to B, which is the definition of set difference in
Eq. (2.6-19). The last row in the figure is the XOR (exclusive OR) operation,
which is the set of foreground pixels belonging to A or B, but not both. Ob-
serve that the preceding operations are between regions, which clearly can be
irregular and of different sizes. This is as opposed to the gray-scale operations
discussed earlier, which are array operations and thus require sets whose spa-
tial dimensions are the same. That is, gray-scale set operations involve com-
plete images, as opposed to regions of images.
We need be concerned in theory only with the cability to implement the AND,
OR, and NOT logic operators because these three operators are functionally
84 Chapter 2 ■ Digital Image Fundamentals

FIGURE 2.33 NOT(A)


Illustration of NOT
logical operations
A
involving
foreground (A) AND (B)
(white) pixels.
Black represents AND
B
binary 0 s and
white binary 1s. A

The dashed lines


are shown for (A) OR (B)

reference only.
OR
They are not part
of the result.

(A) AND [NOT (B)]

AND-
NOT

(A) XOR (B)

XOR

complete. In other words, any other logic operator can be implemented by using
only these three basic functions, as in the fourth row of Fig. 2.33, where we im-
plemented the set difference operation using AND and NOT. Logic operations
are used extensively in image morphology, the topic of Chapter 9.

Fuzzy sets
The preceding set and logical results are crisp concepts, in the sense that ele-
ments either are or are not members of a set. This presents a serious limitation
in some applications. Consider a simple example. Suppose that we wish to cat-
egorize all people in the world as being young or not young. Using crisp sets,
let U denote the set of all people and let A be a subset of U, which we call the
set of young people. In order to form set A, we need a membership function
that assigns a value of 1 or 0 to every element (person) in U. If the value as-
signed to an element of U is 1, then that element is a member of A; otherwise
it is not. Because we are dealing with a bi-valued logic, the membership func-
tion simply defines a threshold at or below which a person is considered young,
and above which a person is considered not young. Suppose that we define as
young any person of age 20 or younger. We see an immediate difficulty. A per-
son whose age is 20 years and 1 sec would not be a member of the set of young
people. This limitation arises regardless of the age threshold we use to classify a
person as being young. What we need is more flexibility in what we mean by
“young,” that is, we need a gradual transition from young to not young. The the-
ory of fuzzy sets implements this concept by utilizing membership functions
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 85

that are gradual between the limit values of 1 (definitely young) to 0 (definite-
ly not young). Using fuzzy sets, we can make a statement such as a person being
50% young (in the middle of the transition between young and not young). In
other words, age is an imprecise concept, and fuzzy logic provides the tools to
deal with such concepts. We explore fuzzy sets in detail in Section 3.8.

2.6.5 Spatial Operations


Spatial operations are performed directly on the pixels of a given image. We
classify spatial operations into three broad categories: (1) single-pixel opera-
tions, (2) neighborhood operations, and (3) geometric spatial transformations.

Single-pixel operations
The simplest operation we perform on a digital image is to alter the values of
its individual pixels based on their intensity. This type of process may be ex-
pressed as a transformation function, T, of the form:
s = T(z) (2.6-20)
where z is the intensity of a pixel in the original image and s is the (mapped)
intensity of the corresponding pixel in the processed image. For example,
Fig. 2.34 shows the transformation used to obtain the negative of an 8-bit
image, such as the image in Fig. 2.32(b), which we obtained using set operations.
We discuss in Chapter 3 a number of techniques for specifying intensity trans-
formation functions.

Neighborhood operations
Let Sxy denote the set of coordinates of a neighborhood centered on an arbi-
trary point (x, y) in an image, f. Neighborhood processing generates a corres-
ponding pixel at the same coordinates in an output (processed) image, g, such
that the value of that pixel is determined by a specified operation involving the
pixels in the input image with coordinates in Sxy. For example, suppose that
the specified operation is to compute the average value of the pixels in a rec-
tangular neighborhood of size m * n centered on (x, y). The locations of pixels

s  T(z) FIGURE 2.34 Intensity


255
transformation
function used to
obtain the negative of
an 8-bit image. The
dashed arrows show
transformation of an
s0 arbitrary input
intensity value z0 into
its corresponding
output value s0.
z
0 z0 255
86 Chapter 2 ■ Digital Image Fundamentals

a b
c d n
FIGURE 2.35
Local averaging m
using (x, y) (x, y)
neighborhood The value of this pixel
processing. The Sxy is the average value of the
procedure is pixels in Sxy
illustrated in
(a) and (b) for a
rectangular
neighborhood.
(c) The aortic
angiogram
discussed in
Section 1.3.2. Image f Image g
(d) The result of
using Eq. (2.6-21)
with m = n = 41.
The images are of
size 790 * 686
pixels.

in this region constitute the set Sxy. Figures 2.35(a) and (b) illustrate the
process. We can express this operation in equation form as

1
g(x, y) = a f(r, c)
mn (r, c)HS
(2.6-21)
xy

where r and c are the row and column coordinates of the pixels whose coordi-
nates are members of the set Sxy. Image g is created by varying the coordi-
nates (x, y) so that the center of the neighborhood moves from pixel to pixel in
image f, and repeating the neighborhood operation at each new location. For
instance, the image in Fig. 2.35(d) was created in this manner using a neigh-
borhood of size 41 * 41. The net effect is to perform local blurring in the orig-
inal image. This type of process is used, for example, to eliminate small details
and thus render “blobs” corresponding to the largest regions of an image. We
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 87

discuss neighborhood processing in Chapters 3 and 5, and in several other


places in the book.

Geometric spatial transformations and image registration


Geometric transformations modify the spatial relationship between pixels in an
image. These transformations often are called rubber-sheet transformations be-
cause they may be viewed as analogous to “printing” an image on a sheet of
rubber and then stretching the sheet according to a predefined set of rules. In
terms of digital image processing, a geometric transformation consists of two
basic operations: (1) a spatial transformation of coordinates and (2) intensity
interpolation that assigns intensity values to the spatially transformed pixels.
The transformation of coordinates may be expressed as
(x, y) = T5(v, w)6 (2.6-22)
where (v, w) are pixel coordinates in the original image and (x, y) are the cor-
responding pixel coordinates in the transformed image. For example, the
transformation (x, y) = T5(v, w)6 = (v>2, w>2) shrinks the original image to
half its size in both spatial directions. One of the most commonly used spatial
coordinate transformations is the affine transform (Wolberg [1990]), which has
the general form

t11 t12 0
[x y 1] = [v w 1] T = [v w 1] C 21
t t22 0S (2.6-23)
t31 t32 1

This transformation can scale, rotate, translate, or sheer a set of coordinate


points, depending on the value chosen for the elements of matrix T. Table 2.2
illustrates the matrix values used to implement these transformations. The real
power of the matrix representation in Eq. (2.6-23) is that it provides the frame-
work for concatenating together a sequence of operations. For example, if we
want to resize an image, rotate it, and move the result to some location, we
simply form a 3 * 3 matrix equal to the product of the scaling, rotation, and
translation matrices from Table 2.2.
The preceding transformations relocate pixels on an image to new loca-
tions. To complete the process, we have to assign intensity values to those loca-
tions. This task is accomplished using intensity interpolation. We already
discussed this topic in Section 2.4.4. We began that section with an example of
zooming an image and discussed the issue of intensity assignment to new pixel
locations. Zooming is simply scaling, as detailed in the second row of Table 2.2,
and an analysis similar to the one we developed for zooming is applicable to
the problem of assigning intensity values to the relocated pixels resulting from
the other transformations in Table 2.2. As in Section 2.4.4, we consider nearest
neighbor, bilinear, and bicubic interpolation techniques when working with
these transformations.
In practice, we can use Eq. (2.6-23) in two basic ways. The first, called a
forward mapping, consists of scanning the pixels of the input image and, at
88 Chapter 2 ■ Digital Image Fundamentals

TABLE 2.2
Affine transformations based on Eq. (2.6-23).
Transformation Coordinate
Affine Matrix, T Example
Name Equations
Identity 1 0 0 xv
yw y
0 1 0
0 0 1
x

Scaling cx 0 0 x  cxv
0 cy 0 y  cyw
0 0 1

Rotation cos u sin u 0 x  v cos u  w sin u


sin u cos u 0 y  v cos u  w sin u
0 0 1

Translation 1 0 x  v  tx
0
0 1 0 y  w  ty
tx ty 1

Shear (vertical) 1 0 0 x  v  svw


sv 1 0 yw

0 0 1

Shear (horizontal) 1 sh 0 xv


0 1 0 y  shv  w

0 0 1

each location, (v, w), computing the spatial location, (x, y), of the correspond-
ing pixel in the output image using Eq. (2.6-23) directly. A problem with the
forward mapping approach is that two or more pixels in the input image can
be transformed to the same location in the output image, raising the question
of how to combine multiple output values into a single output pixel. In addi-
tion, it is possible that some output locations may not be assigned a pixel at all.
The second approach, called inverse mapping, scans the output pixel locations
and, at each location, (x, y), computes the corresponding location in the input
image using (v, w) = T-1(x, y). It then interpolates (using one of the tech-
niques discussed in Section 2.4.4) among the nearest input pixels to determine
the intensity of the output pixel value. Inverse mappings are more efficient to
implement than forward mappings and are used in numerous commercial im-
plementations of spatial transformations (for example, MATLAB uses this
approach).
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 89

a b c d
FIGURE 2.36 (a) A 300 dpi image of the letter T. (b) Image rotated 21° using nearest neighbor interpolation
to assign intensity values to the spatially transformed pixels. (c) Image rotated 21° using bilinear
interpolation. (d) Image rotated 21° using bicubic interpolation. The enlarged sections show edge detail for
the three interpolation approaches.

■ The objective of this example is to illustrate image rotation using an affine EXAMPLE 2.9:
transform. Figure 2.36(a) shows a 300 dpi image and Figs. 2.36(b)–(d) are the re- Image rotation
sults of rotating the original image by 21°, using nearest neighbor, bilinear, and and intensity
interpolation.
bicubic interpolation, respectively. Rotation is one of the most demanding geo-
metric transformations in terms of preserving straight-line features. As we see in
the figure, nearest neighbor interpolation produced the most jagged edges and, as
in Section 2.4.4, bilinear interpolation yielded significantly improved results. As
before, using bicubic interpolation produced slightly sharper results. In fact, if you
compare the enlarged detail in Figs. 2.36(c) and (d), you will notice in the middle
of the subimages that the number of vertical gray “blocks” that provide the in-
tensity transition from light to dark in Fig. 2.36(c) is larger than the correspond-
ing number of blocks in (d), indicting that the latter is a sharper edge. Similar
results would be obtained with the other spatial transformations in Table 2.2 that
require interpolation (the identity transformation does not, and neither does the
translation transformation if the increments are an integer number of pixels).
This example was implemented using the inverse mapping approach discussed in
the preceding paragraph. ■

Image registration is an important application of digital image processing


used to align two or more images of the same scene. In the preceding discus-
sion, the form of the transformation function required to achieve a desired
geometric transformation was known. In image registration, we have available
the input and output images, but the specific transformation that produced the
output image from the input generally is unknown. The problem, then, is to es-
timate the transformation function and then use it to register the two images.
To clarify terminology, the input image is the image that we wish to transform,
and what we call the reference image is the image against which we want to
register the input.
90 Chapter 2 ■ Digital Image Fundamentals

For example, it may be of interest to align (register) two or more images


taken at approximately the same time, but using different imaging systems,
such as an MRI (magnetic resonance imaging) scanner and a PET (positron
emission tomography) scanner. Or, perhaps the images were taken at different
times using the same instrument, such as satellite images of a given location
taken several days, months, or even years apart. In either case, combining the
images or performing quantitative analysis and comparisons between them re-
quires compensating for geometric distortions caused by differences in view-
ing angle, distance, and orientation; sensor resolution; shift in object positions;
and other factors.
One of the principal approaches for solving the problem just discussed is to
use tie points (also called control points), which are corresponding points
whose locations are known precisely in the input and reference images. There
are numerous ways to select tie points, ranging from interactively selecting
them to applying algorithms that attempt to detect these points automatically.
In some applications, imaging systems have physical artifacts (such as small
metallic objects) embedded in the imaging sensors. These produce a set of
known points (called reseau marks) directly on all images captured by the sys-
tem, which can be used as guides for establishing tie points.
The problem of estimating the transformation function is one of modeling.
For example, suppose that we have a set of four tie points each in an input and a
reference image. A simple model based on a bilinear approximation is given by

x = c1v + c2w + c3vw + c4 (2.6-24)

and
y = c5v + c6w + c7vw + c8 (2.6-25)

where, during the estimation phase, (v, w) and (x, y) are the coordinates of tie
points in the input and reference images, respectively. If we have four pairs of
corresponding tie points in both images, we can write eight equations using
Eqs. (2.6-24) and (2.6-25) and use them to solve for the eight unknown coeffi-
cients, c1, c2, Á , c8. These coefficients constitute the model that transforms
the pixels of one image into the locations of the pixels of the other to achieve
registration.
Once we have the coefficients, Eqs. (2.6-24) and (2.6-25) become our vehi-
cle for transforming all the pixels in the input image to generate the desired
new image, which, if the tie points were selected correctly, should be registered
with the reference image. In situations where four tie points are insufficient to
obtain satisfactory registration, an approach used frequently is to select a larger
number of tie points and then treat the quadrilaterals formed by groups of
four tie points as subimages. The subimages are processed as above, with all
the pixels within a quadrilateral being transformed using the coefficients de-
termined from those tie points. Then we move to another set of four tie points
and repeat the procedure until all quadrilateral regions have been processed.
Of course, it is possible to use regions that are more complex than quadrilater-
als and employ more complex models, such as polynomials fitted by least
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 91

squares algorithms. In general, the number of control points and sophistication


of the model required to solve a problem is dependent on the severity of the
geometric distortion. Finally, keep in mind that the transformation defined by
Eqs. (2.6-24) and (2.6-25), or any other model for that matter, simply maps the
spatial coordinates of the pixels in the input image. We still need to perform in-
tensity interpolation using any of the methods discussed previously to assign
intensity values to those pixels.

■ Figure 2.37(a) shows a reference image and Fig. 2.37(b) shows the same EXAMPLE 2.10:
image, but distorted geometrically by vertical and horizontal shear. Our objec- Image
tive is to use the reference image to obtain tie points and then use the tie registration.
points to register the images. The tie points we selected (manually) are shown
as small white squares near the corners of the images (we needed only four tie

a b
c d
FIGURE 2.37
Image
registration.
(a) Reference
image. (b) Input
(geometrically
distorted image).
Corresponding tie
points are shown
as small white
squares near the
corners.
(c) Registered
image (note the
errors in the
border).
(d) Difference
between (a) and
(c), showing more
registration
errors.
92 Chapter 2 ■ Digital Image Fundamentals

points because the distortion is linear shear in both directions). Figure 2.37(c)
shows the result of using these tie points in the procedure discussed in the pre-
ceding paragraphs to achieve registration. We note that registration was not
perfect, as is evident by the black edges in Fig. 2.37(c). The difference image in
Fig. 2.37(d) shows more clearly the slight lack of registration between the refer-
ence and corrected images.The reason for the discrepancies is error in the man-
ual selection of the tie points. It is difficult to achieve perfect matches for tie
points when distortion is so severe. ■

2.6.6 Vector and Matrix Operations


Multispectral image processing is a typical area in which vector and matrix op-
Consult the Tutorials sec-
tion in the book Web site erations are used routinely. For example, you will learn in Chapter 6 that color
for a brief tutorial on vec- images are formed in RGB color space by using red, green, and blue component
tors and matrices.
images, as Fig. 2.38 illustrates. Here we see that each pixel of an RGB image has
three components, which can be organized in the form of a column vector
z1
z = C z2 S (2.6-26)
z3

where z1 is the intensity of the pixel in the red image, and the other two ele-
ments are the corresponding pixel intensities in the green and blue images,
respectively. Thus an RGB color image of size M * N can be represented by
three component images of this size, or by a total of MN 3-D vectors. A general
multispectral case involving n component images (e.g., see Fig. 1.10) will result
in n-dimensional vectors. We use this type of vector representation in parts of
Chapters 6, 10, 11, and 12.
Once pixels have been represented as vectors we have at our disposal the
tools of vector-matrix theory. For example, the Euclidean distance, D, between
a pixel vector z and an arbitrary point a in n-dimensional space is defined as
the vector product
D(z, a) = C (z - a)T(z - a) D
1
2

(2.6-27)
= C (z1 - a 1) + (z2 - a 2) + Á + (zn - a n)2 D
1
2 2 2

FIGURE 2.38
Formation of a
vector from
corresponding
pixel values in
three RGB
component z1
images. z  z2
z3 Component image 3 (Blue)
Component image 2 (Green)

Component image 1 (Red)


2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 93

We see that this is a generalization of the 2-D Euclidean distance defined in


Eq. (2.5-1). Equation (2.6-27) sometimes is referred to as a vector norm, de-
noted by 7z  a 7. We will use distance computations numerous times in later
chapters.
Another important advantage of pixel vectors is in linear transformations,
represented as

w = A(z  a) (2.6-28)

where A is a matrix of size m * n and z and a are column vectors of size


n * 1. As you will learn later, transformations of this type have a number of
useful applications in image processing.
As noted in Eq. (2.4-2), entire images can be treated as matrices (or, equi-
valently, as vectors), a fact that has important implication in the solution of nu-
merous image processing problems. For example, we can express an image of
size M * N as a vector of dimension MN * 1 by letting the first row of the
image be the first N elements of the vector, the second row the next N ele-
ments, and so on. With images formed in this manner, we can express a broad
range of linear processes applied to an image by using the notation

g = Hf  n (2.6-29)

where f is an MN * 1 vector representing an input image, n is an MN * 1 vec-


tor representing an M * N noise pattern, g is an MN * 1 vector representing
a processed image, and H is an MN * MN matrix representing a linear process
applied to the input image (see Section 2.6.2 regarding linear processes). It is
possible, for example, to develop an entire body of generalized techniques for
image restoration starting with Eq. (2.6-29), as we discuss in Section 5.9. We
touch on the topic of using matrices again in the following section, and show
other uses of matrices for image processing in Chapters 5, 8, 11, and 12.

2.6.7 Image Transforms


All the image processing approaches discussed thus far operate directly on the
pixels of the input image; that is, they work directly in the spatial domain. In
some cases, image processing tasks are best formulated by transforming the
input images, carrying the specified task in a transform domain, and applying
the inverse transform to return to the spatial domain. You will encounter a
number of different transforms as you proceed through the book. A particu-
larly important class of 2-D linear transforms, denoted T(u, v), can be ex-
pressed in the general form

M-1 N-1
T(u, v) = a a f(x, y)r(x, y, u, v) (2.6-30)
x=0 y=0

where f(x, y) is the input image, r(x, y, u, v) is called the forward transforma-
tion kernel, and Eq. (2.6-30) is evaluated for u = 0, 1, 2, Á , M - 1 and
v = 0, 1, 2, Á , N - 1. As before, x and y are spatial variables, while M and N
94 Chapter 2 ■ Digital Image Fundamentals

FIGURE 2.39 T(u, v) Operation R[T(u, v)] Inverse g (x, y)


General approach f (x, y) Transform
R transform
for operating in
the linear Spatial Spatial
transform domain Transform domain domain
domain.
are the row and column dimensions of f. Variables u and v are called the
transform variables. T(u, v) is called the forward transform of f(x, y). Given
T(u, v), we can recover f(x, y) using the inverse transform of T(u, v),
M-1 N-1
f(x, y) = a a T(u, v)s(x, y, u, v) (2.6-31)
u=0 v=0

for x = 0, 1, 2, Á , M - 1 and y = 0, 1, 2, Á , N - 1, where s(x, y, u, v) is


called the inverse transformation kernel. Together, Eqs. (2.6-30) and (2.6-31)
are called a transform pair.
Figure 2.39 shows the basic steps for performing image processing in the
linear transform domain. First, the input image is transformed, the transform is
then modified by a predefined operation, and, finally, the output image is ob-
tained by computing the inverse of the modified transform. Thus, we see that
the process goes from the spatial domain to the transform domain and then
back to the spatial domain.

EXAMPLE 2.11: ■ Figure 2.40 shows an example of the steps in Fig. 2.39. In this case the trans-
Image processing form used was the Fourier transform, which we mention briefly later in this
in the transform section and discuss in detail in Chapter 4. Figure 2.40(a) is an image corrupted
domain.

a b
c d
FIGURE 2.40
(a) Image corrupted
by sinusoidal
interference. (b)
Magnitude of the
Fourier transform
showing the bursts
of energy responsible
for the interference.
(c) Mask used to
eliminate the energy
bursts. (d) Result of
computing the
inverse of the
modified Fourier
transform. (Original
image courtesy of
NASA.)
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 95

by sinusoidal interference, and Fig. 2.40(b) is the magnitude of its Fourier


transform, which is the output of the first stage in Fig. 2.39. As you will learn in
Chapter 4, sinusoidal interference in the spatial domain appears as bright
bursts of intensity in the transform domain. In this case, the bursts are in a cir-
cular pattern that can be seen in Fig. 2.40(b). Figure 2.40(c) shows a mask
image (called a filter) with white and black representing 1 and 0, respectively.
For this example, the operation in the second box of Fig. 2.39 is to multiply the
mask by the transform, thus eliminating the bursts responsible for the interfer-
ence. Figure 2.40(d) shows the final result, obtained by computing the inverse
of the modified transform. The interference is no longer visible, and important
detail is quite clear. In fact, you can even see the fiducial marks (faint crosses)
that are used for image alignment. ■

The forward transformation kernel is said to be separable if


r(x, y, u, v) = r1(x, u)r2(y, v) (2.6-32)
In addition, the kernel is said to be symmetric if r1(x, y) is functionally equal to
r2(x, y), so that
r(x, y, u, v) = r1(x, u)r1(y, v) (2.6-33)
Identical comments apply to the inverse kernel by replacing r with s in the pre-
ceding equations.
The 2-D Fourier transform discussed in Example 2.11 has the following for-
ward and inverse kernels:
r(x, y, u, v) = e-j 2 p(ux>M + vy>N) (2.6-34)
and
1 j 2p(ux>M + vy>N)
s(x, y, u, v) = e (2.6-35)
MN
respectively, where j = 2-1, so these kernels are complex. Substituting these
kernels into the general transform formulations in Eqs. (2.6-30) and (2.6-31)
gives us the discrete Fourier transform pair:
M-1 N-1
T(u, v) = a a f(x, y) e -j 2 p(ux>M + vy>N) (2.6-36)
x=0 y=0

and
1 M-1 N-1 j2p(ux>M + vy>N)
MN ua a T(u, v) e
f(x, y) = (2.6-37)
=0 v=0

These equations are of fundamental importance in digital image processing,


and we devote most of Chapter 4 to deriving them starting from basic princi-
ples and then using them in a broad range of applications.
It is not difficult to show that the Fourier kernels are separable and sym-
metric (Problem 2.25), and that separable and symmetric kernels allow 2-D
transforms to be computed using 1-D transforms (Problem 2.26). When the
96 Chapter 2 ■ Digital Image Fundamentals

forward and inverse kernels of a transform pair satisfy these two conditions,
and f(x, y) is a square image of size M * M, Eqs. (2.6-30) and (2.6-31) can be
expressed in matrix form:
T = AFA (2.6-38)
where F is an M * M matrix containing the elements of f(x, y) [see Eq. (2.4-2)],
A is an M * M matrix with elements aij = r1(i, j), and T is the resulting
M * M transform, with values T(u, v) for u, v = 0, 1, 2, Á , M - 1.
To obtain the inverse transform, we pre- and post-multiply Eq. (2.6-38) by
an inverse transformation matrix B:

BTB = BAFAB (2.6-39)

If B = A-1,

F = BTB (2.6-40)

indicating that F [whose elements are equal to image f(x, y)] can be recov-
ered completely from its forward transform. If B is not equal to A-1, then use
of Eq. (2.6-40) yields an approximation:
N = BAFAB
F (2.6-41)

In addition to the Fourier transform, a number of important transforms, in-


cluding the Walsh, Hadamard, discrete cosine, Haar, and slant transforms, can
be expressed in the form of Eqs. (2.6-30) and (2.6-31) or, equivalently, in the
form of Eqs. (2.6-38) and (2.6-40). We discuss several of these and some other
types of image transforms in later chapters.

2.6.8 Probabilistic Methods


Probability finds its way into image processing work in a number of ways. The
Consult the Tutorials sec-
tion in the book Web site simplest is when we treat intensity values as random quantities. For example,
for a brief overview of let zi, i = 0, 1, 2, Á , L - 1, denote the values of all possible intensities in an
probability theory.
M * N digital image. The probability, p(zk), of intensity level zk occurring in a
given image is estimated as
nk
p(zk) = (2.6-42)
MN
where nk is the number of times that intensity zk occurs in the image and MN
is the total number of pixels. Clearly,
L-1

a p(zk) = 1 (2.6-43)
k=0
Once we have p(zk), we can determine a number of important image charac-
teristics. For example, the mean (average) intensity is given by
L-1
m = a zk p(zk) (2.6-44)
k=0
2.6 ■ An Introduction to the Mathematical Tools Used in Digital Image Processing 97

Similarly, the variance of the intensities is


L-1
s2 = a (zk - m)2 p(zk) (2.6-45)
k=0

The variance is a measure of the spread of the values of z about the mean, so it
is a useful measure of image contrast. In general, the nth moment of random
variable z about the mean is defined as
L-1
mn(z) = a (zk - m)n p(zk) (2.6-46)
k=0

We see that m0(z) = 1, m1(z) = 0, and m2(z) = s2. Whereas the mean and The units of the variance
are in intensity values
variance have an immediately obvious relationship to visual properties of an squared. When compar-
image, higher-order moments are more subtle. For example, a positive third ing contrast values, we
usually use the standard
moment indicates that the intensities are biased to values higher than the deviation, s (square root
mean, a negative third moment would indicate the opposite condition, and a of the variance), instead
because its dimensions
zero third moment would tell us that the intensities are distributed approxi- are directly in terms of
mately equally on both sides of the mean. These features are useful for com- intensity values.
putational purposes, but they do not tell us much about the appearance of an
image in general.

■ Figure 2.41 shows three 8-bit images exhibiting low, medium, and high con- EXAMPLE 2.12:
trast, respectively. The standard deviations of the pixel intensities in the three Comparison of
images are 14.3, 31.6, and 49.2 intensity levels, respectively. The corresponding standard
deviation values
variance values are 204.3, 997.8, and 2424.9, respectively. Both sets of values as measures of
tell the same story but, given that the range of possible intensity values in image intensity
these images is [0, 255], the standard deviation values relate to this range much contrast.
more intuitively than the variance. ■

As you will see in progressing through the book, concepts from probability
play a central role in the development of image processing algorithms. For ex-
ample, in Chapter 3 we use the probability measure in Eq. (2.6-42) to derive in-
tensity transformation algorithms. In Chaper 5, we use probability and matrix
formulations to develop image restoration algorithms. In Chapter 10, probabil-
ity is used for image segmentation, and in Chapter 11 we use it for texture de-
scription. In Chapter 12, we derive optimum object recognition techniques
based on a probabilistic formulation.

a b c
FIGURE 2.41
Images exhibiting
(a) low contrast,
(b) medium
contrast, and
(c) high contrast.
98 Chapter 2 ■ Digital Image Fundamentals

Thus far, we have addressed the issue of applying probability to a single ran-
dom variable (intensity) over a single 2-D image. If we consider sequences of
images, we may interpret the third variable as time. The tools needed to handle
this added complexity are stochastic image processing techniques (the word
stochastic is derived from a Greek word meaning roughly “to aim at a target,”
implying randomness in the outcome of the process). We can go a step further
and consider an entire image (as opposed to a point) to be a spatial random
event. The tools needed to handle formulations based on this concept are tech-
niques from random fields. We give one example in Section 5.8 of how to treat
entire images as random events, but further discussion of stochastic processes
and random fields is beyond the scope of this book.The references at the end of
this chapter provide a starting point for reading about these topics.

Summary
The material in this chapter is primarily background for subsequent discussions. Our treat-
ment of the human visual system, although brief, provides a basic idea of the capabilities of
the eye in perceiving pictorial information.The discussion on light and the electromagnetic
spectrum is fundamental in understanding the origin of the many images we use in this
book. Similarly, the image model developed in Section 2.3.4 is used in the Chapter 4 as the
basis for an image enhancement technique called homomorphic filtering.
The sampling and interpolation ideas introduced in Section 2.4 are the foundation
for many of the digitizing phenomena you are likely to encounter in practice. We will
return to the issue of sampling and many of its ramifications in Chapter 4, after you
have mastered the Fourier transform and the frequency domain.
The concepts introduced in Section 2.5 are the basic building blocks for processing
techniques based on pixel neighborhoods. For example, as we show in the following
chapter, and in Chapter 5, neighborhood processing methods are at the core of many
image enhancement and restoration procedures. In Chapter 9, we use neighborhood
operations for image morphology; in Chapter 10, we use them for image segmentation;
and in Chapter 11 for image description. When applicable, neighborhood processing is
favored in commercial applications of image processing because of their operational
speed and simplicity of implementation in hardware and/or firmware.
The material in Section 2.6 will serve you well in your journey through the book. Al-
though the level of the discussion was strictly introductory, you are now in a position to
conceptualize what it means to process a digital image. As we mentioned in that section,
the tools introduced there are expanded as necessary in the following chapters. Rather
than dedicate an entire chapter or appendix to develop a comprehensive treatment of
mathematical concepts in one place, you will find it considerably more meaningful to
learn the necessary extensions of the mathematical tools from Section 2.6 in later chap-
ters, in the context of how they are applied to solve problems in image processing.

References and Further Reading


Additional reading for the material in Section 2.1 regarding the structure of the human
eye may be found in Atchison and Smith [2000] and Oyster [1999]. For additional reading
on visual perception, see Regan [2000] and Gordon [1997].The book by Hubel [1988] and
the classic book by Cornsweet [1970] also are of interest. Born and Wolf [1999] is a basic
reference that discusses light in terms of electromagnetic theory. Electromagnetic energy
propagation is covered in some detail by Felsen and Marcuvitz [1994].
■ Problems 99

The area of image sensing is quite broad and very fast moving. An excellent source
of information on optical and other imaging sensors is the Society for Optical Engi-
neering (SPIE). The following are representative publications by the SPIE in this area:
Blouke et al. [2001], Hoover and Doty [1996], and Freeman [1987].
The image model presented in Section 2.3.4 is from Oppenheim, Schafer, and
Stockham [1968]. A reference for the illumination and reflectance values used in that
section is the IESNA Lighting Handbook [2000]. For additional reading on image
sampling and some of its effects, such as aliasing, see Bracewell [1995]. We discuss this
topic in more detail in Chapter 4. The early experiments mentioned in Section 2.4.3
on perceived image quality as a function of sampling and quatization were reported
by Huang [1965]. The issue of reducing the number of samples and intensity levels in
an image while minimizing the ensuing degradation is still of current interest, as ex-
emplified by Papamarkos and Atsalakis [2000]. For further reading on image shrink-
ing and zooming, see Sid-Ahmed [1995], Unser et al. [1995], Umbaugh [2005], and
Lehmann et al. [1999]. For further reading on the topics covered in Section 2.5, see
Rosenfeld and Kak [1982], Marchand-Maillet and Sharaiha [2000], and Ritter and
Wilson [2001].
Additional reading on linear systems in the context of image processing (Section 2.6.2)
may be found in Castleman [1996]. The method of noise reduction by image averaging
(Section 2.6.3) was first proposed by Kohler and Howell [1963]. See Peebles [1993] re-
garding the expected value of the mean and variance of a sum of random variables.
Image subtraction (Section 2.6.3) is a generic image processing tool used widely for
change detection. For image subtraction to make sense, it is necessary that the images
being subtracted be registered or, alternatively, that any artifacts due to motion be
identified. Two papers by Meijering et al. [1999, 2001] are illustrative of the types of
techniques used to achieve these objectives.
A basic reference for the material in Section 2.6.4 is Cameron [2005]. For more ad-
vanced reading on this topic, see Tourlakis [2003]. For an introduction to fuzzy sets, see
Section 3.8 and the corresponding references in Chapter 3. For further details on single-
point and neighborhood processing (Section 2.6.5), see Sections 3.2 through 3.4 and the
references on these topics in Chapter 3. For geometric spatial transformations, see Wol-
berg [1990].
Noble and Daniel [1988] is a basic reference for matrix and vector operations
(Section 2.6.6). See Chapter 4 for a detailed discussion on the Fourier transform
(Section 2.6.7), and Chapters 7, 8, and 11 for examples of other types of transforms
used in digital image processing. Peebles [1993] is a basic introduction to probability
and random variables (Section 2.6.8) and Papoulis [1991] is a more advanced treat-
ment of this topic. For foundation material on the use of stochastic and random
fields for image processing, see Rosenfeld and Kak [1982], Jähne [2002], and Won
and Gray [2004].
For details of software implementation of many of the techniques illustrated in this
chapter, see Gonzalez, Woods, and Eddins [2004].

Problems
 2.1 Using the background information provided in Section 2.1, and thinking purely Detailed solutions to the
problems marked with a
in geometric terms, estimate the diameter of the smallest printed dot that the star can be found in the
eye can discern if the page on which the dot is printed is 0.2 m away from the book Web site. The site
eyes. Assume for simplicity that the visual system ceases to detect the dot when also contains suggested
projects based on the ma-
the image of the dot on the fovea becomes smaller than the diameter of one re- terial in this chapter.
ceptor (cone) in that area of the retina. Assume further that the fovea can be
100 Chapter 2 ■ Digital Image Fundamentals

modeled as a square array of dimensions 1.5 mm * 1.5 mm, and that the cones
and spaces between the cones are distributed uniformly throughout this array.
2.2 When you enter a dark theater on a bright day, it takes an appreciable interval
of time before you can see well enough to find an empty seat. Which of the visual
processes explained in Section 2.1 is at play in this situation?
 2.3 Although it is not shown in Fig. 2.10, alternating current certainly is part of the
electromagnetic spectrum. Commercial alternating current in the United States
has a frequency of 60 Hz. What is the wavelength in kilometers of this compo-
nent of the spectrum?
2.4 You are hired to design the front end of an imaging system for studying the
boundary shapes of cells, bacteria, viruses, and protein. The front end consists, in
this case, of the illumination source(s) and corresponding imaging camera(s).
The diameters of circles required to enclose individual specimens in each of
these categories are 50, 1, 0.1, and 0.01 m, respectively.
(a) Can you solve the imaging aspects of this problem with a single sensor and
camera? If your answer is yes, specify the illumination wavelength band and
the type of camera needed. By “type,” we mean the band of the electromag-
netic spectrum to which the camera is most sensitive (e.g., infrared).
(b) If your answer in (a) is no, what type of illumination sources and corre-
sponding imaging sensors would you recommend? Specify the light sources
and cameras as requested in part (a). Use the minimum number of illumina-
tion sources and cameras needed to solve the problem.
By “solving the problem,” we mean being able to detect circular details of diam-
eter 50, 1, 0.1, and 0.01 m, respectively.
2.5 A CCD camera chip of dimensions 7 * 7 mm, and having 1024 * 1024 ele-
ments, is focused on a square, flat area, located 0.5 m away. How many line
pairs per mm will this camera be able to resolve? The camera is equipped with
a 35-mm lens. (Hint: Model the imaging process as in Fig. 2.3, with the focal
length of the camera lens substituting for the focal length of the eye.)
 2.6 An automobile manufacturer is automating the placement of certain compo-
nents on the bumpers of a limited-edition line of sports cars. The components
are color coordinated, so the robots need to know the color of each car in order
to select the appropriate bumper component. Models come in only four colors:
blue, green, red, and white. You are hired to propose a solution based on imag-
ing. How would you solve the problem of automatically determining the color of
each car, keeping in mind that cost is the most important consideration in your
choice of components?
2.7 Suppose that a flat area with center at (x0, y0) is illuminated by a light source
with intensity distribution
2
+ (y - y0)2]
i(x, y) = Ke-[(x - x0)

Assume for simplicity that the reflectance of the area is constant and equal to
1.0, and let K = 255. If the resulting image is digitized with k bits of intensity
resolution, and the eye can detect an abrupt change of eight shades of intensity
between adjacent pixels, what value of k will cause visible false contouring?
2.8 Sketch the image in Problem 2.7 for k = 2.
 2.9 A common measure of transmission for digital data is the baud rate, defined as
the number of bits transmitted per second. Generally, transmission is accomplished
■ Problems 101

in packets consisting of a start bit, a byte (8 bits) of information, and a stop bit.
Using these facts, answer the following:
(a) How many minutes would it take to transmit a 1024 * 1024 image with 256
intensity levels using a 56K baud modem?
(b) What would the time be at 3000K baud, a representative medium speed of a
phone DSL (Digital Subscriber Line) connection?
2.10 High-definition television (HDTV) generates images with 1125 horizontal TV
lines interlaced (where every other line is painted on the tube face in each of two
fields, each field being 1>60th of a second in duration). The width-to-height as-
pect ratio of the images is 16:9. The fact that the number of horizontal lines is
fixed determines the vertical resolution of the images. A company has designed
an image capture system that generates digital images from HDTV images. The
resolution of each TV (horizontal) line in their system is in proportion to vertical
resolution, with the proportion being the width-to-height ratio of the images.
Each pixel in the color image has 24 bits of intensity resolution, 8 bits each for a
red, a green, and a blue image. These three “primary” images form a color image.
How many bits would it take to store a 2-hour HDTV movie?
 2.11 Consider the two image subsets, S1 and S2, shown in the following figure. For
V = 516, determine whether these two subsets are (a) 4-adjacent, (b) 8-adjacent,
or (c) m-adjacent.
S1 S2
0 0 0 0 0 0 0 1 1 0
1 0 0 1 0 0 1 0 0 1
1 0 0 1 0 1 1 0 0 0
0 0 1 1 1 0 0 0 0 0
0 0 1 1 1 0 0 1 1 1

 2.12 Develop an algorithm for converting a one-pixel-thick 8-path to a 4-path.


2.13 Develop an algorithm for converting a one-pixel-thick m-path to a 4-path.
2.14 Refer to the discussion at the end of Section 2.5.2, where we defined the back-
ground as (Ru)c, the complement of the union of all the regions in an image. In
some applications, it is advantageous to define the background as the subset of
pixels (Ru)c that are not region hole pixels (informally, think of holes as sets of
background pixels surrounded by region pixels). How would you modify the de-
finition to exclude hole pixels from (Ru)c? An answer such as “the background is
the subset of pixels of (Ru)c that are not hole pixels” is not acceptable. (Hint:
Use the concept of connectivity.)
2.15 Consider the image segment shown.
(a) Let V = 50, 16 and compute the lengths of the shortest 4-, 8-, and m-path
between p and q. If a particular path does not exist between these two
points, explain why.
(b) Repeat for V = 51, 26.
3 1 2 1 (q)

2 2 0 2

1 2 1 1

( p) 1 0 1 2
102 Chapter 2 ■ Digital Image Fundamentals

2.16 (a) Give the condition(s) under which the D4 distance between two points p
and q is equal to the shortest 4-path between these points.
(b) Is this path unique?
2.17 Repeat Problem 2.16 for the D8 distance.
 2.18 In the next chapter, we will deal with operators whose function is to compute
the sum of pixel values in a small subimage area, S. Show that these are linear
operators.
2.19 The median, z, of a set of numbers is such that half the values in the set are
below z and the other half are above it. For example, the median of the set of
values 52, 3, 8, 20, 21, 25, 316 is 20. Show that an operator that computes the
median of a subimage area, S, is nonlinear.
 2.20 Prove the validity of Eqs. (2.6-6) and (2.6-7). [Hint: Start with Eq. (2.6-4) and use
the fact that the expected value of a sum is the sum of the expected values.]
2.21 Consider two 8-bit images whose intensity levels span the full range from 0 to 255.
(a) Discuss the limiting effect of repeatedly subtracting image (2) from image
(1). Assume that the result is represented also in eight bits.
(b) Would reversing the order of the images yield a different result?
 2.22 Image subtraction is used often in industrial applications for detecting missing
components in product assembly. The approach is to store a “golden” image that
corresponds to a correct assembly; this image is then subtracted from incoming
images of the same product. Ideally, the differences would be zero if the new prod-
ucts are assembled correctly. Difference images for products with missing compo-
nents would be nonzero in the area where they differ from the golden image.
What conditions do you think have to be met in practice for this method to work?
2.23 (a) With reference to Fig. 2.31, sketch the set (A ¨ B) ´ (A ´ B)c.
(b) Give expressions for the sets shown shaded in the following figure in terms
of sets A, B, and C. The shaded areas in each figure constitute one set, so
give one expression for each of the three figures.

B C

2.24 What would be the equations analogous to Eqs. (2.6-24) and (2.6-25) that would
result from using triangular instead of quadrilateral regions?
2.25 Prove that the Fourier kernels in Eqs. (2.6-34) and (2.6-35) are separable and
symmetric.
 2.26 Show that 2-D transforms with separable, symmetric kernels can be computed
by (1) computing 1-D transforms along the individual rows (columns) of the
input, followed by (2) computing 1-D transforms along the columns (rows) of
the result from step (1).
■ Problems 103

2.27 A plant produces a line of translucent miniature polymer squares. Stringent qual-
ity requirements dictate 100% visual inspection, and the plant manager finds the
use of human inspectors increasingly expensive. Inspection is semiautomated. At
each inspection station, a robotic mechanism places each polymer square over a
light located under an optical system that produces a magnified image of the
square. The image completely fills a viewing screen measuring 80 * 80 mm. De-
fects appear as dark circular blobs, and the inspector’s job is to look at the screen
and reject any sample that has one or more such dark blobs with a diameter of
0.8 mm or larger, as measured on the scale of the screen. The manager believes
that if she can find a way to automate the process completely, she will increase
profits by 50%. She also believes that success in this project will aid her climb up
the corporate ladder. After much investigation, the manager decides that the way
to solve the problem is to view each inspection screen with a CCD TV camera
and feed the output of the camera into an image processing system capable of de-
tecting the blobs, measuring their diameter, and activating the accept/reject but-
tons previously operated by an inspector. She is able to find a system that can do
the job, as long as the smallest defect occupies an area of at least 2 * 2 pixels in
the digital image. The manager hires you to help her specify the camera and lens
system, but requires that you use off-the-shelf components. For the lenses, as-
sume that this constraint means any integer multiple of 25 mm or 35 mm, up to
200 mm. For the cameras, it means resolutions of 512 * 512, 1024 * 1024, or
2048 * 2048 pixels. The individual imaging elements in these cameras are
squares measuring 8 * 8 m, and the spaces between imaging elements are
2 m. For this application, the cameras cost much more than the lenses, so the
problem should be solved with the lowest-resolution camera possible, based on
the choice of lenses. As a consultant, you are to provide a written recommenda-
tion, showing in reasonable detail the analysis that led to your conclusion. Use
the same imaging geometry suggested in Problem 2.5.

You might also like