1 Introduction 1
Preview 1
1.1 Background 1
1.2 What Is Digital Image Processing? 2
1.3 Background on MATLAB and the Image Processing Toolbox 4
1.4 Areas of Image Processing Covered in the Book 5
1.5 The Book Web Site 6
1.6 Notation 7
1.7 The MATLAB Working Environment 7
1.7.1 The MATLAB Desktop 7
1.7.2 Using the MATLAB Editor to Create M-Files 9
1.7.3 Getting Help 9
1.7.4 Saving and Retrieving a Work Session 10
1.8 How References Are Organized in the Book 11
Summary 11
2 Fundamentals 12
Preview 12
2.1 Digital Image Representation 12
2.1.1 Coordinate Conventions 13
2.1.2 Images as Matrices 14
2.2 Reading Images 14
2.3 Displaying Images 16
2.4 Writing Images 18
2.5 Data Classes 23
2.6 Image Types 24
2.6.1 Intensity Images 24
2.6.2 Binary Images 25
2.6.3 A Note on Terminology 25
2.7 Converting between Data Classes and Image Types 25
2.7.1 Converting between Data Classes 25
2.7.2 Converting between Image Classes and Types 26
2.8 Array Indexing 30
2.8.1 Vector Indexing 30
2.8.2 Matrix Indexing 32
2.8.3 Selecting Array Dimensions 37
2.9 Some Important Standard Arrays 37
2.10 Introduction to M-Function Programming 38
2.10.1 M-Files 38
2.10.2 Operators 40
2.10.3 Flow Control 49
2.10.4 Code Optimization 55
2.10.5 Interactive I/O 59
2.10.6 A Brief Introduction to Cell Arrays and Structures 62
Summary 64
3 Intensity Transformations and Spatial Filtering 65
Preview 65
3.1 Background 65
3.2 Intensity Transformation Functions 66
3.2.1 Function imadjust 66
3.2.2 Logarithmic and Contrast-Stretching Transformations 68
3.2.3 Some Utility M-Functions for Intensity Transformations 70
3.3 Histogram Processing and Function Plotting 76
3.3.1 Generating and Plotting Image Histograms 76
3.3.2 Histogram Equalization 81
3.3.3 Histogram Matching (Specification) 84
3.4 Spatial Filtering 89
3.4.1 Linear Spatial Filtering 89
3.4.2 Nonlinear Spatial Filtering 96
3.5 Image Processing Toolbox Standard Spatial Filters 99
3.5.1 Linear Spatial Filters 99
3.5.2 Nonlinear Spatial Filters 104
Summary 107
4 Frequency Domain Processing 108
Preview 108
4.1 The 2-D Discrete Fourier Transform 108
4.2 Computing and Visualizing the 2-D DFT in MATLAB 112
4.3 Filtering in the Frequency Domain 115
4.3.1 Fundamental Concepts 115
4.3.2 Basic Steps in DFT Filtering 121
4.3.3 An M-function for Filtering in the Frequency Domain 122
4.4 Obtaining Frequency Domain Filters from Spatial Filters 122
4.5 Generating Filters Directly in the Frequency Domain 127
4.5.1 Creating Meshgrid Arrays for Use in Implementing Filters in the Frequency Domain 128
4.5.2 Lowpass Frequency Domain Filters 129
4.5.3 Wireframe and Surface Plotting 132
4.6 Sharpening Frequency Domain Filters 136
4.6.1 Basic Highpass Filtering 136
4.6.2 High-Frequency Emphasis Filtering 138
Summary 140
5 Image Restoration 141
Preview 141
5.1 A Model of the Image Degradation/Restoration Process 142
5.2 Noise Models 143
5.2.1 Adding Noise with Function imnoise 143
5.2.2 Generating Spatial Random Noise with a Specified Distribution 144
5.2.3 Periodic Noise 150
5.2.4 Estimating Noise Parameters 153
5.3 Restoration in the Presence of Noise Only—Spatial Filtering 158
5.3.1 Spatial Noise Filters 159
5.3.2 Adaptive Spatial Filters 164
5.4 Periodic Noise Reduction by Frequency Domain Filtering 166
5.5 Modeling the Degradation Function 166
5.6 Direct Inverse Filtering 169
5.7 Wiener Filtering 170
5.8 Constrained Least Squares (Regularized) Filtering 173
5.9 Iterative Nonlinear Restoration Using the Lucy-Richardson Algorithm 176
5.10 Blind Deconvolution 179
5.11 Geometric Transformations and Image Registration 182
5.11.1 Geometric Spatial Transformations 182
5.11.2 Applying Spatial Transformations to Images 187
5.11.3 Image Registration 191
Summary 193
6 Color Image Processing 194
Preview 194
6.1 Color Image Representation in MATLAB 194
6.1.1 RGB Images 194
6.1.2 Indexed Images 197
6.1.3 IPT Functions for Manipulating RGB and Indexed Images 199
6.2 Converting to Other Color Spaces 204
6.2.1 NTSC Color Space 204
6.2.2 The YCbCr Color Space 205
6.2.3 The HSV Color Space 205
6.2.4 The CMY and CMYK Color Spaces 206
6.2.5 The HSI Color Space 207
6.3 The Basics of Color Image Processing 215
6.4 Color Transformations 216
6.5 Spatial Filtering of Color Images 227
6.5.1 Color Image Smoothing 227
6.5.2 Color Image Sharpening 230
6.6 Working Directly in RGB Vector Space 231
6.6.1 Color Edge Detection Using the Gradient 232
6.6.2 Image Segmentation in RGB Vector Space 237
Summary 241
7 Wavelets 242
Preview 242
7.1 Background 242
7.2 The Fast Wavelet Transform 245
7.2.1 FWTs Using the Wavelet Toolbox 246
7.2.2 FWTs without the Wavelet Toolbox 252
7.3 Working with Wavelet Decomposition Structures 259
7.3.1 Editing Wavelet Decomposition Coefficients without the Wavelet Toolbox 262
7.3.2 Displaying Wavelet Decomposition Coefficients 266
7.4 The Inverse Fast Wavelet Transform 271
7.5 Wavelets in Image Processing 276
Summary 281
8 Image Compression 282
Preview 282
8.1 Background 283
8.2 Coding Redundancy 286
8.2.1 Huffman Codes 289
8.2.2 Huffman Encoding 295
8.2.3 Huffman Decoding 301
8.3 Interpixel Redundancy 309
8.4 Psychovisual Redundancy 315
8.5 JPEG Compression 317
8.5.1 JPEG 318
8.5.2 JPEG 2000 325
Summary 333
9 Morphological Image Processing 334
Preview 334
9.1 Preliminaries 335
9.1.1 Some Basic Concepts from Set Theory 335
9.1.2 Binary Images, Sets, and Logical Operators 337
9.2 Dilation and Erosion 337
9.2.1 Dilation 338
9.2.2 Structuring Element Decomposition 341
9.2.3 The strel Function 341
9.2.4 Erosion 345
9.3 Combining Dilation and Erosion 347
9.3.1 Opening and Closing 347
9.3.2 The Hit-or-Miss Transformation 350
9.3.3 Using Lookup Tables 353
9.3.4 Function bwmorph 356
9.4 Labeling Connected Components 359
9.5 Morphological Reconstruction 362
9.5.1 Opening by Reconstruction 363
9.5.2 Filling Holes 365
9.5.3 Clearing Border Objects 366
9.6 Gray-Scale Morphology 366
9.6.1 Dilation and Erosion 366
9.6.2 Opening and Closing 369
9.6.3 Reconstruction 374
Summary 377
10 Image Segmentation 378
Preview 378
10.1 Point, Line, and Edge Detection 379
10.1.1 Point Detection 379
10.1.2 Line Detection 381
10.1.3 Edge Detection Using Function edge 384
10.2 Line Detection Using the Hough Transform 393
10.2.1 Hough Transform Peak Detection 399
10.2.2 Hough Transform Line Detection and Linking 401
10.3 Thresholding 404
10.3.1 Global Thresholding 405
10.3.2 Local Thresholding 407
10.4 Region-Based Segmentation 407
10.4.1 Basic Formulation 407
10.4.2 Region Growing 408
10.4.3 Region Splitting and Merging 412
10.5 Segmentation Using the Watershed Transform 417
10.5.1 Watershed Segmentation Using the Distance Transform 418
10.5.2 Watershed Segmentation Using Gradients 420
10.5.3 Marker-Controlled Watershed Segmentation 422
Summary 425
11 Representation and Description 426
Preview 426
11.1 Background 426
11.1.1 Cell Arrays and Structures 427
11.1.2 Some Additional MATLAB and IPT Functions Used in This Chapter 432
11.1.3 Some Basic Utility M-Functions 433
11.2 Representation 436
11.2.1 Chain Codes 436
11.2.2 Polygonal Approximations Using Minimum-Perimeter Polygons 439
11.2.3 Signatures 449
11.2.4 Boundary Segments 452
11.2.5 Skeletons 453
11.3 Boundary Descriptors 455
11.3.1 Some Simple Descriptors 455
11.3.2 Shape Numbers 456
11.3.3 Fourier Descriptors 458
11.3.4 Statistical Moments 462
11.4 Regional Descriptors 463
11.4.1 Function regionprops 463
11.4.2 Texture 464
11.4.3 Moment Invariants 470
11.5 Using Principal Components for Description 474
Summary 483
12 Object Recognition 484
Preview 484
12.1 Background 484
12.2 Computing Distance Measures in MATLAB 485
12.3 Recognition Based on Decision-Theoretic Methods 488
12.3.1 Forming Pattern Vectors 488
12.3.2 Pattern Matching Using Minimum-Distance Classifiers 489
12.3.3 Matching by Correlation 490
12.3.4 Optimum Statistical Classifiers 492
12.3.5 Adaptive Learning Systems 498
12.4 Structural Recognition 498
12.4.1 Working with Strings in MATLAB 499
12.4.2 String Matching 508
Summary 513
Appendix A Function Summary 514
Appendix B ICE and MATLAB Graphical User Interfaces 527
Appendix C M-Functions 552
Bibliography 594
Index 597