Digital Image Processing: First Edition
Digital Image Processing: First Edition
First Edition
ISBN 978-1-84628-379-6
e-ISBN 978-1-84628-968-2
Preface
This book provides a modern, self-contained introduction to digital image processing. We designed the book to be used both by learners desiring a rm foundation on which to build and practitioners in search
of critical analysis and modern implementations of the most important
techniques. This is the rst English edition of the original Germanlanguage book, which has been widely used by:
Scientists, and engineers who use image processing as a tool and
wish to develop a deeper understanding and create custom solutions
to imaging problems in their eld.
Information technology (IT) professionals wanting a self-study course
featuring easily adaptable code and completely worked out examples
enabling them to be productive right away.
Faculty and students desiring an example-rich introductory textbook
suitable for an advanced undergraduate or graduate level course that
features exercises, projects, and examples that have been honed during our years of experience teaching this material.
While we concentrate on practical applications and concrete implementations, we do so without glossing over the important formal details and
mathematics necessary for a deeper understanding of the algorithms. In
preparing this text, we started from the premise that simply creating a
recipe book of imaging solutions would not provide the deeper understanding needed to apply these techniques to novel problems, so instead
our solutions are developed stepwise from three dierent perspectives:
in mathematical form, as abstract pseudocode algorithms, and as complete Java programs. We use a common notation to intertwine all three
perspectivesproviding multiple, but linked, views of the problem and
its solution.
Prerequisites
Instead of presenting digital image processing as a mathematical discipline, or strictly as signal processing, we present it from a practitioners
and programmers perspective and with a view toward replacing many
of the formalisms commonly used in other texts with constructs more
readily understandable by our audience. To take full advantage of the
programming components of this book, a knowledge of basic data structures and object-oriented programming, ideally in Java, is required. We
Preface
selected Java for a number of reasons, one of which is that it is the rst
programming language learned by students in a wide variety of engineering curricula. Practitioners with knowledge of a related language,
especially C or C++, will nd the programming examples easy to follow
and extend.
The software in this book is designed to work with ImageJ, a widely
used programmer-extensible imaging system developed, maintained, and
distributed by Wayne Rasband of the National Institutes of Health
(NIH).1 ImageJ is implemented completely in Java, and therefore runs
on all major platforms, and is widely used because its plugin-based
architecture enables it to be easily extended. While all examples run in
ImageJ, they have been specically designed to be easily ported to other
environments and programming languages.
Use in research and development
This book has been especially designed for use as a textbook and as
such features exercises and carefully constructed examples that supplement the detailed synthesis of the fundamental concepts and techniques.
As both practitioners and developers, we know that the details required
for successful understanding and application of classical techniques are
often dicult to nd, and for this reason we have been very careful
to provide the details, many gleaned over years of practical application,
necessary to successfully apply these techniques. While this should make
the text particularly valuable to those in research and development, it
is not designed as a comprehensive, fully cited scientic research text.
On the contrary, we have carefully vetted our citations so that they can
be obtained from easily accessible sources. While we have only briey
discussed the fundamentals of, or entirely omitted, topics such as hierarchical methods, wavelets, or eigenimages because of space limitations,
other topics have been omitted deliberately, including advanced issues
such as object recognition, image understanding, or three-dimensional
computer vision. So while most techniques described in this book could
be called blind and dumb, it is our experience that straightforward,
technically clean implementations of these simpler methods are essential to the success of any further domain-specic, or even intelligent
approaches.
If you are only in search of a programming handbook for ImageJ or
Java, there are certainly better sources. While the book includes a comprehensive ImageJ reference and many code examples, programming in
and of itself is not our main focus. Instead it serves as just one important element for describing each technique in a precise and immediately
testable way.
VI
http://rsb.info.nih.gov/ij/.
Preface
Whether it is called signal processing, image processing, or media computation, the manipulation of digital images has been an integral part of
most computer science and engineering curricula for many years. Today,
with the omnipresence of all-digital work ows it has become an integral part of the required skill set for professionals in diverse disciplines.
Previous to the explosion of digital media, it was often the case that
a computing curriculum would oer only a single course, called Digital Signal Processing in engineering or Digital Image Processing in
computing, and likely only as a graduate elective.
Today the topic has migrated into the early stages of many curricula, where it now serves as a key foundation course. This migration
uncovered a problem in that many of the texts relied on as standards
in the older graduate-level courses were not appropriate for beginners.
The texts were usually too formal for beginners, and at the same time
did not provide detailed coverage of many of the most popular methods
used in actual practice. The result was that educators had a dicult
time selecting a single textbook or even nding a compact collection
of literature to recommend to their students. Faced with this dilemma
ourselves, we wrote this book in the sincere hope of lling a need.
The contents of the following chapters can be presented in either a
one- or two-semester sequence. Where it was feasible, we have added
supporting material in order to make each chapter as independent as
possible and provide the instructor with as much exibility as possible
when designing the course. Chapters 1315 oer a complete introduction
to the fundamental spectral techniques used in image processing and are
essentially independent of the other material in the text. Depending on
the goals of the instructor and the curriculum, they can be covered in as
much detail as required or completely omitted.
The road map (on page VIII) provides a sequence of topics for a oneor two-semester syllabus.
One Semester: A one-semester course can be organized around either
of two major themes: image processing or image analysis. While
either theme integrates easily into the early semesters of a modern computer science or IT curriculum, image analysis is especially
appropriate as an early foundation course in medical informatics.
Two Semesters: When the content can be presented over two semesters,
it has been designed so that it can be coherently divided (as described below) into two courses (fundamentals and advanced ) where
the themes are grouped according to diculty.
Supplement to the English edition
This book was translated by the authors from the second German edition
(published in 2006) [17], incorporating many enhancements throughout
VII
Advanced
Fundamentals
Image Analysis
Image Processing
Preface
1 Sem.
2 Sem.
the text. In addition to the numerous small corrections and improvements that have been made, the presentation of histogram matching in
Ch. 5, geometric region properties based on moments in Ch. 11, morphological lters in Ch. 10, and interpolation methods in Ch. 16 have been
completely revised. Also, a number of example programs, such as the
single-pass region labeling and contour nding algorithm (Sec. 11.2.2),
have been rewritten for improved clarity and to take advantage of the
new language features in Java 5.
Online resources
Visit the Website for this text
www.imagingbook.com
to download supplementary materials, including the complete Java
source code for the examples, the test images used in the examples, and
corrections. Additional materials are available for educators, including a
complete set of formulas and gures used in the text, in a format suitable
for inclusion in presentations. Comments, questions, and corrections are
welcome and should be addressed to
VIII
Thank you
Preface
This book would not have been possible without the understanding and
support of our families. Our thanks go to Wayne Rasband (NIH) for
developing ImageJ and for his truly outstanding support of the community, to our colleagues Prof. Axel Pinz (TU Graz) and Prof. Vaclav
Hlavac (TU Prague) for their comments, and to all the readers of the rst
two editions who provided valuable input, suggestions for improvement,
and encouragement as we translated this edition. The authors greatly
appreciate the help of their brave Sony and Apple notebooks that performed an estimated 1.6 quadrillion (1015 ) CPU cycles to prepare this
manuscript, thereby consuming about 560 kWh of electric energy and
producing 196 kg of carbon dioxide. Finally, we owe a debt of gratitude to the professionals at Springer-Verlag, Ursula Zimpfer and Jutta
Maria Fleschutz, who led the German edition team, and Wayne Wheeler,
Catherine Brett, and Jerey Taub who were responsible for the English
edition.
IX
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Crunching Pixels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1 Programming with Images . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Image Analysis and Computer Vision . . . . . . . . . . . . . . . . .
1
2
3
Digital Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.1 Types of Digital Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Image Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 The Pinhole Camera Model . . . . . . . . . . . . . . . . . . . .
2.2.2 The Thin Lens . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.3 Going Digital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.4 Image Size and Resolution . . . . . . . . . . . . . . . . . . . . .
2.2.5 Image Coordinate System . . . . . . . . . . . . . . . . . . . . .
2.2.6 Pixel Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Image File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.1 Raster versus Vector Data . . . . . . . . . . . . . . . . . . . . .
2.3.2 Tagged Image File Format (TIFF) . . . . . . . . . . . . . .
2.3.3 Graphics Interchange Format (GIF) . . . . . . . . . . . .
2.3.4 Portable Network Graphics (PNG) . . . . . . . . . . . . .
2.3.5 JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3.6 Windows Bitmap (BMP) . . . . . . . . . . . . . . . . . . . . . .
2.3.7 Portable Bitmap Format (PBM) . . . . . . . . . . . . . . .
2.3.8 Additional File Formats . . . . . . . . . . . . . . . . . . . . . . .
2.3.9 Bits and Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
5
7
8
8
10
11
11
13
14
15
15
16
17
20
21
21
22
24
ImageJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1 Image Manipulation and Processing . . . . . . . . . . . . . . . . . . .
3.2 ImageJ Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.2 Interactive Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.3 ImageJ Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.4 A First Example: Inverting an Image . . . . . . . . . . .
3.3 Additional Information on ImageJ and Java . . . . . . . . . . . .
3.3.1 Resources for ImageJ . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.2 Programming with Java . . . . . . . . . . . . . . . . . . . . . . .
27
28
28
29
30
31
32
35
35
35
XI
3.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Contents
XII
Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.1 What Is a Histogram? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Interpreting Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2.1 Image Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2.2 Image Defects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 Computing Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Histograms of Images with More than 8 Bits . . . . . . . . . . .
4.4.1 Binning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Color Image Histograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.1 Intensity Histograms . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.2 Individual Color Channel Histograms . . . . . . . . . . .
4.5.3 Combined Color Histogram . . . . . . . . . . . . . . . . . . . .
4.6 Cumulative Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37
38
39
40
42
44
46
46
46
47
47
48
48
49
50
51
Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1 Modifying Image Intensity . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.1 Contrast and Brightness . . . . . . . . . . . . . . . . . . . . . . .
5.1.2 Limiting the Results by Clamping . . . . . . . . . . . . . .
5.1.3 Inverting Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.1.4 Threshold Operation . . . . . . . . . . . . . . . . . . . . . . . . . .
5.2 Point Operations and Histograms . . . . . . . . . . . . . . . . . . . . .
5.3 Automatic Contrast Adjustment . . . . . . . . . . . . . . . . . . . . . .
5.4 Modied Auto-Contrast . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.5 Histogram Equalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6 Histogram Specication . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6.1 Frequencies and Probabilities . . . . . . . . . . . . . . . . . .
5.6.2 Principle of Histogram Specication . . . . . . . . . . . .
5.6.3 Adjusting to a Piecewise Linear Distribution . . . . .
5.6.4 Adjusting to a Given Histogram (Histogram
Matching) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.6.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7 Gamma Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.1 Why Gamma? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.2 The Gamma Function . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.3 Real Gamma Values . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.4 Applications of Gamma Correction . . . . . . . . . . . . .
5.7.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5.7.6 Modied Gamma Correction . . . . . . . . . . . . . . . . . . .
5.8 Point Operations in ImageJ . . . . . . . . . . . . . . . . . . . . . . . . . .
5.8.1 Point Operations with Lookup Tables . . . . . . . . . . .
5.8.2 Arithmetic Operations . . . . . . . . . . . . . . . . . . . . . . . .
5.8.3 Point Operations Involving Multiple Images . . . . .
53
54
54
54
55
55
55
57
58
59
62
63
65
65
67
68
72
73
74
74
75
76
76
80
80
81
81
Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1 What Is a Filter? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.1 The Filter Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.2 Applying the Filter . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.3 Computing the Filter Operation . . . . . . . . . . . . . . . .
6.2.4 Filter Plugin Examples . . . . . . . . . . . . . . . . . . . . . . . .
6.2.5 Integer Coecients . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2.6 Filters of Arbitrary Size . . . . . . . . . . . . . . . . . . . . . . .
6.2.7 Types of Linear Filters . . . . . . . . . . . . . . . . . . . . . . . .
6.3 Formal Properties of Linear Filters . . . . . . . . . . . . . . . . . . .
6.3.1 Linear Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.3.2 Properties of Linear Convolution . . . . . . . . . . . . . . .
6.3.3 Separability of Linear Filters . . . . . . . . . . . . . . . . . . .
6.3.4 Impulse Response of a Filter . . . . . . . . . . . . . . . . . . .
6.4 Nonlinear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4.1 Minimum and Maximum Filters . . . . . . . . . . . . . . . .
6.4.2 Median Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4.3 Weighted Median Filter . . . . . . . . . . . . . . . . . . . . . . .
6.4.4 Other Nonlinear Filters . . . . . . . . . . . . . . . . . . . . . . .
6.5 Implementing Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.5.1 Eciency of Filter Programs . . . . . . . . . . . . . . . . . . .
6.5.2 Handling Image Borders . . . . . . . . . . . . . . . . . . . . . . .
6.5.3 Debugging Filter Programs . . . . . . . . . . . . . . . . . . . .
6.6 Filter Operations in ImageJ . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6.1 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6.2 Gaussian Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6.3 Nonlinear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
87
89
89
90
91
92
93
94
95
98
99
100
101
103
104
105
106
107
110
111
111
111
112
113
113
114
115
115
117
117
118
119
119
120
120
123
123
125
125
126
126
Contents
XIII
127
127
127
129
130
130
133
137
Corner Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1 Points of Interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2 Harris Corner Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.2.1 Local Structure Matrix . . . . . . . . . . . . . . . . . . . . . . . .
8.2.2 Corner Response Function (CRF) . . . . . . . . . . . . . .
8.2.3 Determining Corner Points . . . . . . . . . . . . . . . . . . . .
8.2.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.3.1 Step 1: Computing the Corner Response Function
8.3.2 Step 2: Selecting Good Corner Points . . . . . . . . .
8.3.3 Displaying the Corner Points . . . . . . . . . . . . . . . . . .
8.3.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
139
139
140
140
141
142
142
142
144
148
152
152
153
155
155
156
157
159
159
160
161
163
165
167
167
170
170
10 Morphological Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.1 Shrink and Let Grow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.1.1 Neighborhood of Pixels . . . . . . . . . . . . . . . . . . . . . . .
10.2 Basic Morphological Operations . . . . . . . . . . . . . . . . . . . . . .
10.2.1 The Structuring Element . . . . . . . . . . . . . . . . . . . . . .
10.2.2 Point Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.3 Dilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.4 Erosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10.2.5 Properties of Dilation and Erosion . . . . . . . . . . . . . .
173
174
175
175
175
176
177
178
178
Contents
XIV
180
181
183
185
185
186
187
187
187
188
189
189
191
193
194
194
196
199
200
200
204
209
209
209
212
213
216
216
216
218
219
222
222
223
226
228
233
234
235
12 Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.1 RGB Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.1.1 Organization of Color Images . . . . . . . . . . . . . . . . . .
12.1.2 Color Images in ImageJ . . . . . . . . . . . . . . . . . . . . . . .
12.2 Color Spaces and Color Conversion . . . . . . . . . . . . . . . . . . .
12.2.1 Conversion to Grayscale . . . . . . . . . . . . . . . . . . . . . . .
239
239
241
244
253
256
10.3
10.4
10.5
10.6
Contents
XV
257
258
267
271
275
276
281
283
288
288
292
299
299
299
301
303
305
311
313
314
314
317
318
319
320
321
325
325
330
332
332
334
334
338
339
340
340
342
342
343
343
344
344
345
348
Contents
12.3
12.4
12.5
12.6
XVI
348
348
349
350
350
351
352
352
354
359
359
363
364
364
366
367
367
368
368
370
371
371
371
373
16 Geometric Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1 2D Mapping Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.1 Simple Mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.2 Homogeneous Coordinates . . . . . . . . . . . . . . . . . . . . .
16.1.3 Ane (Three-Point) Mapping . . . . . . . . . . . . . . . . . .
16.1.4 Projective (Four-Point) Mapping . . . . . . . . . . . . . . .
16.1.5 Bilinear Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.1.6 Other Nonlinear Image Transformations . . . . . . . . .
16.1.7 Local Image Transformations . . . . . . . . . . . . . . . . . .
16.2 Resampling the Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.2.1 Source-to-Target Mapping . . . . . . . . . . . . . . . . . . . . .
16.2.2 Target-to-Source Mapping . . . . . . . . . . . . . . . . . . . . .
16.3 Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.1 Simple Interpolation Methods . . . . . . . . . . . . . . . . . .
16.3.2 Ideal Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.3 Interpolation by Convolution . . . . . . . . . . . . . . . . . .
16.3.4 Cubic Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.5 Spline Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.6 Lanczos Interpolation . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.7 Interpolation in 2D . . . . . . . . . . . . . . . . . . . . . . . . . . .
16.3.8 Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
375
376
377
377
378
380
385
386
389
390
390
391
392
392
393
397
397
399
402
404
410
Contents
XVII
413
413
423
426
427
17 Comparing Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.1 Template Matching in Intensity Images . . . . . . . . . . . . . . . .
17.1.1 Distance between Image Patterns . . . . . . . . . . . . . . .
17.1.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.1.3 Matching under Rotation and Scaling . . . . . . . . . . .
17.2 Matching Binary Images . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.2.1 Direct Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.2.2 The Distance Transform . . . . . . . . . . . . . . . . . . . . . . .
17.2.3 Chamfer Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
429
430
431
438
439
441
441
442
446
447
Mathematical Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.1 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 Set Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.4 Algorithmic Complexity and O Notation . . . . . . . . . . . . . .
451
451
453
453
454
Java Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.1 Integer Division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.2 Modulus Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.3 Unsigned Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.4 Mathematical Functions (Class Math) . . . . . . . . . . .
B.1.5 Rounding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.1.6 Inverse Tangent Function . . . . . . . . . . . . . . . . . . . . . .
B.1.7 Float and Double (Classes) . . . . . . . . . . . . . . . . . . .
B.2 Arrays and Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2.1 Creating Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2.2 Array Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2.3 Accessing Array Elements . . . . . . . . . . . . . . . . . . . . .
B.2.4 Two-Dimensional Arrays . . . . . . . . . . . . . . . . . . . . . .
B.2.5 Cloning Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B.2.6 Arrays of Objects, Sorting . . . . . . . . . . . . . . . . . . . . .
B.2.7 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
457
457
457
459
459
460
461
462
462
462
462
463
463
464
465
466
467
469
469
471
471
471
472
Contents
XVIII
Contents
XIX
Contents
500
502
504
504
505
506
506
509
510
511
512
512
513
514
515
515
517
518
518
519
520
521
521
522
522
523
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.1 Harris Corner Detector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.1.1 Harris_Corner_Plugin (Class) . . . . . . . . . . . . . . . .
D.1.2 File Corner (Class) . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.1.3 File HarrisCornerDetector (Class) . . . . . . . . . . . .
D.2 Combined Region Labeling and Contour Tracing . . . . . . .
D.2.1 Contour_Tracing_Plugin (Class) . . . . . . . . . . . . . .
D.2.2 Contour (Class) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.2.3 BinaryRegion (Class) . . . . . . . . . . . . . . . . . . . . . . . .
D.2.4 ContourTracer (Class) . . . . . . . . . . . . . . . . . . . . . . .
D.2.5 ContourOverlay (Class) . . . . . . . . . . . . . . . . . . . . . .
525
525
525
527
527
532
532
533
535
536
541
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
XX