PRACTICAL IMAGE AND
VIDEO PROCESSING
USING MATLAB®
PRACTICAL IMAGE AND
VIDEO PROCESSING
USING MATLAB®
OGE MARQUES
Florida Atlantic University
About the Cover (by Roger Dalal)
The elegant Nautilus, with its progressive chambers and near-perfect logarithmic spiral, demonstrates the
beauty of mathematics and the power of digital image processing. Created exclusively for Practical
Image and Video Processing Using MATLAB®, this composition features multiple layers and processing
techniques. The primary image is doubly sharpened with an 8 pixel radius, and enhanced with
posterizing and edge detection algorithms. The outer, secondary image is indexed to 20 colors, pixelized
at two percent resolution of the center image, and partially hidden by a fading, offset radial mask.
Copyright © 2011 by John Wiley & Sons, Inc. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as
permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior
written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to
the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400,
fax (978) 646-8600, or on the web at www.copyright.com. Requests to the Publisher for permission should
be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ
07030, (201) 748-6011, fax (201) 748-6008.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in
preparing this book, they make no representations or warranties with respect to the accuracy or
completeness of the contents of this book and specifically disclaim any implied warranties of
merchantability or fitness for a particular purpose. No warranty may be created ore extended by sales
representatives or written sales materials. The advice and strategies contained herin may not be
suitable for your situation. You should consult with a professional where appropriate. Neither the
publisher nor author shall be liable for any loss of profit or any other commercial damages, including
but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services please contact our Customer Care
Department with the U.S. at 877-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print,
however, may not be available in electronic format.
Library of Congress Cataloging-in-Publication Data
Marques, Oge.
Practical image and video processing using MATLAB® / Oge Marques.
p. cm.
Includes bibliographical references and index.
Image processing–Digital
ISBN 978-0-470-04815-3 (hardback)
1.
techniques. 4. MATLAB®.
I. Title.
Image processing–Mathematics. 2. Digital video–Mathematics. 3.
TA1637.M3375 2011
502.85’66–dc22
oBook ISBN: 978111093467
ePDF ISBN: 9781118093481
ePub ISBN: 9781118093474
Printed in Singapore.
10 9 8 7 6 5 4 3 2 1
2011008249
To my Son Nicholas, whose
Precious Existence has
Provided the Greatest
Motivation to Pursue this
Project.
And in Loving Memory of my
Father, Ogˆe Aby Marques.
CONTENTS
LIST OF FIGURES
LIST OF TABLES
FOREWORD
PREFACE
ACKNOWLEDGMENTS
PART I
IMAGE PROCESSING
1
INTRODUCTION AND OVERVIEW
1.1
1.2
1.3
1.4
1.5
1.6
1.7
Motivation / 3
Basic Concepts and Terminology / 5
Examples of Typical Image Processing Operations / 6
Components of a Digital Image Processing System / 10
Machine Vision Systems / 12
Resources / 14
Problems / 18
2
IMAGE PROCESSING BASICS
2.1
Digital Image Representation / 21
2.1.1
Binary (1-Bit) Images / 23
xxi
xxxix
xli
xliii
xlix
3
21
vii
CONTENTS
viii
2.2
2.3
2.4
Gray-Level (8-Bit) Images / 24
Color Images / 25
Compression / 26
2.1.2
2.1.3
2.1.4
Image File Formats / 27
Basic Terminology / 28
Overview of Image Processing Operations / 30
2.4.1
2.4.2
2.4.3
2.4.4
Global (Point) Operations / 31
Neighborhood-Oriented Operations / 31
Operations Combining Multiple Images / 32
Operations in a Transform Domain / 32
3 MATLAB BASICS
35
3.1
3.2
3.3
3.4
3.5
3.6
3.7
3.8
Working Environment / 36
Data Types / 37
Array and Matrix Indexing in MATLAB / 37
Standard Arrays / 37
Command-Line Operations / 38
Introduction to MATLAB / 35
Basic Elements of MATLAB / 36
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
Programming Tools: Scripts and Functions / 38
M-Files / 39
3.3.1
Operators / 40
3.3.2
Important Variables and Constants / 42
3.3.3
Number Representation / 42
3.3.4
Flow Control / 43
3.3.5
Code Optimization / 43
3.3.6
3.3.7
Input and Output / 43
Graphics and Visualization / 43
Tutorial 3.1: MATLAB—a Guided Tour / 44
Tutorial 3.2: MATLAB Data Structures / 46
Tutorial 3.3: Programming in MATLAB / 53
Problems / 59
4 THE IMAGE PROCESSING TOOLBOX AT A GLANCE
61
4.1
4.2
The Image Processing Toolbox: an Overview / 61
Essential Functions and Features / 62
4.2.1
4.2.2
Displaying Information About an Image File / 62
Reading an Image File / 64
CONTENTS
ix
Data Classes and Data Conversions / 65
Displaying the Contents of an Image / 68
Exploring the Contents of an Image / 69
Writing the Resulting Image onto a File / 70
4.2.3
4.2.4
4.2.5
4.2.6
Tutorial 4.1: MATLAB Image Processing Toolbox—a
Guided Tour / 72
Tutorial 4.2: Basic Image Manipulation / 74
Problems / 80
4.3
4.4
4.5
5
IMAGE SENSING AND ACQUISITION
83
5.1
5.2
5.3
5.4
5.5
Light and Electromagnetic Spectrum / 84
Types of Images / 85
Light and Color Perception / 86
Color Encoding and Representation / 87
Introduction / 83
Light, Color, and Electromagnetic Spectrum / 84
5.2.1
5.2.2
5.2.3
5.2.4
Image Acquisition / 89
5.3.1
5.3.2
Image Digitization / 93
Sampling / 95
5.4.1
Quantization / 96
5.4.2
5.4.3
Spatial and Gray-Level Resolution / 97
Problems / 101
Image Sensors / 89
Camera Optics / 92
6 ARITHMETIC AND LOGIC OPERATIONS
103
6.1
6.2
6.3
6.4
6.5
Addition / 104
Subtraction / 106
Multiplication and Division / 109
Combining Several Arithmetic Operations / 110
Arithmetic Operations: Fundamentals and Applications / 103
6.1.1
6.1.2
6.1.3
6.1.4
Logic Operations: Fundamentals and Applications / 111
Tutorial 6.1: Arithmetic Operations / 113
Tutorial 6.2: Logic Operations and Region of Interest
Processing / 118
Problems / 122