saewtindeererntinainiomasiasctn inthis
Contents
18
24
22
23
24
25
26
27
28
Preface xi
Acknowledgments xii
About the Authors xiii
Introduction 1
Preview 1
Background 1
What Is Digital Image Processing? 2
Background on MATLAB and the Image Processing Toolbox
Areas of Image Processing Covered in the Book 5
‘The Book Web Site 6
Notation 7
‘The MATLAB Working Environment 7
1.7.1 The MATLAB Desktop 7
1.7.2. Using the MATLAB Editor to Create M-Files 9
173. Getting Help 9
L7A_ Saving and Retrieving a Work Session 10
How References Are Organized in the Book 11
Summary 1
Fundamentals 12
Preview 12
Digital Image Representation 12
21.1 Coordinate Conventions 13
21.2 Images as Matrices 14
Reading Images 14
Displaying Images 16
Writing Images 18
Data Classes 23
Image Types 24
26.1 Intensity Images 24
262 Binary images 25
263 ANoteon Terminology 25
Converting between Data Classes and Image Types 25
27.1 Converting becween Data Classes 25
27.2 Converting between Image Classes and Types 26
Anay Indexing 30
281 VectorIndexing 20°
282 Matrix Indexing 3
283 Selecting Array Dimensions 3729
2.10
3a
32
33
34
4a
42
43
4a
a3
Some Important Standard Arrays 37
Introduction to M-Function Programming 38
2101 M-Files 38
2102 Operators 40
2103 Flow Control 49
210.4 Code Optimization 55
2105 Interactive /O 59
2106 A Briel Introduction to Cell Arrays and Structures 62
Summary 64
Intensity Transformations
and Spatial Filtering 65
Preview! 65
Background 65
Intensity Transformation Functions 66
S21" Function inadjust 66
332. Lopanittmic and Contrast Stetching Transformations 68
333. Some Uuty MoFunctions for intensity Transformations 70
Histogram Processing and Function Potting 7
531 “Generating and Poting image Histograms 76
332 Histogram Equalization 81
333. Histogram Matching (Specification). 84
Spatial Filtering 89
SHI Linear Spatial Fitering. 69
342 Nonlinear Spatial Filtering 96
Image Processing Toolbox Standard Spatial Filters 99
B51" Linear Spatal Filters 99
352 Nonlinene Spatial ites 104
Summary. 107
Frequency Domain Processing 108
Preview 108
The 2-D Discrete Fourier Transform 108
Computing and Visualizing the 2-D DFT in MATLAB 112
Filtering in the Frequency Domain 115
[31 fundamental Concepts 3
432 Basie Steps in DFT Filtering 121
$33 Am Mefunction for Filtering in the Frequency Domain 122
Oblaining Frequency Domain Filters from Spatial Filters 122
Ceneatigg Fives Directly inthe Trequency Doma 127
sat Cheating Meshgrid Arrays for Ute in Implementing Filters
inthe Frequency Domain 128
Towpass Frequency Domain Fters_ 129
WWieerame and Surface Poting, 132
46
5a
52
53
5
55
56
37
38
59
510
sit
61
62
63
6a
= Contents vii
Sharpening Frequency Domain Filters 136
461 Basic Highpass Filtering 136
462 High-Frequency Emphasis Filtering 138
Summary 140
Image Restoration 141
Preotwo 101
‘A Model ofthe Image Degradation Restoration Process 142
Noise Models 133
B21" Adding Noe with Function nose 143
522. Goering Spatial Random Note with a Specified
Disuibuton 1s
523. Period Nese 150
524. Estimating Noise Parameters 153
Restoration inthe Presence of Noise Only—Spatial Filtering. 158
SS Spatial Nose Filters 159
532. Aaptve Spatial ters 168
Periodic Nese Reduction by Frequency Domain Filtering, 166
Modeling the Degradation Fancion I6e
Ditect Inverse Filtering 169
Wiener Filtering 170
Conrtrsned Lest Squares (Regularized) Filtering 173
erative Nonlinear Restoration Using the Luy-Richandson
Algorithm 176
Bind Deconvolution 179
Geometic Transformations and Image Registration 182
S11 Geometric Spatal Tarsformatons “182
5112 Applying Spatal Transformation to Images 187
Bits image Reyetraton 1
Summary "193
Color Image Processing 194
Preview 194
Color Image Representation in MATLAB 194
GL RGBlmages 194
612 Indexed images 197
61.3 IPT Functions for Manipulating RGB and indexed Images 199
Converting to Other Color Spaces 204
621 NTSCColor Space 204
622 TheYCbCrColor Space 205
62% The HSV Calor Spare 205
624 The CMY and CMYK Color Spaces 206
625 The HSIColor Space 207
The Basics of Color Image Processing 215
Color Transformations 216«Contents
65.
66
7a
72
73
Spatial Filtering of Color Images 227
65:1 Color Image Smoothing 227
65.2 Color Image Sharpening 230
Working Directly in RGB Vector Space 251
66.1 Color Edge Detection Using the Gradient 232
662. Image Segmentation in RGB Vector Space 237
Summary 241
Wavelets 242
Preview 242
Background 242
The Fast Wavelet Transform 245
7.2.1 FWTs Using the Wavelet Toolbox 246
72.2 FWTswithout the Wavelet Toolbox 252
Working with Wavelet Decomposition Structures 259
7.3.1 Editing Wavelet Decomposition Coetficients without
the Wavelet Toolbox 262,
7.3.2. Displaying Wavelet Decomposition Coefficients 266
The Inverse Fast Wavelet Transform 271
Wavelets in Image Processing 276
Summary 281
Image Compression 282
Proviso 282
Background 283
Coding Redundancy 286
S21 Huffman Coges 289
322 Hulfman Encoding 295
823. Huffman Decoding. 301
Interpixel Redundancy "309
Paychovisual Redundancy 315
JPEG Compression 317
B51 yee. 38
852 JPEG2000 305
Summary 338
Morphological Image Processing 334
Preview 334
Preliminaries 335
9.141 Some Basic Concepts from Set Theory 385
91.2 Binary Images, Sets, and Logical Operators 337
Dilation and Erosion 337
921 Dilation 338
92.2 Structuring Element Decomposition 341
923 The strel Function 341
924 Erosion 345
93
94
95.
96
10
10a
102
103
4
105
i
ua
8 Contents ix
Combining Dilation and Erosion 347
93.1 Opening and Closing 347
93.2 The Hittor-Miss Transformation 350
933 Using Lookup Tables 353
934 Function banorpn 356
Labeling Connected Components 359
Morphological Reconstruction 362
95.1 Opening by Reconstruction 363
952 Filling Holes 365
95.3. Clearing Border Objects 366
Gray-Scale Morphology 366
9.6.1 Dilation and Erosion 366
92 Opening and Closing 369
9.63 Reconstruction 374
Summary 377
Image Segmentation 378
Previtw 373
Point Line, and Edge Detection 373
1041 Point Detection 979
1012 Line Detection 381
1013 Edge Detection Using Function edge 384
Line Detection Using the Hough Transform 33
1021 Hough Transform Peak Detection 399
1022 Hough Transform Line Detection and Linking 401
Thresholding 404
1031 Global Tresholding 405
1032 Local Thresholding 407
Regioa-Based Segmentation 407
1041 Basic Formulation 407
1042 Region Growing "408
1043 Region Spliting and Merging 412
Segmentation Using the Watershed Transform 417
1051 Watershed Segmentation Using the Distance Transform 418
105.2 Watershed Segmentation Using Gradients 420
1053 Marker-Contolled Watershed Segmentation 42
Summary 425
Representation and Description 426
Proview 426
Background 425
1123 Cell Arays and Structures 427
112 Some Advitional MATLAB and IPT Functions Used
inthis Chapter 422
113 Some Basie Uilty M-Functons 483Contents|
112 Representation 436
3121 Chain Codes 436
11.22 Polygonal Approximations Using Minimum-Perimeter
Polygons 439
11.23 Signatures 449
112.4 Boundary Segments 452
1125 Skeletons 453
113 Boundary Descriptors 455
113.1 Some Simple Descriptors’ 455
3132 Shape Numbers 456
11.33 Fourier Descriptors 458
134 Statistical Moments 462
1A Regional Descriptors $63,
ALA Function regionprops 463,
1142 Texture 464
i143 Moment Invariants 470
115 Using Principal Components for Description 474
Summary 483
12 object Recognition 484
|
122 Background 484
122 Computing Distance Measures in MATLAB 485
123 Recognition Based on Decsion-Theoretic Methods 488
123 Forming Patern Verto 488
1232 ator Matching Using MinimarDistance Classifiers 489
1233 Matching by Correlation 50
1234 Opaimum Statistical Casiiers $92
1235 Adaptive Leaning Systems, 498
Cy rene meer
TLD Working th Strings in MATLAB 499
1242 String Matching 508
pasneach
Appendix A Function Summary 514
Aupentic Bice and MATLAB Graphical
User Interfaces 527
Aapentx C M-Functions 552
Bibliography 594
Index 597
Preface
Solutions to problems in the field of digital image processing generally requite
extensive experimental work involving software simulation and testing wit large sets
of sample images Although algorithm development typically is based on theoretical
‘underpinnings. the actual implementation of these algorithms almost always requires
parameter estimation and, requenty algorithm revision and comparison of candidte
Solutions Thus selection ofa flexible, comprehensive, and well-documented software
‘evelopment envisonment isa key factor that has important implications in the cost,
‘development time, and portability of image processing solutions.
In spite of its importance, surprisingly litle has been writen on this aspect of the
field in the fom of textbook material dealing with both theoretical principles and sof-
‘ware implementation of digital image processing concepts This book was written for
just this purpose. Is main objective so provide foundation for implementing image
processing algorithms using modem software tools complementary objective was to
prepare a book that is selcontained and easly readable by individuals witha basic
buckground in digital image processing, mathematical analysis, and computer pro-
gramming all at a level typical of that found in a juniorsenior eurticulum ina techai-
‘al discipline Rudimentary knowledge of MATLAB also i desirable.
‘To achieve these objectives, we felt that two key ingredients were needed. The
frst was to select image processing material that is representative of material cov-
cred in formal course of instruction inthis field, The second was to select soft
‘ware tools that are well supported and documented, and which have a wide range
of applications inthe “real” world.
“Tomect the fst objective most ofthe theoretical eonceptsin the following chapters
were selected fom Digital Image Processing by Gonzsez and Woods, which has been
the choie introductory textbook used by educators all ver the world for over two
decades The software tools selected ate from the MATLAB Image Processing Toolbox
{OPT).which similarly occupies a postion of eminence in both education and industrial
pplcations A basic strategy followed in the preparation ofthe book was to provide a
seamles integration of wellestablished theoretical concepts and their implementation
wing state-of the-art software tools
‘The book is organized along the same lines as Digial Image Processing. In this way,
the reader has easy access to a more detailed treatment ofall the image processing
‘concepts discused here, 5 well as an up-to-date set of references for further reading.
Following this approach made it possible to present theoretical mate ina sucinct
‘manner and thus we were able to maintain afocuson the software implementation as-
ects of image processing problem solutions Because it works in the MATLAB com-
Puting environment, the Image Processing Toolbox offers some significant advantages,
ot ony in the breadth ofits computational took, but also because it is supported
under most operating systems in se today. nique feature of this book sits empia-
sis on showing How to develop new code o enhance existing MATLAB and TPT func-
tionality. This i an important feature in an area Such as image processing, which, as
‘oted ale, is characterized by the need for extensive algorithm development and
experimental work
‘Aller an introduction to the fundamentals of MATLAB functions and program-
ming, the book proceeds to address the mainstream areas of image processing. The1 Preface
major areas covered include intensity transformations, linear and nonlinear spatial fk
tering, filering in the frequency domain, image restoration and registration, color
image processing wavelets image data compression, morphological image prosesing,
image Seementation, region and boundary representation and description, and object
recognition This material is complemented by numerous illustrations of how to solve
jmage processing problems using MATLAB and IPT functions In cases where a fune-
tion cid not exist, a new function was written and documented as part ofthe instruc-
tional focus ofthe book, Over 60 new functions are included in the following chapters.
“These functions inerease the scope of IPT by approximately 35 percent and also serve
the important purpose of futher illustrating how to implement new image processing,
software solutions
“The material is presented in textbook format, not a a software manual. Although
the book is self-contained, we have established a companion Web site (See Section 13)
signed to provide support in a number of areas For students following a forrmal
‘course of study or individuals embarked on a program of set study, the site contains
tutorials and reviews on background material, as wel as projects and image databases,
‘including all images in the book, For instructors, te site contains classroom presenta~
tion materials that inelude PowerPoint slides ofall the images and graphics used inthe
book, Individuals already familiar with image processing and IPT fundamentals will
find the site a useful place for up-to-date references new implementation techniques,
‘and a host of other support material not easly ound elsewhere. Al purchasers ofthe
‘book are eligible to download executable files of all the new functions developed in
the text.
‘Asis true of most writing efforts of this nature, progress continues after work on the
_manuscript stops For ths reason, we devoted significant effort to the selection of ma-
terial that we believe is Findamental, and whose value is likely to remain applicable in
2 rapidly evolving body of knowledge. We trust that readers ofthe book will benefit
from this effort and thus find the material imely and usefl in their work.
Acknowledgments
‘We are indebted to a numberof individuals in academic circles as wel asin industry
and government who have contributed tothe preparation ofthe book. Their contribu-
tions have been important in so many different ways that we find it dificult to ac-
Knowledge them in any other way but alphabetically. We wish to extend our
appreciation to Mongi A. Abid, Peter J.Acklam, Serge Beucher, Emesto Bribesca,
Michael W, Davidson, Courtney Esposito, Naomi Fernandes, Thomas R. Gest, Roger
Head, Brian Johnson, Lisa Kempler, Roy Lurie, Ashley Mohamed, Joseph E.
Paseente, David R. Pickens, Edgardo Felipe Riveron, Michael Robinson, Loren Shure,
Jack Sklanski, Sally Stowe, Craig Watson, and Greg Wolodkin, We also wish to ac
knowledge the organizations cite inthe captions of many of th figures inthe book
fr their permission to use that materia
1 oUt tne go to-Tom Robins, Rose Kemi, Ace Dworkin, Xohong
Zhu, Bruce Kenselaa, and Jayne Conte at Prentice Hal for their commitment to
excellence in all aspects of the production ofthe book. Their creativity assistance,
and patience are trly appreciated.
Ragas. C GonzaLez
Ricuaro E.Wooos
‘Steven L. EDDINS
About the Authors
Rafael C. Gonzalez
R.C. Gonzalez received the BSE.E, degree from the University of Mian ia 1965
and the MEE and Ph.D. degrees in electrical engincering from the University of
Florida, Gainesville, in 1967 and 1970, respectively. He joined the Electrical and
Computer Engineering Department at the University of Tennessee, Knowvile
(UTK) in 1970, where he became Associate Professor in 1973, Professor in 1978,
and Distinguished Service Professor in 1984, He served as Chairman of the de-
partment from 1994 through 1997. He is currently a Professor Emeritus of Elect
al ond Computer Engineering at UTK.
He isthe founder of the Image & Patter Analysis Laboratory and the Robot-
ies & Computer Vision Laboratory atthe University of Tennessee. He also found
cd Perceptics Corporation in 1982 and was its president until 1992, The lat three
years of this period were spent under a fulltime employment conteact with West
inghouse Corporation, who acquired the company in 1989, Under his direction
Perceptics became highly successful in image processing, computer vision,
laser disk storage technologies In its initial ten years Perceptics introduced # se-
rics of innovative products, including: The world’s first commercally-available
computer vision system for automatically reading the license plate on moving ve-
hile: a series of large-scale image processing and archiving systems used by the
US. Navy at six different manufacturing sites throughout the country to inspect
the rocket motors of missiles in the Trident Il Submarine Program: the market
leading family of imaging boards for advanced Macintosh computers: and a line of
trillion-byte laser disk products.
He isa frequent consultant to industry and government inthe areas of pattern
recognition, image processing, and machine earning. His academic honors for work
in these fields include the 1977 UTK College of Engineering Faculty Achievement
‘Awardthe 1978 UTK Chancellor's Research Scholar Award: the 1980 Magnavox En-
tineering Professor Award: and the 1980 M. E. Brooks Distinguished Professor
‘Awatd In 1981 he became an IBM Professor a the University of Tennesse and in
1984 he was named a Distinguished Service Professor there. He was awarded Di
tinguished Alumnus Award by the University of Miami in 1985, the Phi Kappa Phi
Scholar Award in 1986, and the University of Tennessee's Nathan W. Dougherty
‘Award for Excellence in Engineering in 1992. Honors fr industrial ascompishment
include the 1987 IEEE Outstanding Engineer Award for Commercial Development
in Tennessee: the 1988 Albert Rose National Award for Excellence in Commercial
lenage Processing the 1589 B, Otto Whecley Award for Excllence in Technology
Transter, the 1989 Coopers and Lybrand Entrepreneur of the Year Award; the 1992
IEEE Region 3 Outstanding Enginzer Award: and the 1993 Automated Imaging As-
sociation National Award fr Technology Development.
ir Gonzalez is author oF co-author of over 100 technical articles, two edited
books. and five textbooks in the fields of pattern recognition, image processing,
And robotics, His books are used in over 500 universities and research institutions
throughout the world. He is listed inthe prestigious Marquis Who’ Who in Amer-
‘ea, Marquis Who's Who in Engineering, Marquis Who's Who in the World. and in
10 other national and intemational biographical citations. He s the co-holder of
two US. Patents, and has been an associate editor of the [EEE Transactions on4 About the Authors
“Systems, Man and Cybernetic and the Intemasional Journal of Computer and In-
Jovmation Sciences. He is 4 member of numerous professional and honorary soci-
‘ties, including Tau Beta Pi, Phi Kappa Phi, Eta Kappa Nu, and Sigma Xi, He is 8
Fellow of the IEEE.
Richard E. Woods
Richard E. Woods earned his BS, MS. and Pp.D. degrees in Flectrical Engineer-
ing ftom the University of Tennessee, Knoxville. His professional experiences
range from entrepreneurial to the more traditional academic, consulting, govemn-
‘meatal, and industrial pursuits Most recently, be founded MedData Interactive, a
high technology company specializing in the development of handheld computer
systems for medical applications, He was also a founder and Vice President of Per-
‘eptics Corporation, where he was responsible forthe development of many ofthe
company’s quantitative image analysis and autonomous decision making products,
rior to Perceptics and MedData, Dr. Woods was an Assistant Protessor of Elec
‘vical Engineering and Computer Science at the University of Tennessee and prior to
that, computer applications engineer at Union Carbide Corporation. As a consul-
tant he has been involved inthe development of a aumber of special-purpose digital
processors for a variety of space and military agencies including NASA. the Ballistic
Missle Systems Command, and the Oak Ridge National Laboratory.
Dr. Woods has published numerous articles related to digital signal processing
‘and is co-author of Digital Image Processing, the leading text in the field. He is a
member of several professional societies, including Tau Beta Pi, Phi Kappa Phi,
and the IEEE, In 1986, he was recognized as a Distinguished Engineering Alum-
rus of the University of Tennessee.
Steven L. Eddins
Steven L. Eddins is development manager of the image processing group at The
‘MathWorks, In. He fed the development of several versions of the company’s
Image Processing Toolbox, His professional interests include building software
tools that are based on the latest research in image processing algorithms, and that
have a broad range of scientific and engineering applications.
Prior to joining The MathWorks, Inc. in 1993, Dr, Eddins was on the faculty of
the Electrical Engineering and Computer Science Department atthe University of
Illinois Chicago. There he taught graduate and senior-level classes in digital image
processing, computer vision, pattern recognition, and filter design, and he per-
formed research in the area of image compression,
De. Eddins holds a BE.E. (1986) and a Ph.D. (1990), both in cletrcal engineering
from the Georgia Institute of Technology. He is a member ofthe IEEE.
Preview
Digital image processing is an area characterized by the need for extensive ex-
perimental work to establish the viability of proposed solutions to a given
problem. In this chapter we outline how a theoretical base and state-of-the-art
software can be integrated into a prototyping environment whose objective is,
{to provide a set of well-supported tools for the solution of a broad class of
problems in digital image processing,
HAR Background
‘An important characteristic underlying the design of image processing 5ys-
temsis the sigfcant evel of esting and experimentation thst normaly ise
4uited before arriving at an acceptable solution. Ths characteristic implies
that the ability to formulate approzches and quickly prototype candidate solu-
tions generally plays a major role in reducing the cost and time required to
ave at viable system implementation,
tle has been Written in the way of instructional material to bridge the
betseen theory and applation na wellsppored software enrronment the
rain objective of this book sto integrate under one cover abroad base of the-
retical concepts with the knowiedge required to implement those concepts
‘wing state-of the-art image processing software tools The theoretical underpin-
rings ofthe material inthe following chapters are mainly from the leading text-
book in the field: Digital mage Processing, by Gonzalez and Woods, published
by Prentice Hall The software code and supporting tools are based on the lead-
ing sottware package in the field: The MATLAB Image Processing Toolbor.
cuson nin sueguen chapter we sometimes ee Digi Image Poe
Woods asthe Gonss oots bok anda the nage Peng Faker UPES