Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.
com
Digital Image Processing An Algorithmic
Introduction 3rd Edition Wilhelm Burger
https://ebookmeta.com/product/digital-image-processing-an-
algorithmic-introduction-3rd-edition-wilhelm-burger/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.
Digital Signal Processing An Introduction D Sundararajan
https://ebookmeta.com/product/digital-signal-processing-an-
introduction-d-sundararajan/
ebookmeta.com
Digital Image Processing 1st Edition A. Baskar
https://ebookmeta.com/product/digital-image-processing-1st-edition-a-
baskar/
ebookmeta.com
Digital Image Processing with Application to Digital
Cinema 1st Edition Ks Thyagarajan
https://ebookmeta.com/product/digital-image-processing-with-
application-to-digital-cinema-1st-edition-ks-thyagarajan/
ebookmeta.com
The Fairchild Books Dictionary of Textiles, 9th Edition
Ajoy K. Sarkar
https://ebookmeta.com/product/the-fairchild-books-dictionary-of-
textiles-9th-edition-ajoy-k-sarkar/
ebookmeta.com
Legacy of Shadows 1st Edition Mark Wells
https://ebookmeta.com/product/legacy-of-shadows-1st-edition-mark-
wells/
ebookmeta.com
Designing the Patient Room A New Approach to Healthcare
Interiors 1st Edition Sylvia Leydecker
https://ebookmeta.com/product/designing-the-patient-room-a-new-
approach-to-healthcare-interiors-1st-edition-sylvia-leydecker/
ebookmeta.com
Embedded Analytics: Integrating analysis with the business
workflow (Second Early Release) Donald Farmer
https://ebookmeta.com/product/embedded-analytics-integrating-analysis-
with-the-business-workflow-second-early-release-donald-farmer/
ebookmeta.com
A World to Live In An Ecologist s Vision for a Plundered
Planet 1st Edition George M Woodwell
https://ebookmeta.com/product/a-world-to-live-in-an-ecologist-s-
vision-for-a-plundered-planet-1st-edition-george-m-woodwell/
ebookmeta.com
Gods of Want: Stories 1st Edition K-Ming Chang
https://ebookmeta.com/product/gods-of-want-stories-1st-edition-k-ming-
chang/
ebookmeta.com
P-graphs for Process Systems Engineering 1st Edition
Ferenc Friedler
https://ebookmeta.com/product/p-graphs-for-process-systems-
engineering-1st-edition-ferenc-friedler/
ebookmeta.com
Texts in Computer Science
Wilhelm Burger
Mark J. Burge
Digital Image
Processing
An Algorithmic Introduction
Third Edition
Texts in Computer Science
Series Editors
David Gries, Department of Computer Science, Cornell University, Ithaca,
NY, USA
Orit Hazzan , Faculty of Education in Technology and Science,
Technion—Israel Institute of Technology, Haifa, Israel
Titles in this series now included in the Thomson Reuters Book Citation
Index!
‘Texts in Computer Science’ (TCS) delivers high-quality instructional
content for undergraduates and graduates in all areas of computing and
information science, with a strong emphasis on core foundational and
theoretical material but inclusive of some prominent applications-related
content. TCS books should be reasonably self-contained and aim to provide
students with modern and clear accounts of topics ranging across the
computing curriculum. As a result, the books are ideal for semester courses
or for individual self-study in cases where people need to expand their
knowledge. All texts are authored by established experts in their fields,
reviewed internally and by the series editors, and provide numerous
examples, problems, and other pedagogical tools; many contain fully worked
solutions.
The TCS series is comprised of high-quality, self-contained books that
have broad and comprehensive coverage and are generally in hardback
format and sometimes contain color. For undergraduate textbooks that are
likely to be more brief and modular in their approach, require only black and
white, and are under 275 pages, Springer offers the flexibly designed
Undergraduate Topics in Computer Science series, to which we refer
potential authors.
Wilhelm Burger Mark J. Burge
•
Digital Image Processing
An Algorithmic Introduction
Third Edition
123
Wilhelm Burger Mark J. Burge
University of Applied Sciences Federal Bureau of Investigation
Upper Austria Quantico, VA, USA
Hagenberg, Austria
ISSN 1868-0941 ISSN 1868-095X (electronic)
Texts in Computer Science
ISBN 978-3-031-05743-4 ISBN 978-3-031-05744-1 (eBook)
https://doi.org/10.1007/978-3-031-05744-1
1st & 2nd edition: © Springer-Verlag London 2008, 2016
3rd edition: © Springer Nature Switzerland AG 2022
This is a U.S. government work and not under copyright protection in the U.S.; foreign copyright
protection may apply 2022
All rights are reserved by the Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting,
reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology
now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are
exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in
this book are believed to be true and accurate at the date of publication. Neither the publisher nor
the authors or the editors give a warranty, expressed or implied, with respect to the material
contained herein or for any errors or omissions that may have been made. The publisher remains
neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
This book provides a modern, self-contained introduction to digital
image processing. We designed this book to be used both by learners
desiring a firm foundation on which to build as well as practitioners
in search of detailed analysis and transparent implementations of the
most important techniques. This is the third English edition of the
original German-language 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 solu-
tions to imaging problems in their field.
• IT professionals in search of 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 text-
book suitable for an advanced undergraduate or graduate level
course that features exercises, projects, and examples that have
been honed during quite some years of experience teaching this
material.
While we concentrate on practical applications and concrete imple-
mentations, 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
different perspectives: in mathematical form, as abstract pseudocode
algorithms, and as complete Java programs. We use a common no-
tation to intertwine all three perspectives—providing multiple, but
intimately linked, views of problems and their solution.
Prerequisites
Instead of presenting digital image processing as a mathematical dis-
cipline, or strictly as a signal processing topic, we present it from a
practitioner’s and programmer’s 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 beneficial. We selected Java for a number of reasons: it is
the first programming language learned by students in a wide vari-
ety of engineering curricula, and professionals with knowledge of a
V
Preface related language, especially C# or C++, will find 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 the National Institutes of Health
(NIH).1 ImageJ is implemented completely in Java, and therefore
runs on all major platforms. It is popular because its “plugin”-based
architecture enables it to be easily extended. While all examples run
in ImageJ, they have been specifically 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 sup-
plement our detailed presentation of the fundamental concepts and
techniques. As both practitioners and developers, we know that the
details required to successfully understand, apply, and extend classi-
cal techniques are often difficult to find, and for this reason we have
been very careful to provide the missing details, many gleaned over
years of practical application. While this should make the text par-
ticularly valuable to those in research and development, it is not de-
signed as a comprehensive, fully-cited scientific 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 briefly
discussed the fundamentals of, or entirely omitted, topics such as
hierarchical methods, wavelets, or eigenimages because of space lim-
itations, other topics have been left out deliberately, including ad-
vanced issues such as object recognition, image understanding, and
three-dimensional (3D) 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 founding methods are essential to the success of any higher-
level, perhaps really “intelligent” techniques built on top of them.
If you are only in search of a programming handbook for Im-
ageJ or Java, there are certainly better sources. While the book
includes many code examples, programming in and of itself is not
our main focus. Instead Java serves as just one important element
for describing each technique in a precise and immediately testable
way.
Classroom Use
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 flows, it has
become an integral part of the required skill set for professionals in
many diverse disciplines.
Today the topic has migrated into the early stages of many curric-
ula, where it is often a key foundation course. This trend uncovered a
1
https://rsb.info.nih.gov/ij/
VI
problem in that many of the texts relied on as standards in the older Preface
graduate-level courses were not appropriate for beginners. The texts
were usually too formal for novices, 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 difficult time
selecting a single textbook or even finding a compact collection of
literature to recommend to their students. Faced with this dilemma
ourselves, we wrote this book in the sincere hope of filling this gap.
The contents of the following chapters can be presented in ei-
ther a one- or two-semester sequence. Where feasible, we have added
supporting material in order to make each chapter as independent
as possible, providing instructors with maximum flexibility when de-
signing the course. Chapters 18–20 offer a compact introduction to
the use of spectral techniques 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 following road map
shows a possible partitioning of topics for a two-semester syllabus.
Road Map for a 2-Semester Syllabus Sem. 1 2
1. Digital Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
2. Histograms and Image Statistics . . . . . . . . . . . . . . . . . . . . . . ■ □
3. Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
4. Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
5. Edges and Contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
6. Corner Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
7. Morphological Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
8. Regions in Binary Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
9. Automatic Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
10. Fitting Straight Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
11. Fitting Circles and Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
12. Detecting Geometric Primitives . . . . . . . . . . . . . . . . . . . . . . . □ ■
13. Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
14. Colorimetric Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
15. Filters for Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
16. Edge Detection in Color Images . . . . . . . . . . . . . . . . . . . . . . . □ ■
17. Edge-Preserving Smoothing Filters . . . . . . . . . . . . . . . . . . . . □ ■
18. Introduction to Spectral Techniques . . . . . . . . . . . . . . . . . . . □ ■
19. The Discrete Fourier Transform in 2D . . . . . . . . . . . . . . . . . □ ■
20. The Discrete Cosine Transform (DCT) . . . . . . . . . . . . . . . . □ ■
21. Geometric Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
22. Pixel Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ■ □
23. Image Matching and Registration . . . . . . . . . . . . . . . . . . . . . ■ □
24. Non-Rigid Image Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . □ ■
25. Scale-Invariant Local Features (SIFT) . . . . . . . . . . . . . . . . . □ ■
26. Maximally Stable Extremal Regions (MSER) . . . . . . . . . . □ ■
Addendum To The 3rd Edition
This third (and presumably final) edition offers carefully revised con-
tents and adds some new topics that round off the original material.
In particular, there are new chapters on circle and ellipse fitting,
VII
Preface geometric primitive detection and local feature extraction. The ap-
pendix has been greatly expanded and contains numerous additions
that should be helpful for concrete implementations as well as for
reference. This includes small numerical examples, which are often
helpful for the understanding of a problem and allow a quick check
of one’s own calculations.
Special attention was paid to the concise description of all meth-
ods in the form of easily understandable algorithms, not least to make
the descriptions as independent as possible from concrete program-
ming languages. In fact, we think that the consistent algorithmic
description, which was significantly improved again in this edition, is
really a unique feature of this book. On the other hand, we have rel-
egated the concrete program examples somewhat to the background
without sacrificing the most essential elements, especially since vir-
tually all examples are also available online. In fact, most algorithms
are implemented one-to-one in the associated imagingbook software
library, so readers can always check in case of any ambiguities in the
mathematical notation. All newly added concepts and associated
demo programs have been implemented in this library, which will be
continuously maintained and extended in the future.
Unfortunately, this third edition had to be prepared without the
helping hand of the second author, therefore the blame for any errors
that were either newly added or overlooked in the existing text lies
solely with me (i.e., the first author). Readers will hopefully be merci-
ful in view of the fact that there was no native speaker at work this
time.
Online Resources and Contact
Visit the website for this book
www.imagingbook.com
to download supplementary materials, including the complete (and
free)2 Java source code for all examples and the underlying software
library, full-size test images, useful references, and other supplements.
Comments, questions, and corrections are welcome and should be
addressed to
[email protected] Exercises and Solutions
Almost every chapter of this book contains a set of sample exercises,
mainly for supporting instructors to prepare their own assignments.
Most of these tasks are easy to solve after studying the corresponding
chapter, while some others may require more elaborated reasoning or
experimental work. We assume that scholars know best how to select
and adapt individual assignments in order to fit the level and interest
of their students. This is the main reason why we have abstained from
publishing explicit solutions in the past. However, we are happy to
2
The imagingbook software suite is published under the 2-Clause BSD
License (see https://opensource.org/licenses/BSD-2-Clause).
VIII
answer any personal request if an exercise is unclear or seems to elude Preface
a simple solution.
Thank You!
This book would not have been possible without the understanding
and support of our families. Our thanks go to Wayne Rasband at
NIH for developing ImageJ and for his truly outstanding support of
the community and to all our readers of the previous editions who
provided valuable input, suggestions for improvement, and encour-
agement. The use of open source software for such a project always
carries an element of risk, since the long-term acceptance and conti-
nuity is difficult to assess. Retrospectively, choosing ImageJ as the
software basis for this work was a good decision, and we would con-
sider ourselves happy if our books have perhaps contributed to the
success of the ImageJ project itself. Finally, we owe a debt of grati-
tude to the professionals at Springer, particularly to Wayne Wheeler
and his team who again patiently accompanied the production of this
edition.
W.B. and M.J.B.
Spring 2022
IX
Contents
Part I Images and Pixels
1 Digital Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Programming with Images . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Image Analysis and Computer Vision . . . . . . . . . . . . . 4
1.3 Types of Digital Images . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Image Acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.1 The Pinhole Camera Model . . . . . . . . . . . . . . . 6
1.4.2 The “Thin” Lens . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.3 Going Digital . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4.4 Image Size and Resolution . . . . . . . . . . . . . . . . 10
1.4.5 Image Coordinate System . . . . . . . . . . . . . . . . . 11
1.4.6 Pixel Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.5 Image File Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.1 Raster Versus Vector Data . . . . . . . . . . . . . . . . 14
1.5.2 Tagged Image File Format (TIFF) . . . . . . . . . 14
1.5.3 Graphics Interchange Format (GIF) . . . . . . . . 15
1.5.4 Portable Network Graphics (PNG) . . . . . . . . . 16
1.5.5 JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.5.6 Legacy File Formats . . . . . . . . . . . . . . . . . . . . . 20
1.5.7 Bits and Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.6 Software for Digital Imaging . . . . . . . . . . . . . . . . . . . . 23
1.7 ImageJ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.7.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
1.7.2 Interactive Tools . . . . . . . . . . . . . . . . . . . . . . . . . 25
1.7.3 Working With ImageJ and Java . . . . . . . . . . . 25
1.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2 Histograms and Image Statistics . . . . . . . . . . . . . . . . . . 29
2.1 What is a Histogram? . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2 Interpreting Histograms . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2.1 Image Acquisition . . . . . . . . . . . . . . . . . . . . . . . . 31
2.2.2 Image Defects . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.3 Calculating Histograms . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.4 Histograms of Images With More Than 8 Bits . . . . . 37
2.4.1 Binning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.4.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.4.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.5 Histograms of Color Images . . . . . . . . . . . . . . . . . . . . . 38
2.5.1 Intensity Histograms . . . . . . . . . . . . . . . . . . . . . 39
2.5.2 Individual Color Channel Histograms . . . . . . . 39
2.5.3 Combined Color Histograms . . . . . . . . . . . . . . 40
XI
Contents 2.6 The Cumulative Histogram . . . . . . . . . . . . . . . . . . . . . 41
2.7 Statistical Information from the Histogram . . . . . . . . 41
2.7.1 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . 42
2.7.2 Median . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.8 Block Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.8.1 Integral Images . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.8.2 Mean Intensity . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.8.3 Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
2.8.4 Practical Calculation of Integral Images . . . . 45
2.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3 Point Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.1 Modifying Image Intensity . . . . . . . . . . . . . . . . . . . . . . 50
3.1.1 Contrast and Brightness . . . . . . . . . . . . . . . . . . 50
3.1.2 Limiting Values by Clamping . . . . . . . . . . . . . . 50
3.1.3 Inverting Images . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1.4 Thresholding Operation . . . . . . . . . . . . . . . . . . 51
3.2 Point Operations and Histograms . . . . . . . . . . . . . . . . 51
3.3 Automatic Contrast Adjustment . . . . . . . . . . . . . . . . . 52
3.4 Modified Auto-Contrast Operation . . . . . . . . . . . . . . . 54
3.5 Histogram Equalization . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.6 Histogram Specification . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.6.1 Frequencies and Probabilities . . . . . . . . . . . . . . 58
3.6.2 Principle of Histogram Specification . . . . . . . . 59
3.6.3 Adjusting to a Piecewise Linear Distribution 60
3.6.4 Adjusting to a Given Histogram (Histogram
Matching) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.6.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
3.7 Gamma Correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.7.1 Why “Gamma”? . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.7.2 Mathematical Definition . . . . . . . . . . . . . . . . . . 68
3.7.3 Real Gamma Values . . . . . . . . . . . . . . . . . . . . . 69
3.7.4 Applications of Gamma Correction . . . . . . . . . 70
3.7.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 71
3.7.6 Modified Gamma Correction . . . . . . . . . . . . . . 71
3.8 Point Operations in ImageJ . . . . . . . . . . . . . . . . . . . . . 74
3.8.1 Point Operations with Lookup Tables . . . . . . 74
3.8.2 Arithmetic Operations . . . . . . . . . . . . . . . . . . . 75
3.8.3 Point Operations Involving Multiple Images . 75
3.8.4 Methods for Point Operations on Two Images 76
3.8.5 ImageJ Plugins Involving Multiple Images . . 76
3.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Part II Filters, Edges and Corners
4 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.1 What is a Filter? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.2 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.2.1 The Filter Kernel . . . . . . . . . . . . . . . . . . . . . . . . 87
4.2.2 Applying the Filter . . . . . . . . . . . . . . . . . . . . . . 87
4.2.3 Implementing Filter Operations . . . . . . . . . . . 88
4.2.4 Filter Plugin Examples . . . . . . . . . . . . . . . . . . . 89
XII
4.2.5 Integer Coefficients . . . . . . . . . . . . . . . . . . . . . . . 91 Contents
4.2.6 Filters of Arbitrary Size . . . . . . . . . . . . . . . . . . 92
4.2.7 Types of Linear Filters . . . . . . . . . . . . . . . . . . . 92
4.3 Formal Properties of Linear Filters . . . . . . . . . . . . . . . 95
4.3.1 Linear Convolution . . . . . . . . . . . . . . . . . . . . . . 96
4.3.2 Formal Properties of Linear Convolution . . . . 96
4.3.3 Separability of Linear Filters . . . . . . . . . . . . . . 98
4.3.4 Impulse Response of a Filter . . . . . . . . . . . . . . 99
4.4 Nonlinear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
4.4.1 Minimum and Maximum Filters . . . . . . . . . . . 101
4.4.2 Median Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
4.4.3 Weighted Median Filter . . . . . . . . . . . . . . . . . . 105
4.4.4 Other Nonlinear Filters . . . . . . . . . . . . . . . . . . . 107
4.5 Implementing Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
4.5.1 Efficiency of Filter Programs . . . . . . . . . . . . . . 108
4.5.2 Handling Image Borders . . . . . . . . . . . . . . . . . . 109
4.5.3 Debugging Filter Programs . . . . . . . . . . . . . . . 110
4.6 Filter Operations in ImageJ . . . . . . . . . . . . . . . . . . . . . 111
4.6.1 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.6.2 Gaussian Filters . . . . . . . . . . . . . . . . . . . . . . . . . 112
4.6.3 Nonlinear Filters . . . . . . . . . . . . . . . . . . . . . . . . 112
4.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
5 Edges and Contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
5.1 What Makes an Edge? . . . . . . . . . . . . . . . . . . . . . . . . . . 117
5.2 Gradient-Based Edge Detection . . . . . . . . . . . . . . . . . . 118
5.2.1 Partial Derivatives and the Gradient . . . . . . . 119
5.2.2 Derivative Filters . . . . . . . . . . . . . . . . . . . . . . . . 119
5.3 Simple Edge Operators . . . . . . . . . . . . . . . . . . . . . . . . . 120
5.3.1 Prewitt and Sobel Edge Operators . . . . . . . . . 121
5.3.2 Roberts Edge Operator . . . . . . . . . . . . . . . . . . . 124
5.3.3 Compass Operators . . . . . . . . . . . . . . . . . . . . . . 124
5.3.4 Edge Operators in ImageJ . . . . . . . . . . . . . . . . 126
5.4 Other Edge Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 126
5.4.1 Edge Detection Based on Second Derivatives 126
5.4.2 Edges at Different Scales . . . . . . . . . . . . . . . . . 126
5.4.3 From Edges to Contours . . . . . . . . . . . . . . . . . . 127
5.5 Canny Edge Operator . . . . . . . . . . . . . . . . . . . . . . . . . . 128
5.5.1 Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
5.5.2 Edge Localization . . . . . . . . . . . . . . . . . . . . . . . . 130
5.5.3 Edge Tracing and Hysteresis Thresholding . . 131
5.5.4 Additional Information . . . . . . . . . . . . . . . . . . . 133
5.5.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 134
5.6 Edge Sharpening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
5.6.1 Edge Sharpening with the Laplacian Filter . . 135
5.6.2 Unsharp Masking . . . . . . . . . . . . . . . . . . . . . . . . 137
5.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
6 Corner Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
6.1 Points of Interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
6.2 Harris Corner Detector . . . . . . . . . . . . . . . . . . . . . . . . . 146
6.2.1 The Local Structure Matrix . . . . . . . . . . . . . . . 146
XIII
Contents 6.2.2 Significance of the Local Structure Matrix . . 147
6.2.3 Corner Response Function (CRF) . . . . . . . . . . 150
6.2.4 Selecting Corner Points . . . . . . . . . . . . . . . . . . . 150
6.2.5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6.3 Alternative Formulations . . . . . . . . . . . . . . . . . . . . . . . 152
6.3.1 Shi-Tomasi Corner Score . . . . . . . . . . . . . . . . . . 152
6.3.2 MOPS Corner Score . . . . . . . . . . . . . . . . . . . . . 154
6.4 Basic Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 154
6.4.1 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
6.5 Sub-Pixel Corner Positions . . . . . . . . . . . . . . . . . . . . . . 161
6.5.1 Position Interpolation by Second-Order
Taylor Expansion . . . . . . . . . . . . . . . . . . . . . . . . 161
6.5.2 Sub-Pixel Positioning Example . . . . . . . . . . . . 162
6.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Part III Binary Images
7 Morphological Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
7.1 Shrink and Let Grow . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
7.1.1 Pixel Neighborhoods . . . . . . . . . . . . . . . . . . . . . 169
7.2 Basic Morphological Operations . . . . . . . . . . . . . . . . . 170
7.2.1 The Structuring Element . . . . . . . . . . . . . . . . . 170
7.2.2 Point Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
7.2.3 Dilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
7.2.4 Erosion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
7.2.5 Formal Properties of Dilation and Erosion . . 172
7.2.6 Designing Morphological Filters . . . . . . . . . . . 173
7.2.7 Application Example: Outline . . . . . . . . . . . . . 176
7.3 Composite Morphological Operations . . . . . . . . . . . . . 177
7.3.1 Opening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.3.2 Closing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
7.3.3 Properties of Opening and Closing . . . . . . . . . 179
7.4 Thinning (Skeletonization) . . . . . . . . . . . . . . . . . . . . . . 180
7.4.1 Basic Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 180
7.4.2 Fast Thinning Algorithm . . . . . . . . . . . . . . . . . 181
7.4.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . 185
7.4.4 Built-in Morphological Operations in ImageJ 186
7.5 Grayscale Morphology . . . . . . . . . . . . . . . . . . . . . . . . . . 187
7.5.1 Structuring Elements . . . . . . . . . . . . . . . . . . . . . 187
7.5.2 Dilation and Erosion . . . . . . . . . . . . . . . . . . . . . 188
7.5.3 Grayscale Opening and Closing . . . . . . . . . . . . 188
7.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
8 Regions in Binary Images . . . . . . . . . . . . . . . . . . . . . . . . . 195
8.1 Finding Connected Image Regions . . . . . . . . . . . . . . . 196
8.1.1 Region Labeling by Flood Filling . . . . . . . . . . 196
8.1.2 Sequential Region Segmentation . . . . . . . . . . . 201
8.1.3 Region Labeling – Summary . . . . . . . . . . . . . . 205
8.2 Region Contours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
8.2.1 Outer and Inner Contours . . . . . . . . . . . . . . . . 206
8.2.2 Combining Region Labeling and Contour
Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
XIV
8.2.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . 210 Contents
8.3 Representing Image Regions . . . . . . . . . . . . . . . . . . . . . 212
8.3.1 Matrix Representation . . . . . . . . . . . . . . . . . . . . 212
8.3.2 Run Length Encoding . . . . . . . . . . . . . . . . . . . . 213
8.3.3 Chain Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.4 Properties of Binary Regions . . . . . . . . . . . . . . . . . . . . 216
8.4.1 Shape Features . . . . . . . . . . . . . . . . . . . . . . . . . . 217
8.4.2 Geometric Features . . . . . . . . . . . . . . . . . . . . . . 217
8.5 Statistical Shape Properties . . . . . . . . . . . . . . . . . . . . . 220
8.5.1 Centroid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
8.5.2 Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
8.5.3 Central Moments . . . . . . . . . . . . . . . . . . . . . . . . 221
8.5.4 Normalized Central Moments . . . . . . . . . . . . . 222
8.5.5 Java Implementation . . . . . . . . . . . . . . . . . . . . . 222
8.6 Moment-Based Geometric Properties . . . . . . . . . . . . . 223
8.6.1 Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
8.6.2 Region Eccentricity . . . . . . . . . . . . . . . . . . . . . . 224
8.6.3 Equivalent Ellipse . . . . . . . . . . . . . . . . . . . . . . . . 226
8.6.4 Bounding Box Aligned to the Major Axis . . . 226
8.6.5 Invariant Region Moments . . . . . . . . . . . . . . . . 227
8.7 Projections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
8.8 Topological Region Properties . . . . . . . . . . . . . . . . . . . 233
8.9 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
8.10 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
9 Automatic Thresholding . . . . . . . . . . . . . . . . . . . . . . . . . . 241
9.1 Global Histogram-Based Thresholding . . . . . . . . . . . . 241
9.1.1 Image Statistics from the Histogram . . . . . . . 243
9.1.2 Simple Threshold Selection . . . . . . . . . . . . . . . . 244
9.1.3 Iterative Threshold Selection (Isodata
Algorithm) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
9.1.4 Otsu’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.1.5 Maximum Entropy Thresholding . . . . . . . . . . . 251
9.1.6 Minimum Error Thresholding . . . . . . . . . . . . . 254
9.2 Local Adaptive Thresholding . . . . . . . . . . . . . . . . . . . . 261
9.2.1 Bernsen’s Method . . . . . . . . . . . . . . . . . . . . . . . . 262
9.2.2 Niblack’s Method . . . . . . . . . . . . . . . . . . . . . . . . 264
9.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
9.3.1 Global Thresholding Methods . . . . . . . . . . . . . 274
9.3.2 Adaptive Thresholding . . . . . . . . . . . . . . . . . . . 275
9.4 Summary and Further Reading . . . . . . . . . . . . . . . . . . 275
9.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Part IV Geometric Primitives
10 Fitting Straight Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
10.1 Straight Line Equations . . . . . . . . . . . . . . . . . . . . . . . . 281
10.1.1 Slope-Intercept Form . . . . . . . . . . . . . . . . . . . . . 281
10.1.2 Parametric (Point-Vector) Form . . . . . . . . . . . 282
10.1.3 Algebraic Form . . . . . . . . . . . . . . . . . . . . . . . . . . 282
10.1.4 Hessian Normal Form . . . . . . . . . . . . . . . . . . . . 284
10.2 Fitting Lines to Points Sets . . . . . . . . . . . . . . . . . . . . . 284
XV
Contents 10.2.1 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . 285
10.2.2 Orthogonal Regression . . . . . . . . . . . . . . . . . . . 286
10.3 Example: Contour Segmentation . . . . . . . . . . . . . . . . . 290
10.4 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
10.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
11 Fitting Circles and Ellipses . . . . . . . . . . . . . . . . . . . . . . . 297
11.1 Fitting Circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.1.1 Circle Equations . . . . . . . . . . . . . . . . . . . . . . . . . 297
11.1.2 Algebraic Circle Fits . . . . . . . . . . . . . . . . . . . . . 298
11.1.3 Geometric Circle Fitting . . . . . . . . . . . . . . . . . . 305
11.2 Fitting Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
11.2.1 Algebraic Ellipse Fitting . . . . . . . . . . . . . . . . . . 314
11.2.2 Geometric Ellipse Fitting . . . . . . . . . . . . . . . . . 323
11.2.3 Orthogonal Distance Approximations . . . . . . . 331
11.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
11.3.1 Circle Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
11.3.2 Ellipse Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
12 Detecting Geometric Primitives . . . . . . . . . . . . . . . . . . 341
12.1 Random Sample Consensus (RANSAC) . . . . . . . . . . . 343
12.1.1 How Many Random Draws Are Needed? . . . . 344
12.1.2 RANSAC Line Detection Algorithm . . . . . . . . 345
12.1.3 Detecting Multiple Lines . . . . . . . . . . . . . . . . . . 346
12.1.4 RANSAC Circle Detection . . . . . . . . . . . . . . . . 348
12.1.5 RANDSAC Ellipse Detection . . . . . . . . . . . . . . 352
12.1.6 RANSAC Extensions and Applications . . . . . 355
12.2 The Hough Transform . . . . . . . . . . . . . . . . . . . . . . . . . . 355
12.2.1 Parameter Space . . . . . . . . . . . . . . . . . . . . . . . . . 356
12.2.2 Accumulator Map . . . . . . . . . . . . . . . . . . . . . . . . 357
12.2.3 A Better Line Representation . . . . . . . . . . . . . 357
12.2.4 Hough Algorithm . . . . . . . . . . . . . . . . . . . . . . . . 359
12.2.5 Hough Transform Extensions . . . . . . . . . . . . . . 363
12.2.6 Hough Transform for Circles and Arcs . . . . . . 366
12.2.7 Hough Transform for Ellipses . . . . . . . . . . . . . . 369
12.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
12.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Part V Color
13 Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
13.1 RGB Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
13.1.1 Structure of Color Images . . . . . . . . . . . . . . . . . 376
13.1.2 Color Images in ImageJ . . . . . . . . . . . . . . . . . . 379
13.2 Color Spaces and Color Conversion . . . . . . . . . . . . . . . 387
13.2.1 Conversion to Grayscale . . . . . . . . . . . . . . . . . . 387
13.2.2 Desaturating RGB Color Images . . . . . . . . . . . 389
13.2.3 HSV/HSB and HLS Color Spaces . . . . . . . . . . 389
13.2.4 TV Component Color Spaces: YUV, YIQ,
and YCbCr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
13.2.5 Color Spaces for Printing: CMY and CMYK 403
13.3 Statistics of Color Images . . . . . . . . . . . . . . . . . . . . . . . 406
XVI
13.3.1 How Many Different Colors Are in an Image? 406 Contents
13.3.2 Color Histograms . . . . . . . . . . . . . . . . . . . . . . . . 407
13.4 Color Quantization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
13.4.1 Scalar Color Quantization . . . . . . . . . . . . . . . . 410
13.4.2 Vector Quantization . . . . . . . . . . . . . . . . . . . . . . 412
13.4.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . 419
13.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
14 Colorimetric Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . 425
14.1 CIE Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
14.1.1 CIE XYZ Color Space . . . . . . . . . . . . . . . . . . . . 426
14.1.2 CIE x, y Chromaticity . . . . . . . . . . . . . . . . . . . . 426
14.1.3 Standard Illuminants . . . . . . . . . . . . . . . . . . . . . 428
14.1.4 Gamut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
14.1.5 Variants of the CIE Color Space . . . . . . . . . . . 429
14.2 CIELAB Color Space . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
14.2.1 CIEXYZ → CIELAB Conversion . . . . . . . . . . 430
14.2.2 CIELAB → CIEXYZ Conversion . . . . . . . . . . 431
14.3 CIELUV Color Space . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
14.3.1 CIEXYZ → CIELUV Conversion . . . . . . . . . . 432
14.3.2 CIELUV→ CIEXYZ Conversion . . . . . . . . . . . 433
14.3.3 Measuring Color Differences . . . . . . . . . . . . . . . 434
14.4 Standard RGB (sRGB) . . . . . . . . . . . . . . . . . . . . . . . . . 434
14.4.1 Linear vs. Nonlinear Color Components . . . . 435
14.4.2 CIEXYZ → sRGB Conversion . . . . . . . . . . . . . 436
14.4.3 sRGB → CIEXYZ Conversion . . . . . . . . . . . . . 436
14.4.4 Calculations with Nonlinear sRGB Values . . . 437
14.5 Adobe RGB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
14.6 Chromatic Adaptation . . . . . . . . . . . . . . . . . . . . . . . . . . 439
14.6.1 XYZ Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
14.6.2 Bradford Color Adaptation . . . . . . . . . . . . . . . 440
14.7 Colorimetric Support in Java . . . . . . . . . . . . . . . . . . . . 442
14.7.1 Profile Connection Space (PCS) . . . . . . . . . . . 442
14.7.2 Color-Related Java Classes . . . . . . . . . . . . . . . . 444
14.7.3 Implementation of the CIELAB Color Space
(Example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
14.7.4 ICC Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
14.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
15 Filters for Color Images . . . . . . . . . . . . . . . . . . . . . . . . . . 451
15.1 Linear Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
15.1.1 Monochromatic Application of Linear Filters 452
15.1.2 Color Space Matters . . . . . . . . . . . . . . . . . . . . . 454
15.1.3 Linear Filtering with Circular Values . . . . . . . 458
15.2 Nonlinear Color Filters . . . . . . . . . . . . . . . . . . . . . . . . . 462
15.2.1 Scalar Median Filter . . . . . . . . . . . . . . . . . . . . . 462
15.2.2 Vector Median Filter . . . . . . . . . . . . . . . . . . . . . 462
15.2.3 Sharpening Vector Median Filter . . . . . . . . . . 466
15.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
15.4 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
15.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
XVII
Contents 16 Edge Detection in Color Images . . . . . . . . . . . . . . . . . . 475
16.1 Monochromatic Techniques . . . . . . . . . . . . . . . . . . . . . 476
16.2 Edges in Vector-Valued Images . . . . . . . . . . . . . . . . . . 478
16.2.1 Multi-Dimensional Gradients . . . . . . . . . . . . . . 480
16.2.2 The Jacobian Matrix . . . . . . . . . . . . . . . . . . . . . 481
16.2.3 Squared Local Contrast . . . . . . . . . . . . . . . . . . . 482
16.2.4 Color Edge Magnitude . . . . . . . . . . . . . . . . . . . 483
16.2.5 Color Edge Orientation . . . . . . . . . . . . . . . . . . . 485
16.2.6 Grayscale Gradients Revisited . . . . . . . . . . . . . 486
16.3 Canny Edge Detector for Color Images . . . . . . . . . . . 489
16.4 Other Color Edge Operators . . . . . . . . . . . . . . . . . . . . 493
16.5 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
16.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494
17 Edge-Preserving Smoothing Filters . . . . . . . . . . . . . . . 497
17.1 Kuwahara-Type Filters . . . . . . . . . . . . . . . . . . . . . . . . . 498
17.1.1 Application to Color Images . . . . . . . . . . . . . . . 500
17.2 Bilateral Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
17.2.1 Domain Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
17.2.2 Range Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
17.2.3 Bilateral Filter: General Idea . . . . . . . . . . . . . . 505
17.2.4 Bilateral Filter with Gaussian Kernels . . . . . . 507
17.2.5 Application to Color Images . . . . . . . . . . . . . . . 508
17.2.6 Efficient Implementation by x/y Separation . 512
17.2.7 Further Reading . . . . . . . . . . . . . . . . . . . . . . . . . 514
17.3 Anisotropic Diffusion Filters . . . . . . . . . . . . . . . . . . . . . 517
17.3.1 Homogeneous Diffusion and the Heat
Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
17.3.2 The Perona-Malik Filter . . . . . . . . . . . . . . . . . . 520
17.3.3 Perona-Malik Filter for Color Images . . . . . . . 522
17.3.4 Geometry Preserving Anisotropic Diffusion . . 526
17.3.5 Tschumperlé-Deriche Algorithm . . . . . . . . . . . 528
17.4 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
17.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Part VI Spectral Techniques
18 Introduction to Spectral Methods . . . . . . . . . . . . . . . . 539
18.1 The Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . 540
18.1.1 Sine and Cosine Functions . . . . . . . . . . . . . . . . 540
18.1.2 Fourier Series Representation of Periodic
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
18.1.3 Fourier Integral . . . . . . . . . . . . . . . . . . . . . . . . . . 543
18.1.4 Fourier Spectrum and Transformation . . . . . . 544
18.1.5 Fourier Transform Pairs . . . . . . . . . . . . . . . . . . 545
18.1.6 Important Properties of the Fourier Transform 546
18.2 Working with Discrete Signals . . . . . . . . . . . . . . . . . . . 550
18.2.1 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
18.2.2 Discrete and Periodic Functions . . . . . . . . . . . 555
18.3 The Discrete Fourier Transform (DFT) . . . . . . . . . . . 555
18.3.1 Definition of the DFT . . . . . . . . . . . . . . . . . . . . 557
18.3.2 Discrete Basis Functions . . . . . . . . . . . . . . . . . . 558
XVIII
18.3.3 Aliasing Again! . . . . . . . . . . . . . . . . . . . . . . . . . . 559 Contents
18.3.4 Units in Signal and Frequency Space . . . . . . . 562
18.3.5 Power Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . 563
18.4 Implementing the DFT . . . . . . . . . . . . . . . . . . . . . . . . . 563
18.4.1 Direct Implementation . . . . . . . . . . . . . . . . . . . 563
18.4.2 Fast Fourier Transform (FFT) . . . . . . . . . . . . . 565
18.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
19 The Discrete Fourier Transform in 2D . . . . . . . . . . . . 567
19.1 Definition of the 2D DFT . . . . . . . . . . . . . . . . . . . . . . . 567
19.1.1 2D Basis Functions . . . . . . . . . . . . . . . . . . . . . . 567
19.1.2 Implementing the 2D DFT . . . . . . . . . . . . . . . . 568
19.2 Visualizing the 2D Fourier Transform . . . . . . . . . . . . . 570
19.2.1 Range of Spectral Values . . . . . . . . . . . . . . . . . 571
19.2.2 Centered Representation of the DFT
Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
19.3 Frequencies and Orientation in 2D . . . . . . . . . . . . . . . 572
19.3.1 Effective Frequency . . . . . . . . . . . . . . . . . . . . . . 572
19.3.2 Frequency Limits and Aliasing in 2D . . . . . . . 573
19.3.3 Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
19.3.4 Normalizing the Geometry of the 2D
Spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574
19.3.5 Effects of Periodicity . . . . . . . . . . . . . . . . . . . . . 575
19.3.6 Windowing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
19.3.7 Common Windowing Functions . . . . . . . . . . . . 577
19.4 2D Fourier Transform Examples . . . . . . . . . . . . . . . . . 581
19.5 Applications of the DFT . . . . . . . . . . . . . . . . . . . . . . . . 581
19.5.1 Linear Filter Operations in Frequency Space 582
19.5.2 Linear Convolution and Correlation . . . . . . . . 585
19.5.3 Inverse Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
19.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
20 The Discrete Cosine Transform (DCT) . . . . . . . . . . . 589
20.1 One-Dimensional DCT . . . . . . . . . . . . . . . . . . . . . . . . . 590
20.1.1 DCT Basis Functions . . . . . . . . . . . . . . . . . . . . . 590
20.1.2 Implementing the 1D DCT . . . . . . . . . . . . . . . . 591
20.2 Two-Dimensional DCT . . . . . . . . . . . . . . . . . . . . . . . . . 592
20.2.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
20.2.2 Separability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
20.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
20.4 Other Spectral Transforms . . . . . . . . . . . . . . . . . . . . . . 596
20.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Part VII Image Transformations
21 Geometric Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
21.1 Coordinate Transformations in 2D . . . . . . . . . . . . . . . 602
21.1.1 Linear Coordinate Transformations . . . . . . . . 603
21.1.2 Homogeneous Coordinates . . . . . . . . . . . . . . . . 603
21.1.3 Affine (Three-Point) Mapping . . . . . . . . . . . . . 605
21.1.4 Projective (Four-Point) Mapping . . . . . . . . . . 608
21.1.5 Bilinear Mapping . . . . . . . . . . . . . . . . . . . . . . . . 614
XIX
Contents 21.1.6 Log-Polar Mapping . . . . . . . . . . . . . . . . . . . . . . 615
21.1.7 Other Nonlinear Transformations . . . . . . . . . . 620
21.1.8 Piecewise Image Transformations . . . . . . . . . . 623
21.2 Resampling the Image . . . . . . . . . . . . . . . . . . . . . . . . . . 624
21.2.1 Source-to-Target Mapping . . . . . . . . . . . . . . . . 625
21.2.2 Target-to-Source Mapping . . . . . . . . . . . . . . . . 626
21.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
21.3.1 Geometric Transformations . . . . . . . . . . . . . . . 627
21.3.2 Image Transformations . . . . . . . . . . . . . . . . . . . 629
21.3.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
21.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
22 Pixel Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
22.1 Interpolation in 1D: Simple Methods . . . . . . . . . . . . . 639
22.1.1 Nearest-Neighbor Interpolation . . . . . . . . . . . . 639
22.1.2 Linear Interpolation . . . . . . . . . . . . . . . . . . . . . . 640
22.1.3 Ideal Low-Pass Filter . . . . . . . . . . . . . . . . . . . . . 640
22.2 Interpolation by Convolution . . . . . . . . . . . . . . . . . . . . 643
22.3 Cubic Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
22.4 Spline Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
22.4.1 Catmull-Rom Interpolation . . . . . . . . . . . . . . . 646
22.4.2 Cubic B-spline Approximation . . . . . . . . . . . . . 647
22.4.3 Mitchell-Netravali Approximation . . . . . . . . . . 647
22.4.4 Lanczos Interpolation . . . . . . . . . . . . . . . . . . . . 648
22.5 Interpolation in 2D . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649
22.5.1 Nearest-Neighbor Interpolation in 2D . . . . . . 651
22.5.2 Bilinear Interpolation . . . . . . . . . . . . . . . . . . . . 651
22.5.3 Bicubic and Spline Interpolation in 2D . . . . . 652
22.5.4 Lanczos Interpolation in 2D . . . . . . . . . . . . . . . 654
22.5.5 Examples and Discussion . . . . . . . . . . . . . . . . . 655
22.6 Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
22.6.1 Sampling the Interpolated Image . . . . . . . . . . 657
22.6.2 Space-Variant Low-Pass Filtering . . . . . . . . . . 659
22.7 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 660
22.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Part VIII Image Matching
23 Image Matching and Registration . . . . . . . . . . . . . . . . . 667
23.1 Template Matching in Intensity Images . . . . . . . . . . . 668
23.1.1 Distance between Image Patterns . . . . . . . . . . 668
23.1.2 Matching Under Rotation and Scaling . . . . . . 675
23.1.3 Java Implementation . . . . . . . . . . . . . . . . . . . . . 676
23.2 Matching Binary Images . . . . . . . . . . . . . . . . . . . . . . . . 676
23.2.1 Direct Comparison of Binary Images . . . . . . . 677
23.2.2 The Distance Transform . . . . . . . . . . . . . . . . . . 678
23.2.3 Chamfer Matching . . . . . . . . . . . . . . . . . . . . . . . 682
23.2.4 Java Implementation . . . . . . . . . . . . . . . . . . . . . 684
23.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 684
24 Non-Rigid Image Matching . . . . . . . . . . . . . . . . . . . . . . . 687
24.1 The Lucas-Kanade Technique . . . . . . . . . . . . . . . . . . . 687
XX
24.1.1 Registration in 1D . . . . . . . . . . . . . . . . . . . . . . . 687 Contents
24.1.2 Extension to Multi-Dimensional Functions . . 689
24.2 The Lucas-Kanade Algorithm . . . . . . . . . . . . . . . . . . . 690
24.2.1 Summary of the Algorithm . . . . . . . . . . . . . . . . 693
24.3 Inverse Compositional Algorithm . . . . . . . . . . . . . . . . 694
24.4 Linear Transformation Parameters . . . . . . . . . . . . . . . 698
24.4.1 Pure Translation . . . . . . . . . . . . . . . . . . . . . . . . . 698
24.4.2 Affine Transformation . . . . . . . . . . . . . . . . . . . . 699
24.4.3 Projective Transformation . . . . . . . . . . . . . . . . 701
24.4.4 Concatenating Linear Transformations . . . . . 701
24.4.5 Coordinate Frames . . . . . . . . . . . . . . . . . . . . . . . 702
24.5 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702
24.6 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
24.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Part IX Local Features
25 Scale-Invariant Feature Transform (SIFT) . . . . . . . . 709
25.1 Interest Points at Multiple Scales . . . . . . . . . . . . . . . . 710
25.1.1 The LoG Filter . . . . . . . . . . . . . . . . . . . . . . . . . . 710
25.1.2 Gaussian Scale Space . . . . . . . . . . . . . . . . . . . . . 715
25.1.3 LoG/DoG Scale Space . . . . . . . . . . . . . . . . . . . . 718
25.1.4 Hierarchical Scale Space . . . . . . . . . . . . . . . . . . 720
25.1.5 Scale Space Structure in SIFT . . . . . . . . . . . . . 724
25.2 Key Point Selection and Refinement . . . . . . . . . . . . . . 730
25.2.1 Local Extrema Detection . . . . . . . . . . . . . . . . . 730
25.2.2 Position Refinement . . . . . . . . . . . . . . . . . . . . . . 732
25.2.3 Suppressing Responses to Edge-Like
Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 734
25.3 Creating Local Descriptors . . . . . . . . . . . . . . . . . . . . . . 736
25.3.1 Finding Dominant Orientations . . . . . . . . . . . . 737
25.3.2 SIFT Descriptor Construction . . . . . . . . . . . . . 740
25.4 SIFT Algorithm Summary . . . . . . . . . . . . . . . . . . . . . . 747
25.5 Matching SIFT Features . . . . . . . . . . . . . . . . . . . . . . . . 748
25.5.1 Feature Distance and Match Quality . . . . . . . 748
25.5.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753
25.6 Efficient Feature Matching . . . . . . . . . . . . . . . . . . . . . . 756
25.7 Java Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
25.7.1 SIFT Feature Extraction . . . . . . . . . . . . . . . . . 760
25.7.2 SIFT Feature Matching . . . . . . . . . . . . . . . . . . . 762
25.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
26 Maximally Stable Extremal Regions (MSER) . . . . . 765
26.1 Threshold Sets and Extremal Regions . . . . . . . . . . . . 766
26.2 Building the Component Tree . . . . . . . . . . . . . . . . . . . 768
26.2.1 Component Tree Algorithms . . . . . . . . . . . . . . 768
26.2.2 Component Tree Algorithm 1: Global
Immersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 770
26.2.3 Component Tree Algorithm 2: Local Flooding 774
26.2.4 Component Tree Examples . . . . . . . . . . . . . . . . 777
26.3 Extracting MSERs from the Component Tree . . . . . 778
26.3.1 Component Size Variation (Growth Rate) . . . 779
XXI
Contents 26.3.2 Maximally Stable Components . . . . . . . . . . . . 781
26.3.3 Constraints on Component Size and Diversity 781
26.3.4 MSER Feature Statistics and Equivalent
Ellipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 784
26.3.5 Additional Constraints . . . . . . . . . . . . . . . . . . . 785
26.3.6 Detecting Dark And Bright Blobs . . . . . . . . . . 787
26.3.7 MSER Examples . . . . . . . . . . . . . . . . . . . . . . . . 788
26.4 Matching MSERs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789
26.5 Local Affine Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . 792
26.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 794
Appendix
A Mathematical Symbols and Notation . . . . . . . . . . . . . 799
A.1 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799
A.2 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
A.2.1 Basic Set Symbols and Operators . . . . . . . . . . 803
A.2.2 Destructive Set Operators . . . . . . . . . . . . . . . . 804
A.2.3 Relations, Mappings and Functions . . . . . . . . 804
A.3 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805
A.3.1 Adding and Removing Elements . . . . . . . . . . . 805
A.3.2 “Stack”-Type Sequences . . . . . . . . . . . . . . . . . . 805
A.3.3 “Queue”-Type Sequences . . . . . . . . . . . . . . . . . 806
A.3.4 Sorting Sequences . . . . . . . . . . . . . . . . . . . . . . . . 806
A.4 Tuples and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
A.4.1 Type Definition and Instantiation . . . . . . . . . . 806
A.4.2 Accessing Object Components . . . . . . . . . . . . . 807
A.4.3 Duplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807
A.5 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807
B Linear Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809
B.1 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 809
B.1.1 Column and Row Vectors . . . . . . . . . . . . . . . . . 810
B.1.2 Extracting Submatrices and Vectors . . . . . . . . 811
B.1.3 Length (Norm) of a Vector . . . . . . . . . . . . . . . . 811
B.2 Matrix Multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . 811
B.2.1 Scalar Multiplication . . . . . . . . . . . . . . . . . . . . . 811
B.2.2 Product of Two Matrices . . . . . . . . . . . . . . . . . 812
B.2.3 Matrix-Vector Products . . . . . . . . . . . . . . . . . . 812
B.3 Vector Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813
B.3.1 Dot (Scalar) Product . . . . . . . . . . . . . . . . . . . . . 813
B.3.2 Outer Product . . . . . . . . . . . . . . . . . . . . . . . . . . 814
B.3.3 Cross Product . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
B.4 Trace and Determinant of a Square Matrix . . . . . . . . 814
B.5 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . . . . . . . 815
B.5.1 Calculating Eigenvalues . . . . . . . . . . . . . . . . . . 816
B.5.2 Generalized Symmetric Eigenproblems . . . . . . 818
B.6 Homogeneous Coordinates . . . . . . . . . . . . . . . . . . . . . . 819
B.7 Basic Matrix-Vector Operations with the Apache
Commons Math Library . . . . . . . . . . . . . . . . . . . . . . . . 820
B.7.1 Vectors and Matrices . . . . . . . . . . . . . . . . . . . . . 821
B.7.2 Matrix-Vector Multiplication . . . . . . . . . . . . . . 821
XXII
B.7.3 Vector Products . . . . . . . . . . . . . . . . . . . . . . . . . 821 Contents
B.7.4 Inverse of a Square Matrix . . . . . . . . . . . . . . . . 822
B.7.5 Eigenvalues and Eigenvectors . . . . . . . . . . . . . . 822
B.8 Solving Systems of Linear Equations . . . . . . . . . . . . . 822
B.8.1 Exact Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . 823
B.8.2 Over-Determined System (Least-Squares
Solutions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 824
B.8.3 Solving Homogeneous Linear Systems . . . . . . 825
C Nonlinear Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . 827
C.1 Nonlinear Least-Squares Fitting . . . . . . . . . . . . . . . . . 827
C.2 Solution Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828
C.2.1 Implementation With Apache Commons Math 829
C.2.2 Example 1: One-Dimensional Curve Fitting . 829
C.3 Multi-Dimensional NLS Problems . . . . . . . . . . . . . . . . 832
C.3.1 Example 2: Geometric Circle Fitting . . . . . . . 832
C.3.2 Numerical Estimation of Partial Derivatives . 836
D Elements from Calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
D.1 Scalar and Vector Fields . . . . . . . . . . . . . . . . . . . . . . . . 837
D.1.1 The Jacobian Matrix . . . . . . . . . . . . . . . . . . . . . 837
D.1.2 Gradients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838
D.1.3 Maximum Gradient Direction . . . . . . . . . . . . . 839
D.1.4 Divergence of a Vector Field . . . . . . . . . . . . . . 839
D.1.5 The Laplacian Operator . . . . . . . . . . . . . . . . . . 839
D.1.6 The Hessian Matrix . . . . . . . . . . . . . . . . . . . . . . 840
D.2 Taylor Series Expansion . . . . . . . . . . . . . . . . . . . . . . . . 841
D.2.1 Single-Variable Functions . . . . . . . . . . . . . . . . . 841
D.2.2 Multi-Variable Functions . . . . . . . . . . . . . . . . . 842
D.2.3 Finding Function Extrema by 2nd-Order
Taylor Expansion . . . . . . . . . . . . . . . . . . . . . . . . 844
D.3 Estimating Derivatives of Discrete Functions . . . . . . 847
D.3.1 First-order Derivatives . . . . . . . . . . . . . . . . . . . 847
D.3.2 Second-Order Derivatives . . . . . . . . . . . . . . . . . 848
D.3.3 Alternative Formulations . . . . . . . . . . . . . . . . . 848
E Sub-Pixel Maximum Finding . . . . . . . . . . . . . . . . . . . . . 849
E.1 Second-Order Interpolation in 1D . . . . . . . . . . . . . . . . 849
E.2 Subpixel Interpolation in 2D . . . . . . . . . . . . . . . . . . . . 851
E.2.1 Quadratic Functions in 2D . . . . . . . . . . . . . . . . 852
E.2.2 Method A: Second-Order Taylor Interpolation 853
E.2.3 Method B: Least-Squares Quadratic
Interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 855
E.2.4 Quartic Interpolation . . . . . . . . . . . . . . . . . . . . . 857
F Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861
F.1 Straight Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 861
F.1.1 Conversions Between Different Line Equations 861
F.1.2 Intersections of Algebraic Lines . . . . . . . . . . . . 863
F.1.3 Intersections of Lines in Hessian Normal Form 863
F.1.4 Numeric Line Fitting Examples . . . . . . . . . . . . 863
F.2 Circles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 865
XXIII
Contents F.2.1 Circle Equations and Conversions . . . . . . . . . . 865
F.2.2 Circle From 3 Points . . . . . . . . . . . . . . . . . . . . . 866
F.3 Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866
F.3.1 Ellipse Equations . . . . . . . . . . . . . . . . . . . . . . . . 866
F.3.2 Converting Between Algebraic and
Geometric Parameters . . . . . . . . . . . . . . . . . . . . 867
F.3.3 Ellipse From 5 Points . . . . . . . . . . . . . . . . . . . . 869
G Statistical Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . 871
G.1 Mean, Variance, and Covariance . . . . . . . . . . . . . . . . . 871
G.1.1 Mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 871
G.1.2 Variance and Covariance . . . . . . . . . . . . . . . . . . 871
G.1.3 Biased vs. Unbiased Variance . . . . . . . . . . . . . . 872
G.2 The Covariance Matrix . . . . . . . . . . . . . . . . . . . . . . . . . 872
G.2.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 873
G.2.2 Practical Calculation . . . . . . . . . . . . . . . . . . . . . 874
G.3 Mahalanobis Distance . . . . . . . . . . . . . . . . . . . . . . . . . . 874
G.3.1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874
G.3.2 Relation to the Euclidean Distance . . . . . . . . . 875
G.3.3 Numerical Considerations . . . . . . . . . . . . . . . . . 875
G.3.4 Pre-Mapping Data For Efficient Mahalanobis
Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
G.4 The Gaussian Distribution . . . . . . . . . . . . . . . . . . . . . . 878
G.4.1 Maximum Likelihood Estimation . . . . . . . . . . 878
G.4.2 Gaussian Mixtures . . . . . . . . . . . . . . . . . . . . . . . 880
G.4.3 Creating Gaussian Noise . . . . . . . . . . . . . . . . . . 880
H Gaussian Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
H.1 Cascading Gaussian Filters . . . . . . . . . . . . . . . . . . . . . . 883
H.2 Gaussian Filters and Scale Space . . . . . . . . . . . . . . . . 883
H.3 Effects of Gaussian Filtering in the Frequency
Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
H.4 LoG-Approximation by Difference of Gaussians
(DoG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 885
I Writing ImageJ Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . 887
I.1 ImageJ Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887
I.1.1 Program Structure . . . . . . . . . . . . . . . . . . . . . . . 887
I.1.2 A First Example: Inverting an Image . . . . . . . 888
I.1.3 Plugin My_Inverter_A (PlugInFilter) . . . . 888
I.1.4 Plugin My_Inverter_B (PlugIn) . . . . . . . . . . . 890
I.1.5 When To Use PlugIn Or PlugInFilter? . . . 891
I.1.6 Executing ImageJ “Commands” . . . . . . . . . . . 892
I.1.7 ImageJ’s Command Recorder . . . . . . . . . . . . . 893
J Java Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
J.1 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 895
J.1.1 Integer Division . . . . . . . . . . . . . . . . . . . . . . . . . 895
J.1.2 Modulus Operator . . . . . . . . . . . . . . . . . . . . . . . 896
J.1.3 Mathematical Functions in Class Math . . . . . . 897
J.1.4 Numerical Rounding . . . . . . . . . . . . . . . . . . . . . 898
J.1.5 Inverse Tangent Function . . . . . . . . . . . . . . . . . 899
XXIV
J.1.6 Unsigned Byte Data . . . . . . . . . . . . . . . . . . . . . 899 Contents
J.1.7 Classes Float and Double . . . . . . . . . . . . . . . . 900
J.1.8 Testing Floating-Point Values Against Zero . 901
J.2 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 901
J.2.1 Creating Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 901
J.2.2 Array Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 902
J.2.3 Accessing Array Elements . . . . . . . . . . . . . . . . . 902
J.2.4 2D Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 903
J.2.5 Arrays of Objects . . . . . . . . . . . . . . . . . . . . . . . . 905
J.2.6 Searching for Minimum and Maximum Values 906
J.2.7 Sorting Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 906
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
XXV
Part I
Images and Pixels
1
Digital Images
For a long time, using a computer to manipulate a digital image (i.e.,
digital image processing) was something performed by only a rela-
tively small group of specialists who had access to expensive equip-
ment. Usually this combination of specialists and equipment was
only to be found in research labs, and so the field of digital image
processing has its roots in the academic realm. Now, however, the
combination of a powerful computer on every desktop and the fact
that nearly everyone has some type of device for digital image ac-
quisition, be it their cell phone camera, digital camera, or scanner,
has resulted in a plethora of digital images and, with that, for many
digital image processing has become as common as word processing.
It was not that many years ago that digitizing a photo and saving it
to a file on a computer was a time-consuming task. This is perhaps
difficult to imagine given today’s powerful hardware and operating
system level support for all types of digital media, but it is always
sobering to remember that “personal” computers in the early 1990s
were not powerful enough to even load into main memory a single
image from a typical digital camera of today. Now powerful hard-
ware and software packages have made it possible for amateurs to
manipulate digital images and videos just as easily as professionals.
All of these developments have resulted in a large community
that works productively with digital images while having only a basic
understanding of the underlying mechanics. For the typical consumer
merely wanting to create a digital archive of vacation photos, a deeper
understanding is not required, just as a deep understanding of the
combustion engine is unnecessary to successfully drive a car.
Today, IT professionals must be more then simply familiar with
digital image processing. They are expected to be able to knowledge-
ably manipulate images and related digital media, which are an in-
creasingly important part of the workflow not only of those involved
in medicine and media but all industries. In the same way, soft-
ware engineers and computer scientists are increasingly confronted
with developing programs, databases, and related systems that must
correctly deal with digital images. The simple lack of practical ex-
3
© Springer Nature Switzerland AG 2022
W. Burger and M. J. Burge, Digital Image Processing, Texts in Computer Science,
https://doi.org/10.1007/978-3-031-05744-1_1
1 Digital Images perience with this type of material, combined with an often unclear
understanding of its basic foundations and a tendency to underes-
timate its difficulties, frequently leads to inefficient solutions, costly
errors, and personal frustration.
1.1 Programming with Images
Even though the term “image processing” is often used interchange-
ably with that of “image editing”, we introduce the following more
precise definitions. Digital image editing, or as it is sometimes re-
ferred to, digital imaging, is the manipulation of digital images using
an existing software application such as Adobe Photoshop® or Corel
Paint® . Digital image processing, on the other hand, is the con-
ception, design, development, and enhancement of digital imaging
programs.
Modern programming environments, with their extensive APIs
(application programming interfaces), make practically every aspect
of computing, be it networking, databases, graphics, sound, or imag-
ing, easily available to nonspecialists. The possibility of developing
a program that can reach into an image and manipulate the individ-
ual elements at its very core is fascinating and seductive. You will
discover that with the right knowledge, an image becomes ultimately
no more than a simple array of values, that with the right tools you
can manipulate in any way imaginable.
“Computer graphics”, in contrast to digital image processing, con-
centrates on the synthesis of digital images from geometrical descrip-
tions such as three-dimensional (3D) object models [91, 106, 280].
While graphics professionals today tend to be interested in topics
such as realism and, especially in terms of computer games, render-
ing speed, the field does draw on a number of methods that originate
in image processing, such as image transformation (morphing), recon-
struction of 3D models from image data, and specialized techniques
such as image-based and nonphotorealistic rendering [206,281]. Sim-
ilarly, image processing makes use of a number of ideas that have
their origin in computational geometry and computer graphics, such
as volumetric (voxel) models in medical image processing. The two
fields perhaps work closest when it comes to digital postproduction
of film and video and the creation of special effects [289]. This book
provides a thorough grounding in the effective processing of not only
images but also sequences of images; that is, videos.
1.2 Image Analysis and Computer Vision
Often it appears at first glance that a given image-processing task will
have a simple solution, especially when it is something that is easily
accomplished by our own visual system. Yet in practice it turns out
that developing reliable, robust, and timely solutions is difficult or
simply impossible. This is especially true when the problem involves
image analysis; that is, where the ultimate goal is not to enhance
or otherwise alter the appearance of an image but instead to extract
4
meaningful information about its contents—be it distinguishing an 1.2 Image Analysis and
object from its background, following a street on a map, or finding Computer Vision
the bar code on a milk carton, tasks such as these often turn out to
be much more difficult to accomplish than we would expect.
We expect technology to improve on what we can do by ourselves.
Be it as simple as a lever to lift more weight or binoculars to see
farther or as complex as an airplane to move us across continents—
science has created so much that improves on, sometimes by unbe-
lievable factors, what our biological systems are able to perform. So,
it is perhaps humbling to discover that today’s technology is nowhere
near as capable, when it comes to image analysis, as our own visual
system. While it is possible that this will always remain true, do not
let this discourage you. Instead consider it a challenge to develop cre-
ative solutions. Using the tools, techniques, and fundamental knowl-
edge available today, it is possible not only to solve many problems
but to create robust, reliable, and fast applications.
While image analysis is not the main subject of this book, it often
naturally intersects with image processing and we will explore this in-
tersection in detail in these situations: finding simple curves (Ch. 12),
segmenting image regions (Ch. 8), and comparing images (Ch. 23). In
these cases, we present solutions that work directly on the pixel data
in a bottom-up way without recourse to domain-specific knowledge
(i.e., blind solutions). In this way, our solutions essentially embody
the distinction between image processing, pattern recognition, and
computer vision, respectively. While these two disciplines are firmly
grounded in, and rely heavily on, image processing, their ultimate
goals are much more lofty.
Pattern recognition is primarily a mathematical discipline and has
been responsible for techniques such as clustering, hidden Markov
models (HMMs), decision trees, and principal component analysis
(PCA), which are used to discover patterns in data and signals.
Methods from pattern recognition have been applied extensively to
problems arising in computer vision and image analysis. A good ex-
ample of their successful application is optical character recognition
(OCR), where robust, highly accurate turnkey solutions are available
for recognizing scanned text. Pattern recognition methods are truly
universal and have been successfully applied not only to images but
also speech and audio signals, text documents, stock trades, and find-
ing trends in large databases, where it is often called data mining.
Dimensionality reduction, statistical, and syntactical methods play
important roles in pattern recognition (see, e.g., [76, 192, 259]).
Computer vision tackles the problem of engineering artificial visual
systems capable of somehow comprehending and interpreting our
real, 3D world. Popular topics in this field include scene under-
standing, object recognition, motion interpretation (tracking), au-
tonomous navigation, and the robotic manipulation of objects in a
scene. Since computer vision has its roots in artificial intelligence
(AI), many AI methods were originally developed to either tackle or
represent a problem in computer vision (see, e.g., [63, Ch. 13]). The
fields still have much in common today, especially in terms of adap-
5
1 Digital Images tive methods and machine learning. Further literature on computer
vision includes [20, 96, 131, 242, 251, 264].
Ultimately you will find image processing to be both intellectually
challenging and professionally rewarding, as the field is ripe with
problems that were originally thought to be relatively simple to solve
but have to this day refused to give up their secrets. With the back-
ground and techniques presented in this text, you will not only be
able to develop complete image-processing solutions but will also have
the prerequisite knowledge to tackle unsolved problems and the real
possibility of expanding the horizons of science: for while image pro-
cessing by itself may not change the world, it is likely to be the
foundation that supports marvels of the future.
1.3 Types of Digital Images
Digital images are the central theme of this book, and unlike just
a few years ago, this term is now so commonly used that there is
really no reason to explain it further. Yet this book is not about all
types of digital images, instead it focuses on images that are made
up of picture elements, more commonly known as pixels, arranged in
a regular rectangular grid.
Every day, people work with a large variety of digital raster images
such as color photographs of people and landscapes, grayscale scans
of printed documents, building plans, faxed documents, screenshots,
medical images such as x-rays and ultrasounds, and a multitude of
others (see Fig. 1.1 for examples). Despite all the different sources
for these images, they are all, as a rule, ultimately represented as
rectangular ordered arrays of image elements.
1.4 Image Acquisition
The process by which a scene becomes a digital image is varied and
complicated, and, in most cases, the images you work with will al-
ready be in digital form, so we only outline here the essential stages in
the process. As most image acquisition methods are essentially vari-
ations on the classical optical camera, we will begin by examining it
in more detail.
1.4.1 The Pinhole Camera Model
The pinhole camera is one of the simplest camera models and has
been in use since the 13th century, when it was known as the “Camera
Obscura”. While pinhole cameras have no practical use today except
to hobbyists, they are a useful model for understanding the essential
optical components of a simple camera. The pinhole camera consists
of a closed box with a small opening on the front side through which
light enters, forming an image on the opposing wall. The light forms
a smaller, inverted image of the scene (Fig. 1.2).
6
1.4 Image Acquisition
Fig. 1.1
Examples of digital images.
Natural landscape (a), syn-
thetically generated scene (b),
poster graphic (c), computer
screenshot (d), black and white
illustration (e), barcode (f),
fingerprint (g), x-ray (h), mi-
croscope slide (i), satellite
(a) (b) (c) image (j), radar image (k),
astronomical object (l).
(d) (e) (f)
(g) (h) (i)
(j) (k) (l)
Perspective Projection
The geometric properties of the pinhole camera are very simple. The
optical axis runs through the pinhole perpendicular to the image
plane. We assume a visible object, in our illustration the cactus,
located at a horizontal distance Z from the pinhole and vertical dis-
tance Y from the optical axis. The height of the projection y is
determined by two parameters: the fixed depth of the camera box f
and the distance Z to the object from the origin of the coordinate
system. By comparison we see that
X Y
x = −f · and y = −f · (1.1)
Z Z 7
1 Digital Images
Fig. 1.2
Geometry of the pinhole cam-
era. The pinhole opening
Y
serves as the origin (O) of the Z
3D coordinate system (X, Y, Z)
for the objects in the scene.
The optical axis, which runs
through the opening, is the Z
axis of this coordinate system. X
optical
A separate 2D coordinate sys-
tem (x, y) describes the projec- axis y
tion points on the image plane.
The distance f (“focal length”) x
O
between the opening and
the image plane determines f
the scale of the projection.
image
plane
change with the scale of the resulting image in proportion to the
depth of the box (i.e., the distance f ) in a way similar to how the
focal length does in an everyday camera. For a fixed image, a small f
(i.e., short focal length) results in a small image and a large viewing
angle, just as occurs when a wide-angle lens is used, while increasing
the “focal length” f results in a larger image and a smaller viewing
angle, just as occurs when a telephoto lens is used. The negative
sign in Eqn. (1.1) means that the projected image is flipped in the
horizontal and vertical directions and rotated by 180◦ .
Equation (1.1) describes what is commonly known today as the
perspective transformation.1 Important properties of this theoretical
model are that straight lines in 3D space always appear straight in
2D projections and that circles appear as ellipses.
1.4.2 The “Thin” Lens
While the simple geometry of the pinhole camera makes it useful for
understanding its basic principles, it is never really used in practice.
One of the problems with the pinhole camera is that it requires a
very small opening to produce a sharp image. This in turn reduces
the amount of light passed through and thus leads to extremely long
exposure times. In reality, glass lenses or systems of optical lenses are
used whose optical properties are greatly superior in many aspects
but of course are also much more complex. Instead we can make our
model more realistic, without unduly increasing its complexity, by
replacing the pinhole with a “thin lens” as in Fig. 1.3.
In this model, the lens is assumed to be symmetric and infinitely
thin, such that all light rays passing through it cross through a virtual
plane in the middle of the lens. The resulting image geometry is the
same as that of the pinhole camera. This model is not sufficiently
1
It is hard to imagine today that the rules of perspective geometry, while
known to the ancient mathematicians, were only rediscovered in 1430
by the Renaissance painter Brunelleschi.
8
Z f 1.4 Image Acquisition
Fig. 1.3
lens Thin lens projection model.
optical
axis
image
plane
complex to encompass the physical details of actual lens systems, such
as geometrical distortions and the distinct refraction properties of
different colors. So, while this simple model suffices for our purposes
(i.e., understanding the mechanics of image acquisition), much more
detailed models that incorporate these additional complexities can
be found in the literature (see, e.g., [148]).
1.4.3 Going Digital
What is projected on the image plane of our camera is essentially
a two-dimensional (2D), time-dependent, continuous distribution of
light energy. In order to convert this image into a digital image on
our computer, the following three main steps are necessary:
1. The continuous light distribution must be spatially sampled.
2. This resulting function must then be sampled in time to create a
single (still) image.
3. Finally, the resulting values must be quantized to a finite range
of integers (or floating-point values) such that they can be rep-
resented by digital numbers.
Step 1: Spatial Sampling
The spatial sampling of an image (i.e., the conversion of the contin-
uous signal to its discrete representation) depends on the geometry
of the sensor elements of the acquisition device (e.g., a digital or
video camera). The individual sensor elements are arranged in or-
dered rows, almost always at right angles to each other, along the
sensor plane (Fig. 1.4). Other types of image sensors, which include
hexagonal elements and circular sensor structures, can be found in
specialized products.
Step 2: Temporal Sampling
Temporal sampling is carried out by measuring at regular intervals
the amount of light incident on each individual sensor element. The
CCD2 in a digital camera does this by triggering the charging process
and then measuring the amount of electrical charge that has built up
during the specified amount of time that the CCD was illuminated.
2
Charge-coupled device.
9
1 Digital Images incident light
Fig. 1.4
The geometry of the sensor
elements is directly responsi-
ble for the spatial sampling
of the continuous image. In
the simplest case, a plane of
v
sensor elements are arranged
in an evenly spaced grid, and
each element measures the
amount of light that falls on it.
sensor plane
image element I(u, v)
Step 3: Quantization of Pixel Values
In order to store and process the image values on the computer
they are commonly converted to an integer scale (e.g., 256 = 28 or
4096 = 212 ). Occasionally floating-point values are used in profes-
sional applications, such as medical imaging. Conversion is carried
out using an analog to digital converter, which is typically embedded
directly in the sensor electronics so that conversion occurs at image
capture or is performed by special interface hardware.
Images as Discrete Functions
The result of these three stages is a description of the image in the
form of a 2D, ordered matrix of integers (Fig. 1.5). Stated a bit
more formally, a digital image I is a 2D function that maps from
the domain of integer coordinates N × N to a range of possible pixel
values P such that
I(u, v) ∈ P and u, v ∈ N.
Now we are ready to transfer the image to our computer so that we
can save, compress, and otherwise manipulate it into the file format
of our choice. At this point, it is no longer important to us how the
image originated since it is now a simple 2D array of numerical data.
Before moving on, we need a few more important definitions.
1.4.4 Image Size and Resolution
In the following, we assume rectangular images, and while that is a
relatively safe assumption, exceptions do exist. The size of an image
is determined directly from the width M (number of columns) and
the height N (number of rows) of the image matrix I.
The resolution of an image specifies the spatial dimensions of
the image in the real world and is given as the number of image
elements per measurement; for example, dots per inch (dpi) or lines
per inch (lpi) for print production, or in pixels per kilometer for
satellite images. In most cases, the resolution of an image is the
same in the horizontal and vertical directions, which means that the
10
148 123 52 107 123 162 172 123 64 89 · · ·
1.4 Image Acquisition
147 130 92 95 98 130 171 155 169 163 · · ·
141 118 121 148 117 107 144 137 136 134 · · · Fig. 1.5
The transformation of a
82 106 93 172 149 131 138 114 113 129 · · · continuous grayscale image
57 101 72 54 109 111 104 135 106 125 · · · F (x, y) to a discrete digital im-
age I(u, v) (left), image detail
→ 138 135 114 82 121 110 34 76 101 111 · · · (below).
138 102 128 159 168 147 116 129 124 117 · · ·
113 89 89 109 106 126 114 150 164 145 · · ·
120 121 123 87 85 70 119 64 79 127 · · ·
145 141 143 134 111 124 117 113 64 112 · · ·
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
F (x, y) I(u, v)
image elements are square. Note that this is not always the case as,
for example, the image sensors of most current video cameras have
non-square pixels!
The spatial resolution of an image may not be relevant in many
basic image processing steps, such as point operations or filters. Pre-
cise resolution information is, however, important in cases where ge-
ometrical elements such as circles need to be drawn on an image
or when distances within an image need to be measured. For these
reasons, most image formats and software systems designed for pro-
fessional applications rely on precise information about image reso-
lution.
1.4.5 Image Coordinate System
In order to know which position on the image corresponds to which
image element, we need to impose a coordinate system. Contrary
to normal mathematical conventions, in image processing the coor-
dinate system is usually flipped in the vertical direction; that is, the
y-coordinate runs from top to bottom and the origin lies in the upper
left corner (Fig. 1.6). While this system has no practical or theoret-
ical advantage, and in fact may be a bit confusing in the context of
geometrical transformations, it is used almost without exception in
imaging software systems. The system supposedly has its roots in
the original design of television broadcast systems, where the picture
rows are numbered along the vertical deflection of the electron beam,
which moves from the top to the bottom of the screen. We start the
numbering of rows and columns at zero for practical reasons, since
in Java array indexing also begins at zero.
1.4.6 Pixel Values
The information within an image element depends on the data type
used to represent it. Pixel values are practically always binary words
of length k so that a pixel can represent any of 2k different values.
The value k is called the bit depth (or just “depth”) of the image. The
exact bit-level layout of an individual pixel depends on the kind of
11
1 Digital Images M columns
0 u M −1
Fig. 1.6
0
Image coordinates. In digital
image processing, it is common
to use a coordinate system
where the origin (u = 0, v = 0)
N rows
lies in the upper left corner. I(u, v)
The coordinates u, v represent
the columns and the rows of v
the image, respectively. For
an image with dimensions
M × N , the maximum col-
umn number is umax = M −1
and the maximum row
number is vmax = N −1. N −1
Table 1.1 Grayscale (Intensity Images):
Bit depths of common
image types and typi- Chan. Bits/Pix. Range Use
cal application domains. 1 1 [0, 1] Binary image: document, illustration, fax
1 8 [0, 255] Universal: photo, scan, print
1 12 [0, 4095] High quality: photo, scan, print
1 14 [0, 16383] Professional: photo, scan, print
1 16 [0, 65535] Highest quality: medicine, astronomy
Color Images:
Chan. Bits/Pix. Range Use
3 24 [0, 255]3 RGB, universal: photo, scan, print
3 36 [0, 4095]3 RGB, high quality: photo, scan, print
3 42 [0, 16383]3 RGB, professional: photo, scan, print
4 32 [0, 255]4 CMYK, digital prepress
Special Images:
Chan. Bits/Pix. Range Use
1 16 [−32768, 32767] Integer values pos./neg., increased range
1 32 ±3.4·1038 Floating-point values: medicine, astronomy
1 64 ±1.8·10308 Floating-point values: internal processing
image; for example, binary, grayscale, or RGB3 color. The properties
of some common image types are summarized below (also see Table
1.1).
Grayscale Images (Intensity Images)
The image data in a grayscale image consist of a single channel that
represents the intensity, brightness, or density of the image. In most
cases, only positive values make sense, as the numbers represent the
intensity of light energy or density of film and thus cannot be neg-
ative, so typically whole integers in the range 0, . . . , 2k −1 are used.
For example, a typical grayscale image uses k = 8 bits (1 byte) per
pixel and intensity values in the range 0, . . . , 255, where the value
0 represents the minimum brightness (black) and 255 the maximum
brightness (white).
For many professional photography and print applications, as well
as in medicine and astronomy, 8 bits per pixel is not sufficient. Image
depths of 12, 14, and even 16 bits are often encountered in these
3
Red, green, blue.
12
domains. Note that bit depth usually refers to the number of bits 1.5 Image File Formats
used to represent one color component, not the number of bits needed
to represent an entire color pixel. For example, an RGB-encoded
color image with an 8-bit depth would require 8 bits for each channel
for a total of 24 bits, while the same image with a 12-bit depth would
require a total of 36 bits.
Binary Images
Binary images are a special type of intensity image where pixels can
only take on one of two values, black or white. These values are
typically encoded using a single bit (0/1) per pixel. Binary images
are often used for representing line graphics, archiving documents,
encoding fax transmissions, and of course in electronic printing.
Color Images
Most color images are based on the primary colors red, green, and
blue (RGB), typically making use of 8 bits for each color component.
In these color images, each pixel requires 3 × 8 = 24 bits to encode all
three components, and the range of each individual color component
is [0, 255]. As with intensity images, color images with 30, 36, and 42
bits per pixel are commonly used in professional applications. Finally,
while most color images contain three components, images with four
or more color components are common in most prepress applications,
typically based on the subtractive CMYK (Cyan-Magenta-Yellow-
Black) color model (see Ch. 13).
Indexed or palette images constitute a very special class of color
image. The difference between an indexed image and a true color
image is the number of different colors (fewer for an indexed image)
that can be used in a particular image. In an indexed image, the pixel
values are only indices (with a maximum of 8 bits) onto a specific
table of selected full-color values (see Sec. 13.1.1).
Special Images
Special images are required if none of the above standard formats
is sufficient for representing the image values. Two common exam-
ples of special images are those with negative values and those with
floating-point values. Images with negative values arise during image-
processing steps, such as filtering for edge detection (see Sec. 5.2.2),
and images with floating-point values are often found in medical,
biological, or astronomical applications, where extended numerical
range and precision are required. These special formats are mostly
application specific and thus may be difficult to use with standard
image-processing tools.
1.5 Image File Formats
While in this book we almost always consider image data as be-
ing already in the form of a 2D array—ready to be accessed by a
program—, in practice image data must first be loaded into mem-
ory from a file. Files provide the essential mechanism for storing,
13
1 Digital Images archiving, and exchanging image data, and the choice of the correct
file format is an important decision. In the early days of digital im-
age processing (i.e., before around 1985), most software developers
created a new custom file format for almost every new application
they developed. Today there exist a wide range of standardized file
formats, and developers can almost always find at least one existing
format that is suitable for their application. Using standardized file
formats vastly increases the ease with which images can be exchanged
and the likelihood that the images will be readable by other software
in the long term. Yet for many projects the selection of the right file
format is not always simple, and compromises must be made. The
following sub-sections outline a few of the typical criteria that need
to be considered when selecting an appropriate file format.
1.5.1 Raster Versus Vector Data
In the following, we will deal exclusively with file formats for storing
raster images; that is, images that contain pixel values arranged in a
regular matrix using discrete coordinates. In contrast, vector graphics
represent geometric objects using continuous coordinates, which are
only rasterized once they need to be displayed on a physical device
such as a monitor or printer.
A number of standardized file formats exist for vector images,
such as the ANSI/ISO standard format CGM (Computer Graph-
ics Metafile) and SVG (Scalable Vector Graphics),4 as well as pro-
prietary formats such as DXF (Drawing Exchange Format from
AutoDesk), AI (Adobe Illustrator), PICT (QuickDraw Graphics
Metafile from Apple), and WMF/EMF (Windows Metafile and En-
hanced Metafile from Microsoft). Most of these formats can con-
tain both vector data and raster images in the same file. The PS
(PostScript) and EPS (Encapsulated PostScript) formats from Adobe
as well as the PDF (Portable Document Format) also offer this possi-
bility, although they are typically used for printer output and archival
purposes.5
1.5.2 Tagged Image File Format (TIFF)
This is a widely used and flexible file format designed to meet the pro-
fessional needs of diverse fields. It was originally developed by Aldus
and later extended by Microsoft and currently Adobe. The format
supports a range of grayscale, indexed, and true color images, but
also special image types with large-depth integer and floating-point
elements. A TIFF file can contain a number of images with different
properties. The TIFF specification provides a range of different com-
pression methods (LZW, ZIP, CCITT, and JPEG) and color spaces,
so that it is possible, for example, to store a number of variations
of an image in different sizes and representations together in a single
4
https://www.w3.org/TR/SVG2/
5
Special variations of PS, EPS, and PDF files are also used as (editable)
exchange formats for raster and vector data; for example, both Adobe’s
Photoshop (Photoshop-EPS) and Illustrator (AI).
14
Byte Order 1.5 Image File Formats
Version No
Fig. 1.7
1st IFD Offset
Structure of a TIFF file. A
IFH Image File Headers TIFF file consists of a header
IFD Image File Directories and a linked list of image ob-
jects, three in this example.
Each image object consists of
a list of “tags” with their cor-
IFD 0 IFD 1 IFD 2 responding entries followed by
Tag Entry Ct Tag Entry Ct Tag Entry Ct a pointer to the actual image
Tag 0 Tag 0 Tag 0 data. This structure makes
TIFF very flexible and easy to
Tag 1 Tag 1 Tag 1 extend.
... ... ...
Tag N0 Tag N1 Tag N2
Next IFD Offset Next IFD Offset Next IFD Offset
Image Image Image
Data Data Data
0 1 2
TIFF file. The flexibility of TIFF has made it an almost universal ex-
change format that is widely used in archiving documents, scientific
applications, digital photography, and digital video production.
The strength of this image format lies within its architecture (Fig.
1.7), which enables new image types and information blocks to be cre-
ated by defining new “tags”. In this flexibility also lies the weakness of
the format, namely that proprietary tags are not always supported
and so the “unsupported tag” error is sometimes still encountered
when loading TIFF files. ImageJ also reads only a few uncompressed
variations of TIFF formats,6 and bear in mind that most popular
Web browsers currently do not support TIFF either.
1.5.3 Graphics Interchange Format (GIF)
The Graphics Interchange Format (GIF) was originally designed by
CompuServe in 1986 to efficiently encode the rich line graphics used
in their dial-up Bulletin Board System (BBS). It has since grown
into one of the most widely used formats for representing images
on the Web. This popularity is largely due to its early support for
indexed color at multiple bit depths, LZW7 compression, interlaced
image loading, and ability to encode simple animations by storing
a number of images in a single file for later sequential display. GIF
is essentially an indexed image file format designed for color and
grayscale images with a maximum depth of 8 bits and consequently
it does not support true color images. It offers efficient support for
encoding palettes containing from 2 to 256 colors, one of which can
be marked for transparency. GIF supports color tables in the range
of 2, . . . , 256, enabling pixels to be encoded using fewer bits. As an
example, the pixels of an image using 16 unique colors require only 4
bits to store the 16 possible color values 0, . . . , 15. This means that
6
The ImageIO plugin offers support for a wider range of TIFF formats.
7
Lempel-Ziv-Welch
15
1 Digital Images instead of storing each pixel using 1 byte, as done in other bitmap
formats, GIF can encode two 4-bit pixels into each 8-bit byte. This
results in a 50% storage reduction over the standard 8-bit indexed
color bitmap format.
The GIF file format is designed to efficiently encode “flat” or
“iconic” images consisting of large areas of the same color. It uses
lossy color quantization as well as lossless LZW compression to effi-
ciently encode large areas of the same color. Despite the popularity
of the format, when developing new software, the PNG8 format, pre-
sented in the next sub-section, should be preferred, as it outperforms
GIF by almost every metric.
1.5.4 Portable Network Graphics (PNG)
PNG (pronounced “ping”) was originally developed as a replacement
for the GIF file format when licensing issues9 arose because of its use
of LZW compression. It was designed as a universal image format
especially for use on the Internet, and, as such, PNG supports three
different types of images:
• true color images (with up to 3 × 16 bits/pixel),
• grayscale images (with up to 16 bits/pixel),
• indexed color images (with up to 256 colors).
Additionally, PNG includes an alpha channel for transparency with a
maximum depth of 16 bits. In comparison, the transparency channel
of a GIF image is only a single bit deep. While the format only sup-
ports a single image per file, it is exceptional in that it allows images
of up to 230 × 230 pixels. The format supports lossless compression
by means of a variation of PKZIP (Phil Katz’s ZIP). No lossy com-
pression is available, as PNG was not designed as a replacement for
JPEG. Ultimately, the PNG format meets or exceeds the capabilities
of the GIF format in every way except GIF’s ability to include mul-
tiple images in a single file to create simple animations. Currently,
PNG should be considered the format of choice for representing un-
compressed, lossless, true color images for use on the Web.
1.5.5 JPEG
The classic JPEG standard defines a compression method for con-
tinuous grayscale and color images, such as those that would arise
from nature photography. The format was developed by the Joint
Photographic Experts Group (JPEG) with the goal of achieving an
average data reduction of a factor of 1:16 and was established in 1990
as ISO Standard IS-10918. In practice, JPEG achieves, depending on
the application, compression rates in the order of 1 bit per pixel (i.e.,
a compression factor of around 1:25) when compressing 24-bit color
images to an acceptable quality for viewing. The JPEG standard
supports images with up to 256 color components, which includes
CMYK images (see Sec. 13.2.5). Although the original JPEG-1 stan-
dard it is still the most widely used image file format, JPEG today is
8
Portable network graphics
9
Unisys’s U.S. LZW Patent No. 4,558,302 expired on June 20, 2003.
16
Discovering Diverse Content Through
Random Scribd Documents
Witness.--"Why, it was in January last, when there was little to be
done in the garden, and I went away a bit before the time, because
it was our club night. He jawed me about it, and said as long as he
was head-gardener the men should keep their time."
Counsel.--"On the night of the fifth of February, I think you said
that you did not know the prisoner had returned till you saw him?"
Witness.--"No, that I didn't."
Counsel, emphatically.--"I have done."
Witness re-examined.--"I think it was five o'clock when I met the
prisoner, I cannot exactly say. I have a watch, but I do not always
look at it: I did not that night. I guessed it was five, and I went."
The next witness was Mr. Andrew Woodyard, surgeon, who
deposed that he had examined the dead body of a person who, he
was informed, had been found in the grounds of Mr. Arthur Tracy, of
Northferry House. He had discovered, he said, severe injuries on the
head, consisting of a contusion over the left temple, and a contused
wound further back, on the same side, which had fractured the skull
and injured the brain. The latter was the immediate cause of death.
It must have been inflicted with a sharp instrument. A blow from a
Dutch hoe would probably produce all the appearances which he had
observed. He had no doubt that the wound was the cause of death.
Counsel for the prosecution.--"Would such a blow always produce
death as an inevitable consequence?"
Witness.--"No."
Counsel.--"In what cases do you think, Mr. Woodyard, a more
favourable result might be anticipated?"
Witness.--"In cases of idiots, of atheists, and of young lawyers:
that is to say, where the brain is soft, is wanting, or is wrong
placed."
Counsel for the defence, laughing.--"We shall decline to cross-
examine this witness;" and, without moving a muscle of his face, Mr.
Woodyard was about to quit the box, when the judge exclaimed in a
severe tone, "The witness will do well to remember, that to give
evidence in a court of justice is a serious matter."
"I am perfectly serious, my lord," replied the surgeon, turning full
upon him; "I am well aware that none but judges and queen's
counsel at the lowest, are permitted to play the fool in such places
as this."
"I have a great mind to commit you, Sir," thundered the judge,
bending his brows upon him.
"In so doing, my lord, you would commit yourself," said Mr.
Woodyard; and without waiting for the falling of the storm, he
hurried out of the court. The judge hesitated. The judge was angry,
but he saw that the trial was likely to be long. He did not like
interludes; and Mr. Woodyard escaped.
Michael Burwash was then placed in the box, and deposed to all
the facts which had been proved by the other witnesses who had
accompanied Mr. Tracy to the tool-house on the night of the murder.
He also stated that he had been sent to ask Sandes for the key; and
in addition to the evidence of the others, he said he had seen the
gentleman who was murdered cross a corner of the lawn a little
after five o'clock, on his way to the spot where the body was
afterwards found. The counsel for the defence did not cross-examine
him upon any of the points deposed to by others. They were wise
men, and let well alone. The first question the junior counsel asked
was, "Pray, what did you say to Mr. Sandes when you asked him for
the key?"
Witness.--"I told him a man had been found murdered in the
grounds, and master did not wish to have the footmarks disturbed."
Counsel.--"Nothing more?"
Witness.--"I might say a word or two more."
Counsel.--"Out with it, young man; we must have the whole."
"Why, I told him," said the witness, after having looked at the
stern face of the judge, and the impatient face of the leader for the
prosecution, "that all the servants thought that Mr. Acton had done
it; and that he ought to go before the coroner."
"What made you and the servants think the head-gardener had
done it?" asked the barrister.
Witness.--"Because he was in the grounds the last; and because
we all thought him so Eugene Aram like. He kept by himself, and
talked Latin and all that."
Counsel.--"I am afraid we of the bar are in great danger of
accusation of murder. This is the best reason ever given for having
the pleadings in English. You say, witness, that Mr. Acton, or the
prisoner at the bar, was the last person in the grounds; how did the
servants know that?"
Witness, in a whimpering tone.--"I cannot tell."
Counsel.--"I must have some answer. Will you swear that you
yourself did not see some person in the grounds after you saw Mr.
Roberts cross the lawn?"
Witness.--"No, I won't swear, because I did."
Counsel.--"Who did you see; and when?"
Witness.--"I don't well know who it was; but about ten minutes
after Mr. Roberts went across, I saw some one come up the dark
walk--I was shutting the dining-room window-shutters at the time--
and he went in by the door of the green-house."
"Then is there away through the green-house or conservatory in
the house?" asked the counsel.
"Yes; it leads into the hall on the left hand side," replied the
witness.
Counsel.--"Now we must hear more of the person. Who was it?"
Sir ---- turned and looked towards the dock. Chandos was sitting
with his arms upon the bar, and his eyes buried on them.
"I do not know--I cannot swear," replied the witness.
Counsel.--"Was it Mr. Tracy?"
Witness.--"No; it was a taller man than he."
"Was it General Tracy?"
"No; not so stout by a good deal."
Counsel.--"In a word: was it the prisoner at the bar?"
Witness.--"No; he is a good deal taller than the gentleman I saw."
Counsel.--"Was it a gentleman, then; or any of the servants?"
Witness.--"It looked like a gentleman's figure; but it was growing
dark, and he walked on very quick indeed. I could not clearly see
who it was."
Counsel.--"I have done with you;" and he sat down with a look of
satisfaction.
There was a murmur amongst the bar. The case for the
prosecution seemed breaking down. It was a result not at all
expected, and the cross-examination by the junior, who was a very
young member of the profession, but blessed with several eminent
solicitors for relations, was looked upon as highly creditable. None of
the barristers were for a moment deceived. They all clearly saw and
understood that several of the witnesses had been perplexed and
confounded; and nothing had shaken their conviction of the guilt of
Chandos Winslow till the admission made by the last witness, that
some one had been seen entering the house of Mr. Tracy, in a
hurried manner, and by a private and somewhat obscure entrance,
some ten minutes or quarter-of-an-hour after the murdered man had
passed across the lawn. It was, in truth, the first fact for the
defence; and legal acumen instantly detected that this was a verity
of great importance. None of the lawyers present, however, were
ignorant of the great impression which the admissions extracted
from other witnesses might make upon a jury, if followed up by any
available line of defence; and they, therefore, as I have said, looked
upon the case as breaking down, under a pressure of doubts, all of
which must be favourable to the prisoner.
There has seldom been a trial, however, in which the opinions of
the most acute and sensible men varied so often, under the different
aspects which the evidence gave to it at different times. Through the
examination of the next witness the same feeling prevailed, namely,
that satisfactory proof would fail. The person who succeeded
Burwash in the witness-box was Henry Haldemand, the constable of
Northferry, who, after stating his rank, condition, and degree, went
on as follows:--
"There were delivered to me, when I went down, on receiving Mr.
Tracy's message, several articles which had been found on the
person of the deceased. I here produce them. The first is a letter,
marked No. 1."
This was the letter which Chandos had written to Mr. Roberts on
the night preceding the murder, and it was ordered to be read aloud.
As the reader has, however, already perused it, it will not be
necessary to reproduce it here. The impression did not seem so
great upon the court as the counsel for the prosecution expected.
The snuffling tone in which the letter was read detracted from the
effect; and it was generally regarded as merely showing that some
sort of dispute might have existed between the prisoner and the
deceased, without by any means establishing a sufficient motive for
so great a crime. It gave an additional shade of probability to the
charge, but that was all. Other papers, marked Nos. 2 and 3, were
produced; but the counsel for the prosecution thought they did not
bear upon the case, and they were consequently not read. The
watch, the purse, and the pocket-book, of course, threw no new
light upon the matter, and only occupied a few minutes more of the
time of the court. The constable then went on with his evidence in
the following strain:--"Early on the morning of the sixth of February I
went to the spot where the dead body had been found; I took with
me Alfred Tims, shoemaker, of Northferry. We found a great many
footmarks round the spot where the deceased had been lying, so
many, that we could make nothing of them. One line of steps we
traced from the spot to the haw-haw; they were very distinct upon
the turf; the heel was towards the haw-haw, the toe towards the
spot where the murder was committed. We found another line like it
from the fish-pond to the haw-haw; the heel was towards the fish-
pond, the toe towards the haw-haw. In the dry ditch beyond the
hedge were several of the same footmarks, and the hedge seemed
to have been broken through. We measured the footmarks exactly;
there was but one line, either coming or going, made by a right and
left foot. After we had measured the marks, I went up to the cottage
of the head-gardener, from information I had received, and desired
to measure his shoes. He offered no opposition, and produced the
pair he had worn on the night before. They had not been cleaned;
and it seemed to me that there was some blood on the toe of the
right shoe: I can't swear it was blood; but there was certainly
something red upon it. We took away the shoes with us, and went
back to the spot in the grounds. The shoes corresponded exactly
with the marks to and from the haw-haw, and with those in the dry
ditch. In the latter we found one very distinct print; there were some
small nails in the outside edge of the shoe, and marks corresponding
on the ground. I afterwards went back to the cottage of the prisoner,
to examine his clothes; but found that he had gone down to
Northferry, and taken the clothes he had worn on the preceding
night with him."
The cross-examination then commenced, and the counsel for the
defence said, "Two or three questions will be enough, witness. Are
you aware why the prisoner went down to Northferry and took his
clothes with him?"
Witness.--"To attend the coroner's inquest, I believe. I know he
went there."
Counsel.--"Voluntarily?"
Witness.--"Yes, I believe so."
Counsel.--"Pray did you measure the shoes of any one else
besides those of the prisoner?"
Witness.--"No, I did not."
Counsel.--"Were you informed that one of the men who
accompanied Mr. Tracy on the night before had gone down to the
haw-haw, to see if there was any one concealed in the ditch?"
Witness.--"No, I never heard it."
Counsel.--"That is a pity. I have done."
Judge.--"Where are the clothes? for by the notes of the inquest
they are important."
Witness.--"They are in the hands of an officer of the rural police. I
belong to the parish of Northferry: it is not in the same county. Mr.
Tracy's house is in this county, but Northferry is not." All the counsel
wrote rapid notes, expecting, probably, some nice points of law.
A sergeant of rural police was then called, who produced a fustian
coat, upon the arm of which was evidently a large stain of blood. It
was on the inside of the arm, just at the bend, and there was no
mark upon the cuff. His evidence was very short. "I took the prisoner
into custody," he said, "after the coroner's jury had returned their
verdict: he had the coat I produce with him. I examined his person:
his hands were considerably torn and scratched, as if with thorns; in
his pocket there was five-and-thirty pounds six shillings, in gold and
silver, and also three letters, addressed to 'Chandos Winslow, Esq.' It
was then I first became aware of his real name. I had seen him
more than once before; but always thought his name was Acton. He
gave no explanation whatever in regard to the charge against him;
but said, when we were in the chaise together, that the coroner's
jury had done very right; for the evidence was strong, although he
was perfectly innocent."
Witness, in answer to the judge.--"The prisoner bore an
exceedingly good character in the neighbourhood, as a kind and
humane young man. He saved a lad from drowning--fetched him out
from under the ice, where he had been sliding, and never left him till
the doctor had brought him to."
This witness was not cross-examined; and the next witness that
was called was "Alice Humphreys." The poor old woman, who for the
last three months had acted as servant to Chandos Winslow, walked
with anxious look and trembling steps into the witness-box, and cast
a scared glance round the court, passing over the array of jurors and
barristers, till at length it lighted on the prisoner's dock, when she
exclaimed, in simple sorrow, "Oh, dear, Sir! dear me! To think of
this!"
Chandos Winslow gave her a kind look; and the judge exclaimed,
in a sharp tone, "Attend to the business before you, witness."
With a faltering voice, which called upon her many an injunction
to speak out, the poor old woman deposed as follows:--"I am
servant to the prisoner, and had kept house for him for about three
months on the fifth of February last. He had then been absent, by
Mr. Tracy's leave, about a month, and he came back on that day
about half-past four. He seemed very gay and cheerful, and asked
me a great number of questions, which I do not recollect. I
remember he asked about the little boy, Tim, that is the gipsey
woman's son, whom General Tracy took and put to live with us. Mr.
Acton asked why he was not there, and where he was; and I told
him the young ladies sent him every day to the day-school at
Northferry. He seemed to be in a hurry to go out again, however;
and said he must take a look round the grounds before it was dark;
so that he did not much listen to me. It was just five when he went
out again. I know it was five, because the clock went as he opened
the door. He was gone about an hour, or a little better. The boy, Tim,
was late before he came home; he did not arrive till half-past five, or
more; and he usually came at a quarter before five. When I scolded
him, he said he had seen his mother in Northferry, and she had kept
him; and he told me, besides, he had seen a man asleep in the
grounds."
Judge.--"That cannot stand in evidence."
Counsel for the prosecution.--"Very well, my lord: we will have the
boy. Now, my good woman, when did the prisoner return?"
Witness.--"He was away more than an hour, and it was quite dark
when he came back."
Counsel.--"Describe his appearance."
Witness.--"Why, Sir, he was as white as a sheet, and his hands
were all over blood. The little boy ran up to him directly; for Tim is
very fond of him, as well he maybe, for he's a kind, good gentleman
as ever lived. But he said, 'Stay a bit, Tim, I will come down again in
a minute.' And then he went up stairs to his room, which is just over
the parlour; and presently after, as I was putting out the tea-things,
I heard some water thrown out of the window. When he came down
again, the blood was off his hands, and he had another coat on."
Counsel.--"Did you observe anything particular in his manner or
demeanour during the evening?"
Witness.--"He was very sad, and astray like, all the time. He took
the boy and kept him by his knee, and asked him a great number of
questions about his learning, and heard him a part of his catechism.
He said he had been a very good boy, and if he always behaved well
and did his duty, he would be a happy man; but he kept falling into
studies, as if he was thinking of something else; and once or twice
he got up and walked heavy up and down the room. He did not say
anything about what had made his hands bloody, nor take any
notice of where he had been."
Counsel.--"Did you remark if his hands bled at all after he came
down?"
Witness.--"No, Sir, I did not see them bleed. They seemed quite
white, as they always were: whiter than most gardeners' hands."
In answer to other questions, she proceeded to state that the
prisoner took a Dutch hoe with him when he went out, and had
none when he came back; that about half-past ten he was called
away to speak with Mr. Tracy, and then she heard of the murder;
that she went up to his room during his absence, to see if anything
wanted putting to rights, when she found his coat, all bloody on the
sleeve, thrown over a chair, and the marks of bloody hands upon the
towel. "When he came back," she deposed, "he seemed very sad,
but not so astray-looking as before; and he told her that the
gentleman who had been murdered was a friend of his, and that he
should have to go down and give evidence before the coroner. He
bade me wake him, too, if he overslept himself," continued the
witness; "for he said he had walked a good way in the course of the
day, and was very tired."
Here ended the examination by the counsel for the prosecution;
and a momentary consultation was seen to take place between Sir --
-- and his junior.
"No, no; go on," said the great barrister; "no one could have done
it better. I am perfectly confident in your judgment."
"But I am somewhat fatigued," said Mr. B----; "and as it is of so
much importance, I would rather you undertook it."
"Very well; to relieve you, but for no other reason," said Sir ----,
and he rose to cross-examine the witness himself.
"When I remind you, witness, he said, that you are upon your
oath, it is simply because I believe you to have a sincere affection
for your master, as every one has who has the honour and pleasure
of knowing him; and I wish you to understand that nothing can so
well serve him as the plain, undisguised truth. Give, therefore, clear
and unhesitating answers to my questions, that the court, convinced
of your sincerity, may attach due weight to your testimony. Did the
prisoner, when he returned to his cottage, make any attempt to
conceal the blood upon his hands or coat?"
"Oh dear no, Sir," replied the witness; "he held his hands straight
before him, and came at once to the light."
Counsel.--"When you saw the coat, did it appear to you that any
attempt had been made to wash out the blood upon the arm."
Witness.--"No, Sir. There it was, plain enough."
Counsel.--"Did you remark any scratches or wound upon his
hands?"
Witness.--"Yes, Sir, they were a good deal scratched, specially the
left. There was a good big tear in that."
Counsel.--"Now, you say, he came in first about half-past four.
How long did he stay?"
Witness.--"Some quarter of an hour or twenty minutes."
"But you say he went away at five," said the barristers; "how can
that be?"
The woman looked puzzled. "Why, I heard half-past four go just
before he came in, by the church clock; and clocks differ you know
Sir."
Counsel.--"They do. You marked his coming by the church clock.
Pray what clock did you say struck when he went?"
Witness.--"No; it did not strike. It was the cuckoo that went."
Counsel.--"But does your cuckoo always sing right, my good
woman?"
Witness.--"Not always, Sir. It is a bit too fast at times."
Counsel.--"It is not worse than other cuckoos, I dare say. There
are some of them fast, some of them slow, like men's minds--
''Tis with our judgments as our watches, none
Go just alike, yet each believes his own.'
Can you give me any notion how much your cuckoo clock was
usually before the church clock? It differed, of course; but on the
average--at its ordinary rate of going?"
Witness.--"Why it got on two or three minutes a-day; but I do not
recollect when I last put it back with my thumb."
Counsel.--
"'Ay, 'tis beyond the date of memory:
Event upon event so oft hath trod,
With quick recurring foot, 'tis hard to trace
The worn-out print of Time's incessant step.'
But cannot you give me some idea of what day you usually put the
cuckoo clock back with your thumb? These things acquire a
regularity by habit which is rarely deviated from, especially in regard
to clocks. Every man, woman, and child in the kingdom who has a
clock, watch, or other indicator of Time's progress, has some
particular day, or perhaps hour for winding up and putting it right.
Can you tell me what day you wound up your cuckoo clock, and
whether you put it by the church or not on that day?"
Witness.--"I always wound it up o' Saturday, at about eleven,
when I had put the pot on; and I generally set it to rights by the
church, if I could hear it, that we might not be late at service the
next day."
Counsel.--"And if you did not set it on Saturday, did you ever
meddle with it during the week?"
Witness.--"Not that I remember ever. I did the two jobs together;
for I had to get up upon the stool, which I was not over fond of, for
the stool was old, and I was old; and if we had tumbled we might
both have gone to pieces."
All the bar laughed heartily, and encouraged the good old woman
amazingly: but the great barrister did not forget his point.
Counsel.--"Am I to understand you, that if you did not set the
clock on Saturday, you did not set it during the week?"
Witness.--"No, never."
"Then can you tell me if you set it on the Saturday before the
prisoner returned?" asked the counsel.
Witness.--"I can't justly recollect."
Counsel.--"Well, it got on two or three minutes a-day, you say; so
if you did set it on Saturday, the thirty-first of January, it would have
got on from ten to twelve minutes, at the least, and might have
done so a quarter-of-an-hour, before the evening of Thursday, the
fifth; which would make your other calculation right, that the
prisoner returned about half-past four, by the church clock, remained
a quarter-of-an-hour or twenty minutes, and went away at five by
the cuckoo, or a quarter to five by the church."
"That is likely," said the witness; "I dare say our clock was a
quarter too fast--it generally was. It was quite light, I know, when
he went away."
Counsel.--"Then I won't trouble you with any more questions,
Mrs. Humphreys; and I am very much obliged to you for replying to
those you have answered."
Witness.--"Well, you are a civil gentleman, I do declare!"
Witness re-examined.--"I am sure the clock went fast, not slow. I
said I put it back that we might not be too late at church, because
when it was right we were right, and if it were wrong we might trust
to its being more wrong than it was.--Well! you are a saucy one!--
The other is a very civil gentleman. But I do not see why you should
take liberties with old women."
A roar of laughter followed in the court; and the judge coughed
sonorously.
I should say that the merriest place on earth--I go no further--is a
court of justice during certain criminal trials. It seems as if the
solemnity of the scene, and the awfulness of the circumstances,
brought out all that is risible with extraordinary effect, as a black
background throws out a bright figure. Perhaps, few trials had ever
excited more strong feelings than that which was now proceeding.
There stood the prisoner, whose life was at stake, an object of
admiration to many, of interest to all; in the prime of his youth and
strength; eminently handsome; richly endowed with powers of mind;
of ancient lineage and high name; connected with some of the
noblest in the land; kind, generous, high-spirited; with genius
throned upon his brow and flashing from his eye: his life hung upon
a word; and yet, the whole court laughed at the silly simplicity of a
good but vulgar old woman--laughed cheerfully, as if there were
nothing like life and death in the world--laughed as if human
suffering and human crime were unknown in the place where they
were met to inquire into the murder of one fellow-creature, and to
adjudge another, either to prolonged existence with all its bright
companionships, or to speedy death--the scaffold, the cord, the
grave, the worm!
It was very horrible that laugh; and Chandos Winslow's brow
grew dark, as if they were sporting with his fate. He could not laugh-
-he could not join in their heartless merriment. More than life was at
stake for him--honour and good name--ay, and perhaps love. Verily,
we human beings are lighter than vanity; and the lake of the spirits
of men is rippled by the least of all possible breezes.
The judge was the only one ashamed at his gravity being overset;
and he endeavoured to cover his merriment by saying in a stern
tone. "Old woman--that is to say, witness, you must respect the
court. Was your clock right or wrong on this identical evening, the
fifth of February? That is the question."
"I dare say it was not quite right," answered Mrs. Humphreys; "it
seldom is for two days together; but how far wrong it was on that
day I cannot tell--may be a quarter-of-an-hour, my lord."
"It is a very extraordinary thing," said the judge, "that they will
have such clocks in the country. Neither the clocks nor the rural
police ever go right. You may go down, witness."
"Timothy Stanley" was now called; and something very small was
seen making its way resolutely through the court towards the
witness-box. The persons near stared at the child and drew back,
treading on the toes of those behind; and one of the officers of the
court caught hold of him to administer the oath. But the judge, who
had a conscience, though it was peculiarly organized, shouted out:
"Stay, stay! That is an infant. Put him in the box for a moment
before you swear him. Give him something to stand upon;" and,
adjusting his spectacles, he gazed at the small intelligent features of
the boy with interest and curiosity.
"Do you know the nature of an oath, my little man?" asked the
judge at length.
The boy remained silent for a few seconds; and then the voice of
Chandos Winslow was heard amidst the stillness of the court, saying
aloud, "That he does, my lord. I taught him."
"Why does he not answer then?" demanded the judge.
"Because your language, my lord, is perhaps above his
comprehension," replied the prisoner. "He is here as a witness
against me; but if you would permit me to suggest, you would ask
him first, What are the consequences of a lie?"
"Tell me, my little man," said the judge; "do you know what are
the consequences of a lie?"
"Disgrace and shame amongst men, and the anger of Almighty
God," replied the boy, readily.
The judge wiped his spectacles; for something touched him.
"Now, if you would pardon me, my lord," said the prisoner, "you
would inquire, What are the consequences of calling upon God to
witness a falsehood?"
"Do you know, boy," asked the judge, "what is the consequences
of taking God's name to a falsehood?"
"The loss of his protection for ever," said the little witness, "for
the greatest offence and insult to his truth and holiness."
There were several eyes had tears in them, and the judge said,
"Swear him--you may swear him."
"I won't be sworn!" said Tim, stoutly.
"Why not, boy?" demanded the judge.
"Because I won't say anything that may hurt him," rejoined the
boy, pointing to the dock.
There was again a silence, and Tim stood resolutely in the
witness-box with his hands in his pockets, and his eyes fixed upon
Chandos Winslow.
"My dear boy," said the prisoner; "nothing you can say will hurt
me if you tell 'the truth, the whole truth, and nothing but the truth,'
as they will put the oath to you. But if you are silent, they will think
you know something against me."
"Oh! that I don't," cried the boy, clasping his hands.
"Then take the oath, and tell the whole truth," said Chandos; "by
so doing you will do me more good than by any other course."
The boy gazed in his face for an instant, and then said, "Well, I
will, then; for you always tell the truth; and I am sure you would not
cheat me."
"Not for the world," said the prisoner; and the oath was
administered.
The counsel for the prosecution hesitated for a moment or two,
as if he doubted whether the boy's testimony would produce the
effect he desired; but then he began the examination, touching but
lightly on the point on which he had laid most stress in his speech.
He was a sagacious observer of an opponent's proceedings, and he
had already divined from the course of examination pursued, that it
was as much the object of the counsel for the defence to fix down
the commission of the crime to a certain period, as it had at first
been his own. He looked upon a criminal trial as a sort of game at
chess, where there were certain moves of necessity, but where it
was expedient to vary his play according to the skill and the moves
of his adversary. The method in which he conducted the examination
produced the following evidence.
Witness.--"On the fifth of February I went from the cottage of Mr.
Acton--the prisoner--to the day-school at Northferry. I went about
seven in the morning. I came back to dinner at one, and returned to
school at two. I left school at a little past four. I met my mother at
the corner of the lane, and went back with her into the town. She
bought me two penny buns at the shop, and we sat down and talked
in the marketplace while I ate them. She had been selling rabbit-
skins to the hatter. I do not know how she got them. She talked to
me of a great many things. She asked me if Mr. Acton had come
home yet, and I said, 'No.' She said he would be home soon, for she
had seen him. She did not say when she had seen him. She did not
say whether that day or the day before. She only said she had seen
him. The church clock had just gone five a few minutes before; and
I said, 'I must get home, mother, or Dame Humphreys will scold.'
She kept me about five minutes more, and then let me go. It was
getting quite dark when I came to the gates of the house--Mr.
Tracy's house; and as they were open and it saved a good bit I
slipped in and down the walks, into the Lady's Walk. When I came
into the Lady's Walk it was a little lighter there, for there were no
trees to the west; and I saw some one lying upon the grass close to
the fish-pond of gold and silver fishes. I am sure it was a man, for I
said to myself, 'There is one of the fellows drunk.' He lay quite still,
and I went up the walk and got over the gate to the cottage. The
prisoner was not there when I arrived. He did not come in for more
than half-an-hour. I ran up to him; but he said, 'Do not touch me,
Tim. Stay a bit, and I will be down in a minute.' I saw that his hands
were all bloody, and that there was a great mark of blood upon his
arm. He went up stairs and stayed some time; and when he came
down he had on another coat, and his hands were clean. He was
very white when he came in. His face is not usually white. He
seemed heavy, but he heard me my catechism, and talked a good
deal to me till I went to bed. I thought he looked strange, different
from what I had ever seen him look before. Often while he was
talking to me, he would begin to think, and stop in what he was
saying; and once he got up and walked up and down the room. He
was very strange till I went to bed."
Here ended the boy's examination-in-chief; and it was remarked
that the counsel for the prosecution had not asked at what hour the
witness had seen the man lying in Mr. Tracy's grounds, nor at what
hour the boy had reached the cottage. Nevertheless, the impression
produced by the witness's evidence was strongly against the
prisoner. The simplicity with which it was given, and the evident bias
of all his affections towards his friend and protector, when put in
contrast with the facts which he disclosed--the pale face--the
agitated demeanour--the moody thoughtfulness--the bloody hands--
the stained garb, told wonderfully upon the minds of the court and
the jury. Nor did the cross-examination remove this impression,
though Sir ---- seemed perfectly unaffected by it, and rose with as
calm and confident an air as ever.
"You are a dear, good little fellow," he said, in a kindly and almost
playful tone; "and I wish to Heaven a great number of grown
witnesses would take example from the clear and straightforward
manner in which such a child gives his evidence. Pursue the same
course, witness, and for my part, I will do nothing to puzzle or
confound you; I seek but the truth."
Perhaps he took a little advantage of his high position at the bar,
and the respect in which he was universally held, to commence the
cross-examination in this discursive manner; but he then proceeded
as follows. "You say that your mother asked you if the prisoner had
returned home, and told you that he would do so soon, for that she
had seen him. Can you recollect exactly at what time that was?"
Witness.--"It was after five, for the clock had struck."
Counsel.--"Did your mother leave you at any time after she first
met you and bought you the two buns you have mentioned?"
Witness.--"Yes, she left me just the minute before she asked me
that question: and she told me to sit by the pump till she came
back."
Counsel.--"Did you yourself see the prisoner in the town while you
were in Northferry that evening?"
Witness.--"No, I did not; but I think mother did; she kept looking
down the street when she asked me."
Judge.--"That will not do; that is not evidence."
Counsel.--"Undoubtedly it is not, my lord; but I did not seek for it.
Now, witness, tell me at what hour, as near as possible, you left the
town."
Witness.--"The quarter had not gone, but it must have been hard
upon it."
Counsel.--"And at what hour did you reach the gardener's
cottage?"
Witness.--"I looked at the clock when I came in, and it wanted a
quarter to six; but then our clock is well-nigh a quarter too fast, and
more of Friday nights, for Dame Humphreys only sets it on Saturday
morning."
"Then by that calculation," said the counsel, "it must have wanted
five-and-twenty minutes, or an half-hour to six when you got home.
But tell me, do you know the clock very accurately?"
Witness.--"Yes, Mr. Acton taught me two months ago."
Counsel.--"And his kindness will safe his life. How long does it
take you, witness, to go from the gardener's cottage to Northferry? I
am told the distance, from Mr. Tracy's house to the village or town,
is nearly two miles: can you walk that distance in a quarter of an
hour?"
Counsel for the prosecution.--"That is a leading question."
Sir ----. --"I only wish to make the whole clear to the jury. I am
not seeking to puzzle or to mislead; but it has been stated that the
distance is nearly two miles. The boy has said he walked it in nearly
twenty minutes, and, without pretending to disbelieve him, I wish
him to explain, to reconcile the two facts, which at first sight seem
incompatible."
Judge.--"I think the question may be put. If not put by counsel, I
will put it. The point must be made clear."
The counsel for the defence then repeated the question.
Witness.--"I walked, and I ran a part of the way, because I was
late; but the distance is nothing like two miles by the fields. I never
take more than twenty minutes to go or come; and that time I went
through the grounds, which saves a good bit. I know Mr. Acton once
walked there and back in half an hour, and bought me a book too."
Counsel.--"Thus the matter is easily explained. One can see, by
the plan submitted by the prosecution, that the high road to
Northferry takes innumerable turnings and windings. Can you give
me any distinct idea, witness, of what o'clock it was when you saw
the body of a man lying by the fish-pond?--By Northferry clock, I
mean."
Witness.--"It must have been half-past five, as near as possible."
Counsel.--"You are sure it was not six?"
Witness.--"How could that be? When I got home it wanted a
quarter to six by our clock, and that is always a good bit too fast."
Counsel.--"You are sure it is never too slow?"
Witness.--"Oh dear, no. If I were to go to school by it I should
always be there before any of the other boys."
Counsel.--"And you are sure the prisoner did not return for full
half an hour after your arrival?"
Witness.--"It was more than that--five or ten minutes more."
Counsel.--"Did you see any scratches on his hands, making them
bleed?"
Witness.--"No, I did not see any. His hands did not bleed at all
after he came down again."
Counsel.--"How long might he be absent when he went up to his
room?"
"Some five or ten minutes, I dare say," said the boy.
The counsel here sat down, and the boy was re-examined at
some length by the counsel for the prosecution, without eliciting any
new fact, or causing him at all to vary in his statements.
Four or five other witnesses were examined to various minute
facts, of no great importance in themselves, but all bearing more or
less upon the case.
The exact distance from Mr. Tracy's house to the place where the
murder was committed, the proximity of the body, when found, to
the temple over the fish-pond, the extent of space between that
building and the haw-haw, and the distance thence to the gardener's
house, were amongst the facts proved; and at length the counsel for
the prosecution declared his case closed.
It was between four and five in the afternoon, and the judge,
who for some time had been showing symptoms of impatience,
inquired of the prisoner's counsels whether they thought they could
conclude, that night.
"The court is intensely hot," said the learned judge. "We have sat
here from an early hour in the morning; but I am most anxious that
to-morrow should be left free for the remaining business of the
assize; and if sure of finishing to-night, we would proceed with the
trial, after taking some refreshment. I would rather sit till midnight
than not conclude to-day."
"Why, my lord," replied Sir----, "I and my learned friend who is
with me in the cause, think that four or five hours would be quite
enough for us; but if there is to be a long reply, of course the
business cannot be concluded to-night."
"I cannot limit myself as to my reply," said Sergeant ----. "Having
an important duty to perform, and not knowing what will be the line
of defence, I can make no promise as to time; and I can see clearly
that my reply cannot be very short."
"Then the court will adjourn," said the judge, somewhat sulkily;
and at the same moment he rose to retire.
Let it be remembered, that this day was marked in the calendar
as the ninth of the month; for dates may be important things even in
a novel, and in this instance a man's life hung upon the events of a
single day.
CHAPTER XXXI.
It was on the tenth of the month, in a very beautiful valley,
between bare hills, which, carrying their bold heads high above the
rich cloak of vegetation that clothed both sides of the dell, seemed
to cool them in the calm blue sky. Just above a waterfall, the same
which has been before described, two large irregular masses of
stone, differing in size, but both enormous, reared themselves up as
gigantic door-posts, to the entrance of a small amphitheatre of cliff,
not less than two hundred feet in height. The one rock had
somewhat the appearance of a chair of colossal size, the other, fancy
might shape into a reading-desk; and thus, amongst the people of
the neighbouring districts, the former had acquired the name of "the
Pope's Throne;" while the other was called "the Puritan's Pulpit."
Between them there was a narrow pass, of not more than ten feet in
width, and on either side was piled up a mound of loose shingly
fragments, forty or fifty feet high, with a tree or a shrub here and
there, where some vegetable earth had accumulated, forming a sort
of natural wall, which joined the rocky portal to the spurs of the
amphitheatre of crag. At several points, it is true, a man might easily
climb over the mound, either to enter or issue forth from the space
within; but the only smooth way was between the two great masses
of stone, where was a carpeting of soft mountain-turf, with not a
blade of grass more than an inch long in anyplace, while in one
appeared the evident marks of often-treading feet, in a narrow line
worn nearly bare.
With his back leaning against the base of the Pope's Throne, and
the sunshine and shadow of a spring day chasing each other across
his brow, was seated a stout gipsey, of four or five and twenty. Half-
way up the mound, on the right, reclining upon the shingle, might
be perceived another, somewhat older than the former, in such a
position that his eyes could rest from time to time, upon his
companion below. The mound on the left hand had also its man; but
he could not be seen from without the natural enclosure, for he had
stationed himself just over the top of the heap, obtaining a view into
the little enclosure; and there he sat from six o'clock in the morning
until eight, with a number of green osier twigs beside him, and a
half-finished basket between his knees, at which he worked away
like on honest, industrious man.
From within the circle, came forth at times the sounds of merry
voices; and at one period of the morning there curled up a quantity
of light bluish smoke. Shortly after, there trudged forth from the
entrance an elderly man, with a pair of bellows slung over his
shoulders, and an old spoutless tin kettle in his hand. Then all
seemed quiet, and the man who had been making baskets, without
changing his position, changed his attitude, and suffered himself to
drop quietly back upon some mossy turf which had gathered round
the root of a tree, planted, Heaven knows how, amongst the stones.
About half-past eight o'clock, the figure of a tall stout man
appeared, close beside the basket-maker. His step was slow and
cautious; and the gipsey man did not move. He was sound asleep.
The other stood and looked at him for an instant, with a look not
altogether friendly: but the moment after he moved quietly on
again, passed behind the tree and began to climb the ridge of the
mound, towards the spur of the cliff. He took a step higher, and
another, and another, with great care and precaution, often looking
back at the man he had passed, often looking down into the little
amphitheatre: but still he advanced steadily towards a part where
there was not a space of more than ten or twelve feet between the
summit of the cliff and the top of the shingly mound, with an ash-
tree waving its branches under the shelter of the bank. He was
within half-a-dozen paces of the top, when some of the loose stones
giving way beneath him, rolled down, and startled the sleeper from
his slumbers.
In an instant he was upon his feet. The next, he gazed up and
gave a loud shout. The scene of confusion that followed was wild
and strange. From a number of gipsey tents which had been pitched
in the circle below, issued forth some twenty or thirty persons, men,
women, and children, all in a state of great excitement, and all
looking in the direction from which the shout had proceeded. The
basket-maker sprang up after the climber of the hill, half-a-dozen
young men followed from below; and one of the other watchers
joined in what was evidently a pursuit.
But the fugitive had gained too much upon them; the shout
warned him to quicken his pace; in an instant he was under the ash-
tree; and in another, by the aid of its stout branches, he was at the
top of the cliff. There he paused for but one instant, then turned and
hurried on. His departing figure lessened rapidly to the eyes of those
who followed him, and at length he disappeared.
Three of the pursuers climbed up by the aid of the ash-tree, as he
had done; but as a fourth was mounting, he happened to turn his
eyes below, and beheld the object of the chase down in the valley,
and in the act of crossing the river, which rose to his arm-pits. By a
bold manœuvre he had put the hounds at fault, and by the time the
men were called down from above, was out of sight.
A short consultation was held amongst the tribe; and then they all
quietly returned to their usual habits. The women and the children
betook themselves again to their tents, the basket-maker came
down and plied his trade more wakefully below; the young man who
had been sitting with his back against the huge rock abandoned his
post, and remained talking, within the little basin, to another of the
tribe; and his fellow-watcher on the outside, lay down at the back of
the encampment, and went to sleep.
About five minutes after, coming at great speed, the gipsey
woman, Sally Stanley, approached the place from the lower part of
the valley. There was anxiety in her look, and she gazed eagerly over
the two shingly mounds, as if in search of what she did not see, and
then with a step quickened almost to a run, she entered the little
amphitheatre of cliff, advancing straight to the youth who had been
stationed at the pass between the two rocks.
"Is he gone?" she asked, in breathless eagerness, "Is he gone?"
"Yes, Sally; he is gone," replied the young man; "but it was not
my fault, for he--"
"Fault!" cried the woman, "it might be no one's fault; for what
right have I to command? what need have you to obey? But cursed
be he who let him go; for he has done a bad act; he has killed one
who has always been kind to us; and the blood of the gipsey's friend
be upon his head;" and without waiting for reply, she ran out of the
circle of rock; and, with the speed of lightning, hurried down the
valley. Cutting off every angle, finding paths where none appeared,
and footing on places which a goat could hardly have trod, she
darted on till she reached the spot where, opening out with an ever-
gentle descent to the plain, the hill-valley was lost in other sweeps
of the ground, and the common foot-path entered into the cultivated
grounds, taking its onward course between two close hedges in the
form of a lane. She looked upon the somewhat moist sand beneath
her feet with eagerness, and examined it carefully for several yards.
Then, murmuring to herself, "He has not passed!--he cannot have
passed!" she placed herself behind the decayed trunk of an old
willow, and, waiting, watched with an attentive ear.
Two minutes had not elapsed when a step was heard; and then
Lockwood was seen coming along the lane at a rapid pace, with a
thick newly-cut stick in his hand. The woman instantly darted forth
and threw herself before him.
"Get out of my way!" he said, in a stern tone, as soon as he saw
her. "I am angry, and I would not do anything unbecoming. You may
have done mischief enough already. Do not do more by making me
forget myself."
But she persevered in her attempts to stop him.
"I am a woman, and alone;" she answered, "you would not do
anything unmanly, I am sure. But hear me, Lockwood," she
continued, more vehemently; "hear me, and I will tell you what you
are going to do. You wish to save him, and you are going to ruin
him. If you set your foot in that court, he is lost. Nay, hear me! hear
me!" she repeated, as he strove to push his way past her; "you
must, you shall--for your own sake--for his sake--for my sake. I will
beseech you--I will kneel to you, to hear me but a few words;" and
casting herself down before him, she clasped his knees with her
arms.
"I will not hear you," he answered, bitterly; "every moment is
precious. You have detained me shamefully two days, and there is
nothing to be told me that I could not tell you. I know all, girl--I
know you, Susan Grey--I know your motives--I know that you are
fool enough still to love him who ruined, betrayed, abandoned you--
who left you to misery, starvation, and death, for aught he knew;
and I know that to save him from the punishment of his crimes, you
would sacrifice one who was kind and good to you, when there was
none other to befriend you. Let me go, girl! for I will pass!" and,
forcing himself from her grasp, he walked hastily onward towards S--
--.
"Oh God! Oh God!" cried the woman, "he will destroy him he
seeks to save!"
This took place, let the reader remember, on the tenth of the
month; the second day of the trial of Chandos Winslow; and to that
trial and the court in which it was taking place, we must now return.
CHAPTER XXXII.
In many cases the inhabitants of an assize town are very little
affected by what is taking place in their courts. They see lawyers
flock in and juries assemble, witnesses moving about in troops, and
a rich crop of blue bags growing up. But with the causes or the
prisoners, they very little trouble their heads. The host of the inn
rubs his hands and rejoices: a heavy calendar to him is a God-send.
His waiters, probably increased in number, bustle about to feed
those classes which are proverbially ravenous; and the chamber-
maids are in great request. The pastrycook becomes a person of
importance; the cookshop has its share of business, and red tape
and parchment rise in value; while the ladies of the place think a
good deal of the young barristers, and very little of those whose
causes brought them to the town.
But there are occasions, on the contrary, when, either from the
intrinsic interest of the case, or from adventitious circumstances
connected with it, the people even of the town in which the trial
takes place become almost universally excited by what is occurring
in the courts; and upon every turn of the trial as it proceeds hangs a
world of emotions in the bosoms of men only linked to the
transaction by the tie of sympathy.
Such was the case in regard to the trial of Chandos Winslow. Not
a drawing-room, not a tea-table, not a chamber in a tavern, not
even a coffee-room did not hear discussed during the whole evening
of the ninth the various events which had taken place in the court-
house during the day, while calculations were formed, and even bets
made, on the probable result of the trial. The prisoner had become
quite a hero of romance to all the youth and much of the age of the
place. He was so young, so handsome, so noble-looking, that the
women of S---- of course felt interest in his favour; and the men
declared he bore it stoutly, struck by his firm and calm demeanour,
and his resolute and gallant bearing. Nevertheless, at the close of
the case for the prosecution, a very general impression prevailed
that he would be found guilty. So many startling facts had been
proved against him: his absence from his house precisely at the time
of the murder; the exact correspondence of his shoes with the
footsteps to and from the spot where the crime was committed; the
bloody hands and coat; and the terribly agitated demeanour which
had been witnessed by the boy and the old woman on his return,
would almost have been enough for conviction, even without the
terrible and seemingly conclusive fact, that the fatal deed had
evidently been committed with the very hoe which he had carried
out in his hand.
Under such circumstances, the rush at the doors of the court-
house on the morning of the tenth was tremendous, and it was as
much as the officers on duty could do, aided by a strong body of
police, to prevent the multitude from crushing each other to death in
the passages and in the very court itself. Several of the magnates of
the county were accommodated with seats on the bench to hear the
defence; and the voice of the judge himself was raised to its very
highest tones to suppress the disorder that occurred when the
prisoner appeared in the dock.
Wearing anxiety will have its effect on every frame, and Chandos
Winslow looked paler and thinner than on the first day of the trial;
but still the magnificent head, the fine person, the tranquil and
undaunted bearing, and the firm, strong step had their effect upon
those who beheld them, and the impression was that though the
jury might and would say "Guilty," the man was innocent.
Sir ---- every one remarked, was exceedingly pale; and before he
rose he turned over the papers under his hand several times, with a
look of nervous anxiety; but the moment he was upon his feet, that
look passed away; he raised his head high; he cast back his
shoulders as if for full breath, and, fixing his fine and speaking eyes
upon the jury, began,
"My lord and gentlemen of the jury,--The learned sergeant who
has conducted the prosecution assured you that to do so was the
most painful task of his life. I doubt it not in the least; for it must be
a terrible task indeed to become the public accuser of such a man as
the prisoner, with even a doubt upon the mind of his guilt: and how
many doubts must have existed in this case? If such were the
feelings of my learned friend, judge, gentlemen of the jury, what
must be mine, when, in rising to defend the prisoner at the bar, I
know that upon my feeble efforts depends not only the life of an
innocent man, not only the life of one who is an ornament to the
society in which he moves, but the life and honour of my dearest
friend! With what anxieties must I be oppressed; how terrible must
be the responsibility when the slightest failure of my powers, the
least oversight on my part, any weakness, any indiscretion, may
condemn to death one whom I love as a brother--one whom I know
to be innocent, as I have trust in God! I am no paid advocate,
retained to defend a bad cause; I am not a counsel doing merely his
professional duties: but I am a friend standing forth in defence of a
friend; an honest man raising his voice to save an innocent one.
Terrible are the difficulties which all these cases present: more than
ordinary are the difficulties in the present case; and all these are
aggravated in an enormous degree by the very feelings of friendship
which exist between myself and the prisoner, by the doubts and
fears of myself, which make me tremble at my own incompetence,
by the zeal which perplexes, by the eagerness which confounds. The
burden would be too great, gentlemen of the jury; it would
overwhelm me; but happily there are circumstances which lighten
the load. I see upon the bench one of the most learned and clear-
sighted of those judges who are an honour to the nation to which
they belong: I see in that box a body of Englishmen well calculated
by judgment and experience to distinguish between truth and
falsehood; between the factitious glozing of an artificial oratory, and
the simple eloquence of right and conviction: and I hold under my
hand the means of establishing, beyond all doubt, the innocence of
my friend, if friendship do not deprive me of reason, if enthusiasm
do not paralyse my tongue.
"I will now, however, do my best to grapple with the case as
presented to you by my learned friend; and, doing him full justice for
his high eloquence, believing most sincerely that he has stated
nothing but what he was instructed was true, I will still venture to
say, that a more terrible misrepresentation was never made to an
English jury. Now, in the very first instance my learned friend
asserted that the prisoner at the bar is of a sharp and vindictive
disposition; and he said that he should be able to show that such
was the case. Gentlemen, I will ask you, has he proved that fact? I
will ask you if he has made any attempt to prove it? I will ask you if
his own witnesses have not proved the exact reverse; if they have
not shown that the prisoner is of a kind and gentle disposition,
winning the love and esteem of all around, high and low, rich and
poor? and, whether we see him teaching the uneducated child,
saving the drowning boy, or tending him in his after sickness, I will
ask, if all that has been proved does not excite admiration, and
sympathy, and respect? Cast from your minds, then, such unjustified
and vague expressions: look upon his general character as it is
shown by the very evidence for the prosecution, tender rather than
sharp, benevolent instead of vindictive. But the insinuation,
gentlemen of the jury, has been made, though not supported; and it
forces me to establish the contrary by proofs. Something was said
too, gentlemen, of a duel between the prisoner and Viscount
Overton, and a connexion must have instantly established itself in
the minds of the jury, between that duel and the sharp and
vindictive character ascribed to the prisoner. But, gentlemen, I will
place that honourable nobleman in the witness-box, to speak to the
character of the prisoner. He shall himself tell you what he thinks of
the circumstances which produced the duel; and you shall judge
from facts, not from insinuations. All this shall be triumphantly swept
away, and I will not leave a vestige of such charges against my
friend. I will call the old servants of his father's house, I will call the
tenants, the parishioners, the neighbours. Their evidence need not
be long, but it will be conclusive to show that a more honourable,
upright, generous, kind-hearted man never existed; full of noble
enthusiasms, gentle in habits, benevolent in disposition, incapable of
a base or a cruel action.
"So much, gentlemen of the jury, for the first part of the charge:
for the general and vague insinuation, made for the purpose of
preparing your minds to regard the prisoner as a man of blood. But
it seemed necessary to my learned friend; and most necessary
indeed it was to his case, to show some apparent motive for the
crime of which the prisoner is accused; and a letter has been read in
evidence to prove that there was some dispute between the prisoner
and the murdered man. That letter shall be fully explained before I
have done; and you shall see how ridiculously petty is the motive
assigned for so great an offence. But besides that letter, allusion was
made to former disputes between the unfortunate Mr. Roberts and
the prisoner, which, though not proved, may have had some
influence upon your minds. I will show that no such disputes ever
existed; that the two were on the best and most kindly terms, that
they had been so through life; and that those causes of disgust
which had induced the prisoner to quit his brother's mansion were
identical with the causes which induced Mr. Roberts to give notice to
Sir William Winslow that he was about to leave his employment. In
short, I will prove that Mr. Winslow and the man he is accused of
murdering, were acting on the most friendly terms together; and
that the letter which is supposed to prove that a dispute existed,
was written in cold terms merely as an authority to Mr. Roberts for
disregarding any orders he might have received from his employer to
meddle with things in which that employer had no right. It was, in
short, a formal notice to him to respect the rights of the prisoner,
without any regard to the illegal directions of a third party. I shall be
able to prove that Mr. Roberts possessed the full confidence of Mr.
Chandos Winslow; that he was acting with due regard for Mr.
Winslow's interests, and that he had actually applied or intended to
apply to that gentleman for an authority or warning to respect, in his
capacity of agent for Sir William Winslow, the rights of him, the
prisoner at the bar. Thus the pretence of motive furnished by the
letter which he, Mr. Roberts, had himself desired, falls entirely to the
ground, and leaves the accusation totally without foundation, except
such as a very doubtful train of circumstantial evidence can afford.
Mr. Roberts, in fact, was the only confidant of the prisoner at the bar,
the only person to whom he confided his address, when disgust at
some injuries he imagined he had received, and a desire to mingle
as an equal with classes in which he had long taken a deep interest
as a superior, led him to quit his high position in society, and accept
the humble station of gardener to Mr. Arthur Tracy, of Northferry.
Was this, gentlemen of the jury, like long disputes and acrimonious
bickerings, ending in malevolence and murder? Is that the man to
entertain such passions?--to commit such an act?
"But I will make no appeal to your feelings; I will address myself
to your judgment only. I will break through this chain of
circumstantial evidence; I will show that it cannot affect the prisoner,
that it is not applicable to him. I will proceed logically with my
inferences; though it may be somewhat out of the usual course. I
will first convince you that the prisoner was not a man likely to
commit such a crime, by the testimony of many witnesses. I will
next prove that there was no earthly motive for his committing that
crime; but every motive for his not doing so: and, in the end, I will
establish beyond all question that it was impossible that he could
have committed it. Before I proceed to call my witnesses, however, it
may be necessary to examine closely the evidence already adduced,
in order that we may separate the facts clearly and distinctly proved
from an immense mass of irrelevant matter. In so doing, I shall not
attempt to explain every fact and every circumstance; I shall not
seek to prove why the prisoner did this, or why he did that. To do so
would occupy unnecessarily the time and patience of the court. For,
surely, if I establish beyond all doubt, those three great points I have
named--That the prisoner was not a man likely by character,
disposition, and previous conduct, to commit such a crime; secondly,