Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (4 votes)
36 views

(Ebook PDF) Image Operators: Image Processing in Python Ebook All Chapters PDF

Image

Uploaded by

izmakuelamri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
36 views

(Ebook PDF) Image Operators: Image Processing in Python Ebook All Chapters PDF

Image

Uploaded by

izmakuelamri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Download the full version of the ebook now at ebooksecure.

com

(eBook PDF) Image Operators: Image Processing


in Python

https://ebooksecure.com/product/ebook-pdf-image-
operators-image-processing-in-python/

Explore and download more ebook at https://ebooksecure.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

(eBook PDF) Digital Image Processing, Global Edition 4th


Edition

https://ebooksecure.com/product/ebook-pdf-digital-image-processing-
global-edition-4th-edition/

ebooksecure.com

Digital Image Processing Using MATLAB 1st edition - eBook


PDF

https://ebooksecure.com/download/digital-image-processing-using-
matlab-ebook-pdf/

ebooksecure.com

(eBook PDF) Digital Image Processing 4th Edition by Rafael


C. Gonzalez

https://ebooksecure.com/product/ebook-pdf-digital-image-
processing-4th-edition-by-rafael-c-gonzalez/

ebooksecure.com

(eBook PDF) Lifespan Development 3rd Edition by Megan


Clegg Kraynok

https://ebooksecure.com/product/ebook-pdf-lifespan-development-3rd-
edition-by-megan-clegg-kraynok/

ebooksecure.com
Transportation: a global supply chain perspective 9e
Edition Coyle - eBook PDF

https://ebooksecure.com/download/transportation-a-global-supply-chain-
perspective-ebook-pdf/

ebooksecure.com

Psychiatric Drugs Explained 7th 7th Edition David Healy -


eBook PDF

https://ebooksecure.com/download/psychiatric-drugs-explained-7th-
ebook-pdf/

ebooksecure.com

Discovering Statistics Using IBM SPSS Statistics 4th


Edition (eBook PDF)

https://ebooksecure.com/product/discovering-statistics-using-ibm-spss-
statistics-4th-edition-ebook-pdf/

ebooksecure.com

Prepare Your Data for Tableau: A Practical Guide to the


Tableau Data Prep Tool (eBook PDF)

https://ebooksecure.com/product/prepare-your-data-for-tableau-a-
practical-guide-to-the-tableau-data-prep-tool-ebook-pdf/

ebooksecure.com

McGraw-Hill Education SAT, 2020 edition Christopher Black


- eBook PDF

https://ebooksecure.com/download/mcgraw-hill-education-
sat-2020-edition-ebook-pdf/

ebooksecure.com
(eBook PDF) A Guide to Mastery in Clinical Nursing: The
Comprehensive Reference

https://ebooksecure.com/product/ebook-pdf-a-guide-to-mastery-in-
clinical-nursing-the-comprehensive-reference/

ebooksecure.com
Contents

Python Codes ................................................................................................................................... xv


Preface.............................................................................................................................................xxi
Software and Data.........................................................................................................................xxiii
Author ............................................................................................................................................ xxv

PART I Image Operators

Chapter 1 Introduction ............................................................................................................. 3


1.1 Scripting in Python ......................................................................................... 3
1.2 Installation ...................................................................................................... 4
1.2.1 Example Codes .................................................................................. 4
1.2.2 Establishing a Work Space................................................................. 4
1.2.3 The Spyder Interface.......................................................................... 5
1.2.4 Intent of the Text ................................................................................ 5

Chapter 2 Operator Nomenclature ........................................................................................... 7


2.1 Image Notation ............................................................................................... 7
2.2 Operators......................................................................................................... 8
2.2.1 Creation Operators ............................................................................. 8
2.2.2 Channel Operators ............................................................................. 9
2.2.3 Informational Operators................................................................... 12
2.2.4 Intensity Operators........................................................................... 14
2.2.5 Geometric Operators........................................................................ 16
2.2.6 Transformation Operators ................................................................ 16
2.2.7 Expansion Operators........................................................................ 17
2.3 Combinations and Reduced Notation ........................................................... 18
2.4 Summary....................................................................................................... 19

Chapter 3 Scripting in Python ................................................................................................ 21


3.1 Basic Python Skills ....................................................................................... 21
3.1.1 Variables........................................................................................... 21
3.1.2 Strings .............................................................................................. 22
3.1.3 Type Conversions with Strings ........................................................ 23
3.2 Tuples, List, Dictionaries, and Sets .............................................................. 23
3.2.1 Tuple ................................................................................................ 23
3.2.2 Slicing .............................................................................................. 23
3.2.3 Lists.................................................................................................. 25
3.2.4 Dictionaries ...................................................................................... 25
3.2.5 Sets................................................................................................... 26
3.3 Flow Control ................................................................................................. 26
3.3.1 The if Command .............................................................................. 27
3.3.2 The while Command........................................................................ 28

vii
viii Contents

3.3.3 Break and Continue.......................................................................... 29


3.3.4 The For Loop ................................................................................... 29
3.3.5 The map and lambda Functions ....................................................... 31
3.3.6 Image Operators and Control........................................................... 31
3.4 Input and Output ........................................................................................... 32
3.4.1 Reading and Writing Text Files ....................................................... 32
3.4.2 Pickling Files ................................................................................... 32
3.5 Defining Functions........................................................................................ 33
3.5.1 Function Components ...................................................................... 33
3.5.2 Returns ............................................................................................. 34
3.5.3 Default Arguments........................................................................... 35
3.5.4 Function Help................................................................................... 35
3.6 Modules ........................................................................................................ 36
3.7 Errors ............................................................................................................ 38
3.8 NumPy .......................................................................................................... 39
3.8.1 Creating Arrays................................................................................ 39
3.8.1.1 Zeros and Ones ................................................................ 39
3.8.1.2 Random............................................................................ 40
3.8.1.3 Geometric Shapes............................................................ 41
3.8.1.4 Conversion of Numerical Data ........................................ 41
3.8.2 Manipulating Arrays ........................................................................ 42
3.8.2.1 Display Option................................................................. 42
3.8.2.2 Converting Arrays ........................................................... 42
3.8.2.3 Simple Math .................................................................... 42
3.8.2.4 Multiplying Vectors ......................................................... 43
3.8.2.5 Multiplying Matrices ....................................................... 44
3.8.2.6 Array Functions ............................................................... 44
3.8.2.7 Decisions ......................................................................... 47
3.8.2.8 Advanced Slicing............................................................. 48
3.8.2.9 Universal Functions ......................................................... 48
3.8.2.10 Sorting ............................................................................. 49
3.8.3 Indices .............................................................................................. 51
3.9 SciPy ............................................................................................................. 52
3.9.1 Loading and Saving Images............................................................. 53
3.9.2 Examples from ndimage .................................................................. 54
3.9.2.1 Rotation and Shift............................................................ 54
3.9.2.2 Center of Mass................................................................. 55
3.10 Summary....................................................................................................... 56

Chapter 4 Digital Images ....................................................................................................... 59


4.1 Images in Python .......................................................................................... 59
4.2 Resolution ..................................................................................................... 59
4.2.1 Intensity Resolution ......................................................................... 59
4.2.2 Spatial Resolution ............................................................................ 61
4.3 Digital Formats ............................................................................................. 63
4.3.1 Bitmaps ............................................................................................ 63
4.3.2 JPEG ................................................................................................ 63
4.3.3 GIF ................................................................................................... 63
4.3.4 TIFF ................................................................................................. 64
Contents ix

4.3.5 PNG.................................................................................................. 65
4.3.6 Other Compressions......................................................................... 65
4.4 Summary....................................................................................................... 65

Chapter 5 Color ...................................................................................................................... 67


5.1 The RGB Color Model ................................................................................. 67
5.2 The HSV Color Model.................................................................................. 69
5.3 The YUV Family .......................................................................................... 72
5.4 CIE L*a*b*................................................................................................... 73
5.5 Improvements in Recognition....................................................................... 74
5.6 Summary....................................................................................................... 77

PART II Image Space Manipulations


Chapter 6 Geometric Transformations ................................................................................... 81
6.1 Selections...................................................................................................... 81
6.2 Linear Translation......................................................................................... 83
6.2.1 Simple Shifting ................................................................................ 83
6.2.2 NonInteger Shifts ............................................................................. 84
6.3 Scaling .......................................................................................................... 85
6.4 Rotation......................................................................................................... 87
6.5 Dilation and Erosion ..................................................................................... 88
6.6 Coordinate Mapping ..................................................................................... 90
6.7 Polar Transformations................................................................................... 90
6.7.1 Theory .............................................................................................. 91
6.7.2 Python Implementation.................................................................... 92
6.7.3 Example ........................................................................................... 94
6.8 Pincushion and Barrel Transformations ...................................................... 95
6.9 Other Transformations.................................................................................. 96
6.9.1 Generic Transformations.................................................................. 97
6.9.2 Affine Transformation...................................................................... 98
6.10 Summary....................................................................................................... 99

Chapter 7 Image Morphing .................................................................................................. 101


7.1 Warp............................................................................................................ 101
7.1.1 Marking Fiducial Points................................................................. 101
7.1.2 Image Dancer ................................................................................. 101
7.1.3 Delaunay Tessellation .................................................................... 103
7.1.4 Applying the Warp ......................................................................... 104
7.2 Average Face............................................................................................... 106
7.3 Image Morphing ......................................................................................... 107

Chapter 8 Principle Component Analysis ............................................................................ 111


8.1 The Purpose of PCA ................................................................................... 111
8.2 Covariance Matrix ...................................................................................... 111
8.3 Eigenvectors................................................................................................ 112
8.4 PCA............................................................................................................. 113
x Contents

8.4.1 Distance Tests ................................................................................ 116


8.4.2 Organization Example ................................................................... 116
8.4.3 RGB Example ................................................................................ 121
8.5 First Order Nature of PCA.......................................................................... 124
8.6 Summary..................................................................................................... 124

Chapter 9 Eigenimages ........................................................................................................ 127


9.1 Eigenimages................................................................................................ 127
9.1.1 Large Covariance Matrix ............................................................... 128
9.1.2 Python Implementation.................................................................. 128
9.1.3 Face Recognition Example ............................................................ 130
9.1.4 Natural Eigenimages...................................................................... 131

PART III Frequency Space Manipulations

Chapter 10 Image Frequencies............................................................................................... 137


10.1 Complex Numbers ...................................................................................... 137
10.2 Theory......................................................................................................... 138
10.3 Digital Fourier Transform........................................................................... 138
10.3.1 FFT in Python ................................................................................ 139
10.3.2 Signal Reconstruction .................................................................... 139
10.4 Properties of a Fourier Transform............................................................... 140
10.4.1 DC Term......................................................................................... 140
10.4.2 Conservation of Energy ................................................................. 141
10.4.3 Replication ..................................................................................... 142
10.4.4 Addition ......................................................................................... 142
10.4.5 Shift................................................................................................ 143
10.4.6 Scale............................................................................................... 143
10.4.7 Power Spectrum ............................................................................. 144
10.5 Displaying the Transform ........................................................................... 144
10.6 Simple Shapes............................................................................................. 145
10.6.1 Rectangle........................................................................................ 145
10.6.2 Circle.............................................................................................. 146
10.7 Frequency Bands ........................................................................................ 147
10.8 Windowing.................................................................................................. 149
10.9 Summary..................................................................................................... 152

Chapter 11 Filtering in Frequency Space............................................................................... 153


11.1 Frequency Filtering..................................................................................... 153
11.1.1 Low-pass Filter .............................................................................. 153
11.1.2 High-pass Filter.............................................................................. 154
11.1.3 Band-pass Filter ............................................................................. 155
11.2 Directional Filtering.................................................................................... 156
11.3 Fingerprint Example ................................................................................... 158
11.4 Artifact Removal......................................................................................... 160
11.5 Summary..................................................................................................... 163
11.6 Problems ..................................................................................................... 163
Contents xi

Chapter 12 Correlations ......................................................................................................... 165


12.1 Justification and Theory.............................................................................. 165
12.2 Theory......................................................................................................... 165
12.2.1 Computations in Fourier Space...................................................... 166
12.3 Implementation in Python........................................................................... 167
12.3.1 Brute Force..................................................................................... 167
12.3.2 Method Based on Fourier Transforms ........................................... 168
12.3.3 Example – Geometric Shapes ........................................................ 169
12.3.4 Example – Boat Isolation............................................................... 170
12.4 Composite Filtering .................................................................................... 174
12.5 SDF and MACE.......................................................................................... 175
12.5.1 Fractional Power Filter (FPF) ........................................................ 176
12.5.1.1 Theory............................................................................ 176
12.5.1.2 Manipulating α .............................................................. 177
12.5.1.3 Example......................................................................... 178
12.5.1.4 The Constraints.............................................................. 180
12.5.1.5 Dual FPFs ...................................................................... 182
12.6 Restrictions of Correlations ........................................................................ 184
12.7 Summary..................................................................................................... 184

PART IV Texture and Shape

Chapter 13 Edge Detection .................................................................................................... 189


13.1 Edges........................................................................................................... 189
13.2 The Sobel Filters......................................................................................... 190
13.3 Difference of Gaussians.............................................................................. 191
13.4 Corners........................................................................................................ 193

Chapter 14 Hough Transforms ............................................................................................... 199


14.1 Detection of a Line ..................................................................................... 199
14.2 Detection of a Circle................................................................................... 202
14.3 Application ................................................................................................. 204
14.4 Summary..................................................................................................... 205

Chapter 15 Noise.................................................................................................................... 209


15.1 Random Noise ............................................................................................ 209
15.2 Salt and Pepper Noise................................................................................. 209
15.3 Camera Noise.............................................................................................. 212
15.4 Colored Noise ............................................................................................. 212
15.5 Comparison of Noise Removal Systems .................................................... 212
15.5.1 Smoothing ...................................................................................... 213
15.5.2 Low-Pass Filtering ......................................................................... 214
15.5.3 Erosion and Dilation ...................................................................... 214
15.5.4 Median Filter.................................................................................. 215
15.5.5 Wiener Filter .................................................................................. 216
15.6 Other Types of Noise .................................................................................. 217
15.7 Summary..................................................................................................... 217
xii Contents

Chapter 16 Texture Recognition ............................................................................................ 221


16.1 Data............................................................................................................. 221
16.2 Edge Density............................................................................................... 221
16.2.1 Statistical Method .......................................................................... 221
16.2.2 The Method of Rosenfeld and Thurston ........................................ 223
16.2.3 Wavelet Decomposition and Texture ............................................. 227
16.2.4 Gray-Level Co-Occurrence Matrix ................................................ 230
16.2.4.1 Angular Second Moment............................................... 232
16.2.4.2 Contrast.......................................................................... 232
16.2.4.3 Correlation..................................................................... 233
16.2.4.4 Variance ......................................................................... 234
16.2.4.5 Entropy .......................................................................... 234
16.2.4.6 The Remaining Haralick Metrics .................................. 235
16.3 Filter-Based Methods.................................................................................. 238
16.3.1 Law’s Filters................................................................................... 238
16.4 Summary..................................................................................................... 240

Chapter 17 Gabor Filtering .................................................................................................... 243


17.1 Gabor Filtering............................................................................................ 243
17.2 Edge Response............................................................................................ 245
17.3 Texture Extraction with Gabor Filters ........................................................ 246
17.4 Gabor Filters in Fourier Space.................................................................... 249
17.5 Summary..................................................................................................... 249

Chapter 18 Describing Shape................................................................................................. 251


18.1 Contour Methods ........................................................................................ 251
18.1.1 Chain Code..................................................................................... 251
18.1.2 The Polygon Method...................................................................... 252
18.1.3 Metrics Used to Describe Shape .................................................... 252
18.1.4 Fourier Descriptors ........................................................................ 255
18.1.5 Wavelets ......................................................................................... 258
18.1.6 Elastic Matching ............................................................................ 258
18.2 Region Methods.......................................................................................... 262
18.2.1 Eigenvectors and Eigenvalues........................................................ 262
18.2.2 Shape Metrics................................................................................. 265
18.3 Describing Structure ................................................................................... 267
18.3.1 Curvature Flow .............................................................................. 267
18.3.2 Medial Axis.................................................................................... 269
18.4 Problems ..................................................................................................... 271

PART V Basis

Chapter 19 Basis Sets............................................................................................................. 275


19.1 Discrete Cosine Transform ......................................................................... 276
19.2 Zernike Polynomials................................................................................... 279
19.3 Empirical Mode Decomposition................................................................. 282
19.4 Image Analysis with Basis Sets.................................................................. 285
Contents xiii

Chapter 20 Pulse Images and Autowaves .............................................................................. 293


20.1 Pulse-Coupled Neural Network .................................................................. 293
20.1.1 Mammalian Visual Cortex ............................................................. 293
20.1.2 PCNN............................................................................................. 293
20.1.2.1 Theory............................................................................ 294
20.1.2.2 Pulse Streams................................................................. 294
20.1.2.3 Applications................................................................... 295
20.1.2.4 Operator Notation.......................................................... 296
20.2 Intersecting Cortical Model ........................................................................ 296
20.2.1 Centripetal Autowaves ................................................................... 297
20.2.2 ICM ................................................................................................ 297
20.3 Texture Classification with the ICM........................................................... 298
20.4 Summary..................................................................................................... 300

Appendix A Operators ............................................................................................................. 303


Appendix B Operators in Symbolic Order............................................................................... 325
Appendix C Lengthy Codes..................................................................................................... 327
Bibliography ................................................................................................................................. 333
Index.............................................................................................................................................. 335
Python Codes
1.1 Positioning Python to the user’s directory ............................................................................. 4
1.2 Positioning Python to the user’s directory ............................................................................. 5
2.1 Corresponding Python outline ............................................................................................... 7
2.2 Swapping the color channels ............................................................................................... 11
2.3 Converting an RGB image to a grayscale image ................................................................. 12
2.4 A few informational operations ........................................................................................... 13
2.5 Computing the average of selected pixels............................................................................ 13
2.6 Determining which channel has the most energy ................................................................ 14
2.7 Isolating the man’s cane....................................................................................................... 16
3.1 Creating an integer............................................................................................................... 21
3.2 Simple math functions ......................................................................................................... 22
3.3 Type casting ......................................................................................................................... 22
3.4 Creating strings .................................................................................................................... 22
3.5 Type conversions.................................................................................................................. 23
3.6 Building a name ................................................................................................................... 23
3.7 Tuple .................................................................................................................................... 24
3.8 Extraction............................................................................................................................. 24
3.9 Slicing selected elements ..................................................................................................... 24
3.10 Using a list ........................................................................................................................... 25
3.11 Using a dictionary ................................................................................................................ 26
3.12 Some dictionary functions ................................................................................................... 26
3.13 Some set functions ............................................................................................................... 27
3.14 A simple if statement ......................................................................................................... 27
3.15 A multiple line if statement................................................................................................ 27
3.16 The if-else statement ....................................................................................................... 28
3.17 The elif statement.............................................................................................................. 28
3.18 A compound if statement ................................................................................................... 28
3.19 A while statement............................................................................................................... 29
3.20 Usgin break command........................................................................................................ 29
3.21 Using the continue command ........................................................................................... 30
3.22 The for loop........................................................................................................................ 30
3.23 Using the range command.................................................................................................. 30
3.24 Using the range command in a for loop ........................................................................... 31
3.25 Using the map and lambda functions ................................................................................. 31
3.26 Choosing parameters in a function ...................................................................................... 31
3.27 Choosing parameters in a function ...................................................................................... 32
3.28 Writing to a file .................................................................................................................... 32
3.29 Reading to a file ................................................................................................................... 32
3.30 Pickling a file ....................................................................................................................... 33
3.31 Reading a pickle file............................................................................................................. 33
3.32 Reading a pickle file............................................................................................................. 33
3.33 Defining a function .............................................................................................................. 34
3.34 Return a value from a function ............................................................................................ 34
3.35 Return a tuple from a function ............................................................................................. 34
3.36 Default arguments ................................................................................................................ 35

xv
Visit https://testbankfan.com
now to explore a rich
collection of testbank or
solution manual and enjoy
exciting offers!
xvi Python Codes

3.37 Function help ....................................................................................................................... 35


3.38 Showing help ....................................................................................................................... 36
3.39 Initial commands.................................................................................................................. 36
3.40 Reading a module ................................................................................................................ 37
3.41 Shortcut name ...................................................................................................................... 37
3.42 From import ......................................................................................................................... 37
3.43 Executing commands in either version of Python ............................................................... 38
3.44 Divide by 0 error .................................................................................................................. 38
3.45 Traceback through a module................................................................................................ 38
3.46 Try-except ............................................................................................................................ 39
3.47 Creation of vectors............................................................................................................... 40
3.48 Creating tensors ................................................................................................................... 40
3.49 Accessing data in a matrix ................................................................................................... 40
3.50 Creating random arrays........................................................................................................ 41
3.51 Using a random seed............................................................................................................ 41
3.52 Creating a solid rectangle..................................................................................................... 41
3.53 Creating arrays from data..................................................................................................... 42
3.54 Setting the number of decimal places that are printed to the console.................................. 42
3.55 Converting between vectors and matrices............................................................................ 43
3.56 Math operations for vectors ................................................................................................. 43
3.57 Multiplication with vectors .................................................................................................. 44
3.58 The inner product of two matrices ....................................................................................... 44
3.59 Maximum values in an image .............................................................................................. 45
3.60 Application of several functions .......................................................................................... 46
3.61 Locating the maximum ........................................................................................................ 46
3.62 Using the nonzero function ................................................................................................ 47
3.63 Advanced slicing for arrays ................................................................................................. 48
3.64 Advanced slicing for arrays with multiple dimensions........................................................ 49
3.65 Mathematical functions for an array .................................................................................... 49
3.66 Sorting data in an array ........................................................................................................ 50
3.67 Sorting images according to a user-defined criteria............................................................. 50
3.68 Example of the indices function .......................................................................................... 51
3.69 Creating a solid circle .......................................................................................................... 52
3.70 The Circle function.............................................................................................................. 52
3.71 Loading an image................................................................................................................. 53
3.72 Rearranging the color channels............................................................................................ 53
3.73 Saving an image ................................................................................................................... 54
3.74 An example of melding the operators and functions from ndimage.................................... 54
3.75 Finding the center of mass ................................................................................................... 55
4.1 Loading the image using Python Image Library.................................................................. 59
4.2 Loading the image using commands from imageio ............................................................. 59
4.3 Reducing the intensity resolution......................................................................................... 61
5.1 Creating an image that suppresses the background ............................................................. 69
5.2 Converting between HSV and RGB values ......................................................................... 70
5.3 The vectorize function applies the operation to all pixels................................................... 70
5.4 Modifying the hue channel .................................................................................................. 71
5.5 The RGB to YIQ conversion................................................................................................ 72
5.6 Getting the Cb and Cr channels from the rocket image....................................................... 73
6.1 Using the Window and Plop operators................................................................................. 82
6.2 Demonstrating the Downsample and Concatenate operators .............................................. 83
Python Codes xvii

6.3 Shifting an image ................................................................................................................. 84


6.4 Noninteger shifts.................................................................................................................. 86
6.5 Scaling the image................................................................................................................. 86
6.6 Rotation using scipy.ndimage .............................................................................................. 87
6.7 Multiple rotations................................................................................................................. 88
6.8 Dilation operations............................................................................................................... 89
6.9 The perimeters are created by computing the difference between two dilations................. 90
6.10 Creation of the image in Figure 6.10 ................................................................................... 91
6.11 The RPolar function............................................................................................................. 93
6.12 The IRPolar function............................................................................................................ 93
6.13 The LogPolar function ......................................................................................................... 93
6.14 Finding the perimeter of the cell.......................................................................................... 96
6.15 The Barrel function ............................................................................................................. 97
6.16 An example using scipy.ndimage.geometric–transform .................................................. 98
6.17 An example using scipy.ndimage.affine_transform ................................................ 98
7.1 Starting Dancer .................................................................................................................. 102
7.2 The DelaunayWarp function ............................................................................................ 103
7.3 Reading a CSV file............................................................................................................. 103
7.4 Extracting information from the tessellation ..................................................................... 104
7.5 Finding a simplex............................................................................................................... 104
7.6 Commands to warp an image............................................................................................. 106
7.7 Morphing two images ........................................................................................................ 108
8.1 Testing the eigenvector engine in NumPy ......................................................................... 113
8.2 Proving that the eigenvectors are orthonormal .................................................................. 113
8.3 Projection of data into a new space.................................................................................... 115
8.4 Projection of data into a new space.................................................................................... 116
8.5 The first two dimensions in PCA space ............................................................................. 117
8.6 The ScrambleImage function ........................................................................................... 118
8.7 The Unscramble function ................................................................................................. 119
8.8 Various calls to the Unscramble function ......................................................................... 120
8.9 The LoadImage and IsoBlue functions ............................................................................ 122
9.1 The EigenImages function ................................................................................................ 129
9.2 The ProjectEigen function................................................................................................ 129
10.1 The Rect2Polar and Polar2Rect functions....................................................................... 137
10.2 Forward and inverse FFT ................................................................................................... 139
10.3 The DC term ...................................................................................................................... 142
10.4 Conservation of energy ...................................................................................................... 142
10.5 Computing the original image ........................................................................................... 142
10.6 The shifting property.......................................................................................................... 143
10.7 The script for Equation (10.28).......................................................................................... 148
10.8 Creating the mask .............................................................................................................. 151
10.9 Using the KaiserMask function........................................................................................ 152
11.1 An example of a low-pass filter ......................................................................................... 154
11.2 An example of a high-pass filter ........................................................................................ 155
11.3 An example of a band-pass filter ....................................................................................... 155
11.4 An example of a band-pass filter with soft edges .............................................................. 156
11.5 The Wedge function .......................................................................................................... 157
11.6 An example of line filtering ............................................................................................... 158
11.7 The MaskinF function....................................................................................................... 159
11.8 The MultiWedges function ............................................................................................... 160
xviii Python Codes

11.9 The ColorCode1 function ................................................................................................. 160


11.10 Removal of the screen from the baseball image ................................................................ 162
12.1 Smoothing through a correlation with a small solid block ................................................ 167
12.2 The Correlate1D function................................................................................................. 169
12.3 The Correlate2DF function .............................................................................................. 169
12.4 Correlating shapes.............................................................................................................. 169
12.5 Loading and creating the necessary images....................................................................... 171
12.6 The LocateDock function.................................................................................................. 172
12.7 The Overlay function ........................................................................................................ 173
12.8 The SubtractDock function .............................................................................................. 174
12.9 The IDboats function ........................................................................................................ 174
12.10 The FPF function............................................................................................................... 176
12.11 Testing the FPF function ................................................................................................... 177
12.12 Computing an FPF ............................................................................................................. 178
12.13 The LoadTach function..................................................................................................... 179
12.14 The MakeTachFPF function............................................................................................. 180
12.15 Running the functions in the tachometer problem............................................................. 180
13.1 Shifting a simple array ....................................................................................................... 189
13.2 Extracting the vertical edges .............................................................................................. 190
13.3 Using the Sobel function to create an edge enhancement ................................................. 191
13.4 Application of the DoG filter ............................................................................................. 193
13.5 The Harris function........................................................................................................... 194
13.6 Applying the Harris detector to simple geometric shapes ................................................. 195
14.1 The LineHough function................................................................................................... 200
14.2 Creating Figure 14.1 .......................................................................................................... 201
14.3 Creating Figure 14.2 .......................................................................................................... 201
14.4 Running the Hough transform on an image with a line ..................................................... 201
14.5 The Hough transform applied to a different image............................................................ 202
14.6 Creating a line that is at a different orientation.................................................................. 202
14.7 Circle Hough transform applied to multiple rings ............................................................. 204
14.8 The detection of the cane ................................................................................................... 206
15.1 Adding random noise......................................................................................................... 210
15.2 Smoothing in Python ......................................................................................................... 210
15.3 Salt noise............................................................................................................................ 211
15.4 Applying colored noise ...................................................................................................... 212
15.5 The AddNoise function ..................................................................................................... 213
15.6 The Lopass function .......................................................................................................... 214
15.7 The ErosionDilation function ........................................................................................... 215
15.8 Applying a median filter .................................................................................................... 216
15.9 Applying a Wiener filter .................................................................................................... 217
16.1 Simple texture measure through the ratio of the mean and standard deviation ................. 223
16.2 Compute the edge density.................................................................................................. 223
16.3 Measuring the four moments ............................................................................................. 225
16.4 The FourMoments function.............................................................................................. 225
16.5 Beginning the comparison of textures ............................................................................... 226
16.6 The WvlIteration function................................................................................................ 228
16.7 Creating an output after a single iteration in wavelet decompostion ................................. 228
16.8 The WaveletDecomp function .......................................................................................... 229
16.9 The GetParts function....................................................................................................... 230
16.10 The WaveletEnergies function.......................................................................................... 230
Python Codes xix

16.11 The Cooccurrence function .............................................................................................. 231


16.12 The HHomogeneity function ............................................................................................ 232
16.13 The HContrast function.................................................................................................... 233
16.14 The HCorrelation function ............................................................................................... 234
16.15 The HVariance function.................................................................................................... 234
16.16 The HEntropy function..................................................................................................... 235
16.17 The Haralick function....................................................................................................... 236
16.18 Using the Haralick function.............................................................................................. 237
16.19 The five Law’s vectors ....................................................................................................... 239
16.20 The BuildLawsFilters function ........................................................................................ 239
16.21 The LawsJets function ...................................................................................................... 240
17.1 The GaborCos function .................................................................................................... 244
17.2 The Filts function .............................................................................................................. 244
17.3 The ManyCorrelations function ...................................................................................... 245
17.4 Complete steps to create an image, Gabor filters, and the correlations ............................. 246
17.5 The RandomJets function................................................................................................. 247
17.6 The entire process of gathering correlations, extracting jets, and mapping in
PCA space ......................................................................................................................... 248
18.1 The PerimeterPoints function .......................................................................................... 254
18.2 The ShowPerimPoints function........................................................................................ 254
18.3 The ChainLength function ............................................................................................... 255
18.4 The Curvature function .................................................................................................... 255
18.5 The FourierDescriptors function ..................................................................................... 257
18.6 The ReadFiducial function ............................................................................................... 259
18.7 The RemoveCenterBias function ..................................................................................... 260
18.8 The RemoveRotateBias function...................................................................................... 261
18.9 The RemoveScaleBias function ........................................................................................ 261
18.10 The GridDifference function ............................................................................................ 262
18.11 The Shape1 function.......................................................................................................... 263
18.12 The ExtractStats function................................................................................................. 263
18.13 Computing four geometric values...................................................................................... 266
18.14 The metrics for the six shapes............................................................................................ 267
18.15 The CurveFlow function ................................................................................................... 268
18.16 Running iterations of curvature flow ................................................................................. 269
18.17 Computing the medial axis ................................................................................................ 270
19.1 Using the 1D discrete cosine transform ............................................................................. 276
19.2 An example of a 1D DCT .................................................................................................. 277
19.3 The dct2d function ............................................................................................................ 278
19.4 The idct2d function ........................................................................................................... 278
19.5 Modified 2D EMD ............................................................................................................. 284
19.6 Reconstruction ................................................................................................................... 285
20.1 The original PCNN Python class ....................................................................................... 295
20.2 Typical execution of the PCNN ......................................................................................... 295
C.1 Programs to convert RGB to XYZ and then to CIE L*a*b* ............................................. 327
C.2 The Zernike function ........................................................................................................ 328
C.3 The Plop function .............................................................................................................. 329
C.4 The Warp function ............................................................................................................ 330
C.5 The KaiserMask function ................................................................................................. 331
Exploring the Variety of Random
Documents with Different Content
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law in
the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms of
this agreement by keeping this work in the same format with its
attached full Project Gutenberg™ License when you share it without
charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears, or
with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in paragraph
1.F.3, the Project Gutenberg Literary Archive Foundation, the owner
of the Project Gutenberg™ trademark, and any other party
distributing a Project Gutenberg™ electronic work under this
agreement, disclaim all liability to you for damages, costs and
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving it,
you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or entity
that provided you with the defective work may elect to provide a
replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the
Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and distribution
of Project Gutenberg™ electronic works, harmless from all liability,
costs and expenses, including legal fees, that arise directly or
indirectly from any of the following which you do or cause to occur:
(a) distribution of this or any Project Gutenberg™ work, (b)
alteration, modification, or additions or deletions to any Project
Gutenberg™ work, and (c) any Defect you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like