Table Of ContentMachine Vision Algorithms in Java
Springer-Verlag London Ltd.
Paul F. Whelan and Derek Molloy
Machine Vision
Algorithms in Java
Techniques and Implementation
With 183 Figures
Springer
Paul F. Whelan, BEng, MEng, PhD
Derek Molloy, BEng
Vision Systems Laboratory, School of Electronic Engineering, Dublin City
University, Dublin 9, Republic of lreland
ISBN 978-1-4471-1066-8 ISBN 978-1-4471-0251-9 (eBook)
DOI 10.1007/978-1-4471-0251-9
British Library Cataloguing in Publicat ion Data
Whelan, Paul
Machine vis ion algorithms in java : techniques and
implementation
1.Computer vis ion 2. java (Computer program language)
3.Computer algorithms
I.Titiie II. Molloy, Derek
006.3'7
ISBN 978-1-4471-1066-8
Library of Congress Cataloging-in-Publication Data
Whelan, Paul E, 1963-
Machine vision algorithms in java: techniques and implementation / Paul E Whelan
and Derek Molloy.
p.cm.
ISBN 978-1-4471-1066-8 (alk. paper)
1. Computer vis ion. 2. Computer algorithms. 3. java (Computer program language) 1.
Molloy, Derek, 1973-II. Title
TA1634.w542000
006.3 '7 -dc21 00-030072
Apart from any fair dealing for the purposes of research or private study, or criticism or review, as per
mitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored
or transmitted, in any form or by any means, with the prior permis sion in writing of the publishers, or
in the case of reprographic reproduction in accordance with the terms of licences issued by the Copy
right Licensing Agency. Enquiries concerning reproduction outside those terms should be sent to the
publishers.
© Springer-Verlag London 2001
Originally published by Springer-Verlag London Berlin Heidelberg in 2001
Softcover reprint of the hardcover 1s t edition 2001
The use of registered names, trademarks etc. in this publication does not imply, even in the absence of
a specific statement, that such names are exempt from the relevant laws and regulations and therefore
free for general use.
The publisher makes no representation, express or implied, with re gard to the accuracy of the informa
tion contained in this book and cannot accept any legal responsibility or liability for any errors or omis
sions that may be made.
Typesetting: PostScript files by authors
34/3830-543210 Printed on acid-free paper SPIN 10743121
To Caroline, Hannah and Sean. (PFW)
To Sally and parents. (DM)
Preface
For many novices to the world of machine vision, the development of auto
mated vision solutions may seem like a relatively easy task as it only requires a
computer to understand basic elements such as shape, colour and texture. Of
course this is not the case. Extracting useful information from images in a lab
oratory environment is a difficult process at the best of times, but to develop
imaging systems with the reliability and repeatability required for industrial,
medical and associated imaging applications increases the complexity of the
design task. The aim of this book was to produce a self contained software
reference source for machine vision designers which takes such issues into ac
count. To that end Machine Vision Algorithms in Java contains explanations
of key machine vision techniques and algorithms, along with the Java source
code for a wide range of real-world image processing and analysis functions.
A number of texts have been written over the last few years, which have
focused on implementing image processing and to a lesser extent image anal
ysis functions, through coded examples (i.e. for a range of software languages
and environments). So, why do we need another book on the subject? Firstly,
Machine Vision Algorithms in Java concentrates on examining these issues
from a machine vision perspective. It focuses on the image analysis and gen
eral machine vision design task, as well as discussing the key concepts relating
to image processing. In addition, we have made available (via the Internet) a
comprehensive machine vision development environment, Neat Vision, which
allows the algorithms and techniques discussed throughout this book to be
implemented by the reader.
The range of machine vision techniques and applications has grown sig
nificantly over the last decade and as such it would be difficult for a single
text to cover them all. Therefore, this book concentrates on those algorithms
and techniques that have found acceptance within the machine vision com
munity. As is in the nature of putting a book like this together, certain areas
receive greater attention reflecting our experience and the nature of our own
research.
This book has grown from a number of different elements. Many of the
ideas outlined are based on the postgraduate modules Computer and Machine
Vision (EE544) and Object-oriented Programming (EE553) developed by Dr.
Paul Whelan and Derek Molloy respectively. Both modules are available in
Vlll Preface
traditional form and via the Internet as part of Dublin City University's
Remote Access to Continuing Engineering Education (RA CeE) initiativel .
Another key element was the development of Neat Vision, a Java based
visual programming environment for machine vision. It provides an intuitive
interface which is achieved using a "drag and drop" block diagram approach,
where each image analysis/processing operation is represented by a graphical
block with inputs and outputs that can be interconnected, edited and deleted
as required. NeatVision was designed to allow the user to focus on the ma
chine vision design task rather than concerns about the subtlety of a given
programming language. It allows students of machine vision to implement
their ideas in a dynamic and easy to use way, thus reinforcing one of the key
elements of the educational experience, interaction. In conjunction with the
publication of this book a fully functional 'shareware' version of NeatVision
has been made available via the Internet2.
We have also included an introduction to Object-oriented Programming
(OOP) and the Java programming language, with particular reference to
its imaging capabilities. This was done for those readers who may be un
familiar with OOP and the Java programming language. It includes details
relating to the design of a Java based visual programming environment for
machine vision along with an introduction to the Java 2D imaging and the
Java Advanced Imaging (JAI) Application Programming Interface (API). A
wide range of illustrative examples are also included.
Having successfully digested the ideas outlined in this book the reader
will:
• Be familiar with the essential elements of machine VlSlOn software and
have an understanding of the problems involved in the development and
implementation of machine vision systems from a software perspective.
• Have the ability to design and implement image processing and analysis
techniques.
• Be able to evaluate emerging machine vision algorithms and techniques.
• Be familiar with the Java programming language and its application to
image analysis.
• Be able to develop machine vision solutions using a Java based visual pro
gramming environment (i.e. Neat Vision).
This book is aimed at senior undergraduate and postgraduate students in
engineering and computer science as well as practitioners in machine vision,
who may wish to update or expand their knowledge in the field. We have
tried to present the techniques and algorithms of machine vision in a way
1 http://www.racee.ie/
2 See http://www.NeatVision.com/ for further details on downloading and in
stalling this software. This web site also contains details of the NeatVision envi
ronment along with a summary of its techniques. A number of working examples
along with sample files and associated visual workspaces are also available.
Preface IX
that it will be understood not only by specialists familiar with the field, but
also by those who are less familiar with the topic. Care has also been taken to
ensure that we have provided adequate references to supporting work. This
should aid readers who wish to examine the topics covered in more detail.
The organisation of the book is as follows. Chap. 1 introduces the general
field of machine vision systems engineering. Chap. 2 outlines the key concepts
behind the Java programming language. As well as giving a brief history, de
scription and layout of the Java language, this chapter outlines the properties
of Java that make it useful for image processing and analysis. The purpose of
Chap. 3 is to detail some of the basic techniques and algorithms used in the
development of machine vision systems. Key elements of the image process
ing and analysis functions introduced in this section are also implemented in
Java and form the basis of the NeatVision visual programming environment.
Chap. 4 follows on from this basic introduction by examining mathemati
cal morphology, a key framework in which many machine vision algorithms
can be placed. Chaps. 5 and 6 expand our discussion of imaging techniques
to include key elements of texture and colour image analysis. Chap. 7 de
tails the design and implementation of the Neat Vision visual programming
environment. Appendix A outlines the graphics file formats that are used
by NeatVision and Appendix B details the NeatVision imaging Application
Programming Interface (API) specification. Finally, Appendix C summarises
the range of operators available in the NeatVision machine vision software
development environment. A range of sample applications implemented in
NeatVision are highlighted throughout the book.
For updates, corrections, colour images and sample visual programmes
please refer to the book web site at http://www.eeng.deu.ie;-j avamv /.
Dublin, June 2000 Paul F. Whelan
Derek Molloy
mvaj©eeng.deu.ie
Acknowledgments
This book has benefited from the comments and suggestions of a wide range
of people, including our colleagues with whom we have had many fruitful
discussions and collaborations. Numerous students have also contributed,
both directly and indirectly. The most important contributions coming from
members of the Vision Systems Laboratory (VSL) at Dublin City Univer
sity (DCU), namely Ovidiu Ghita, Alexandru Drimbarean and Pradeep PP.
We would particulary like to express our gratitude to Robert Sadleir (VSL)
for a fruitful collaboration in the development of Neat Vision. Robert also
contributed to our discussion on the Neat Vision development environment,
specifically in Chap. 7. We would also like to thank all the members of the
VSL for their comments on the various drafts of this book.
We would like to thank Prof. Charles McCorkell, Head of the School
of Electronic Engineering, DCU, for his support of the VSL and this book
project. We would also like to acknowledge all our academic colleagues for
our many discussions on computer and machine vision, especially Prof. Bruce
Batchelor (machine vision systems engineering) and Dr. Pierre Soille (math
ematical morphology). We would like to acknowledge Xuemei Zhang (De
partment of Psychology, Stanford University), Mark Graves (Spectral Fusion
Technologies) and Tim Carew (Technology Systems International) and thank
them for their permission to use some of the material cited in this book.
Special thanks are due to Nicholas Pinfield and Oliver Jackson of Springer
Verlag for their commitment to this book and maintaining its schedule. Ma
chine Vision Algorithms in Java: Techniques and Implementation was pre
pared in camera-ready form using the IbTEX text processing environment and
Paint Shop Pro image editing software.
Finally, the authors would like to thank their families for their constant
support and encouragement during this project. We would like to thank the
readers in advance for comments and suggestions aimed at improving and ex
tending the present book and its associated NeatVision software. Any errors,
of course, remain our own responsibility.
Acknowledgments
XII
Notice
Neat Vision and its associated materials are copyrighted © 2000, by Paul
F. Whelan. The software is presented "as is". While every reasonable effort
has been made to ensure the reliability of this software, NeatVision and the
associated algorithms outlined in this book are supplied for general reference
only and should not be relied on without further specific inquiry. Neat Vision
may be downloaded, stored on a hard drive or other storage device, with the
following restrictions and exceptions:
• Systematic or multiple-copy reproduction or republication; electronic re
transmission to another location; print or electronic duplication of any
NeatVision material supplied for a fee or for commercial purposes; or alter
ing or recompiling any contents of NeatVision and its associated materials
are not permitted.
• By choosing to use Neat Vision and its associated materials, you agree to
all the provisions of the copyright law protecting it and to the terms and
conditions established by the copyright holder.
• The authors cannot accept responsibility for any loss or damage caused by
the use of the source code presented in this book.
Trademarks
• Sun, Sun Microsystems, Solaris, Java and all Java-based trademarks are
trademarks or registered trademarks of Sun Microsystems, Inc. in the
United States and other countries.
• Netscape and Netscape Navigator are registered trademarks of Netscape
Communications Corporation in the United States and other countries.
• Microsoft, Windows, Windows NT and/or other Microsoft products refer
enced herein are either trademarks or registered trademarks of Microsoft
Corporation.
• IBM is a registered trademark of IBM Corporation in the United States
and other countries.
• Paint Shop Pro is a registered trademark of Jasc Software, Inc.