0% found this document useful (0 votes)
11 views

4878

The document provides information about various eBooks related to image processing and analysis, available for download on ebookluna.com. It includes titles such as 'Image Operators: Image Processing in Python' and 'Digital Image Processing' among others, along with links for instant access. Additionally, it outlines the contents of a specific eBook, detailing chapters on image operators, scripting in Python, digital images, color models, and various image processing techniques.

Uploaded by

ouzkhyrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

4878

The document provides information about various eBooks related to image processing and analysis, available for download on ebookluna.com. It includes titles such as 'Image Operators: Image Processing in Python' and 'Digital Image Processing' among others, along with links for instant access. Additionally, it outlines the contents of a specific eBook, detailing chapters on image operators, scripting in Python, digital images, color models, and various image processing techniques.

Uploaded by

ouzkhyrul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Get the full ebook with Bonus Features for a Better Reading Experience on ebookluna.

com

(eBook PDF) Image Operators: Image Processing in


Python

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

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookluna.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

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


Edition

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

ebookluna.com

Digital Image Processing Using MATLAB 1st edition - eBook


PDF

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

ebookluna.com

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


C. Gonzalez

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

ebookluna.com

Feature extraction and image processing for computer


vision Fourth Edition Aguado - eBook PDF

https://ebookluna.com/download/feature-extraction-and-image-
processing-for-computer-vision-ebook-pdf/

ebookluna.com
(eBook PDF) Radiographic Image Analysis 5th Edition

https://ebookluna.com/product/ebook-pdf-radiographic-image-
analysis-5th-edition/

ebookluna.com

Riemannian geometric statistics in medical image analysis


Pennec X 1st edition - eBook PDF

https://ebookluna.com/download/riemannian-geometric-statistics-in-
medical-image-analysis-ebook-pdf/

ebookluna.com

Handbook of Robotic and Image-Guided Surgery 1st Edition -


eBook PDF

https://ebookluna.com/download/handbook-of-robotic-and-image-guided-
surgery-ebook-pdf/

ebookluna.com

(eBook PDF) Deep Learning for Medical Image Analysis by S.


Kevin Zhou

https://ebookluna.com/product/ebook-pdf-deep-learning-for-medical-
image-analysis-by-s-kevin-zhou/

ebookluna.com

Handbook of medical image computing and computer assisted


intervention 1st Edition- eBook PDF

https://ebookluna.com/download/handbook-of-medical-image-computing-
and-computer-assisted-intervention-ebook-pdf/

ebookluna.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
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
Discovering Diverse Content Through
Random Scribd Documents
THE WINDOW; OR THE SONGS OF THE WRENS.
AT THE WINDOW.

VINE, vine and eglantine,


Clasp her window, trail and twine!
Rose, rose and clematis,
Trail and twine and clasp and kiss,
Kiss, kiss; and make her a bower
All of flowers, and drop me a flower,
Drop me a flower.

Vine, vine and eglantine,


Cannot a flower, a flower, be mine?
Rose, rose and clematis,
Drop me a flower, a flower, to kiss,
Kiss, kiss—and out of her bower
All of flowers, a flower, a flower
Dropt, a flower.
GONE.

Gone!
Gone till the end of the year,
Gone, and the light gone with her and left me in shadow here!
Gone—flitted away,
Taken the stars from the night and the sun from the day!
Gone, and a cloud in my heart, and a storm in the air!
Flown to the east or the west, flitted I know not where!
Down in the south is a flash and a groan; she is there! she is there!

Alfred, Lord Tennyson.


VALENTINE.
IF thou canst make the frost be gone,
And fleet away the snow
(And that thou canst, I trow);
If thou canst make the spring to dawn,
Hawthorn to put her brav’ry on,
Willow, her weeds of fine green lawn,
Say why thou dost not so—
Aye, aye!
Say why
Thou dost not so!

If thou canst chase the stormy rack,


And bid the soft winds blow
(And that thou canst, I trow);
If thou canst call the thrushes back
To give the groves the songs they lack,
And wake the violet in thy track,
Say why thou dost not so—
Aye, aye!
Say why
Thou dost not so!

If thou canst make my winter spring,


With one word breathèd low
(And that thou canst, I know);
If in the closure of a ring
Thou canst to me such treasure bring,
My state shall be above a king,
Say why thou dost not so—
Aye, aye!
Say why
Thou dost not so!

Edith M. Thomas.
DREAM TRYST.

THEWere
breaths of kissing night and day
mingled in the eastern heaven;
Throbbing with unheard melody
Shook Lyra all its star-chord seven:
When dusk shrunk cold, and light trod shy,
And dawn’s gray eyes were troubled gray;
And souls went palely up the sky,
And mine to Lucidé.

There was no change in her sweet eyes


Since last I saw those sweet eyes shine;
There was no change in her deep heart
Since last that deep heart knocked at mine.
Her eyes were clear, her eyes were Hope’s,
Wherein did ever come and go
The sparkle of the fountain-drops
From her sweet soul below.

The chambers in the house of dreams


Are fed with so divine an air,
That Time’s hoar wings grow young therein,
And they who walk there are most fair.
I joyed for me, I joyed for her,
Who with the Past meet girt about,
Where our last kiss still warms the air,
Nor can her eyes go out.

Francis Thompson.
ATALANTA.

WHEN spring grows old, and sleepy winds


Set from the south with odours sweet,
I see my love, in green, cool groves,
Speed down dusk aisles on shining feet.

She throws a kiss and bids me run,


In whispers sweet as roses’ breath;
I know I cannot win the race,
And at the end, I know, is death.

But joyfully I bare my limbs,


Anoint me with the tropic breeze,
And feel through every sinew thrill
The vigour of Hippomenes.

A race of love! We all have run


Thy happy course through groves of spring,
And cared not, when at last we lost,
For life, or death, or anything!

Maurice Thompson.
A SONG OF THANKSGIVING.

MYThy
love is the flaming sword, to fight through the world;
love is the shield to ward,
And the armour of the Lord,
And the banner of Heav’n unfurl’d.

Let my voice ring out, and over the earth,


Through all the grief and strife,
With a golden joy in a silver mirth,
Thank God for Life!

Let my voice swell out through the great abyss,


To the azure dome above,
With a chord of faith in the harp of bliss
Thank God for Love!

Let my voice thrill out, beneath and above,


The whole world through,
O my Love and Life, O my Life and Love,
Thank God for you!

James Thomson.
DAY AFTER DAY OF THIS AZURE MAY.

DAYTheafter day of this azure May,


blood of the spring has swelled in my veins;
Night after night of broad moonlight,
A mystical dream has dazzled my brains.

A seething might, a fierce delight,


The blood of the spring is the wine of the world;
My veins run fire and thrill desire,
Every leaf of my heart’s red rose uncurled.

A sad, sweet calm, a tearful balm,


The light of the moon is the trance of the world;
My brain is fraught with yearning thought,
And the rose is pale, and its leaves are furled.

Oh, speed the day then, dear, dear May,


And hasten the night, I charge thee, O June!
When the trance divine shall burn with the wine,
And the red rose unfurl all its fire to the moon.

James Thomson.
THE SONG OF TRISTRAM.

THENight
star of love is trembling in the west,
hears the desolate sea with moan on moan
Sigh for the storm, who on his mountain lone
Smites his wild harp, and dreams of her wild breast.
I am thy storm, Isolt, and thou my sea!
Isolt!
My passionate sea!

The storm to her wild breast, the passionate sea


To his fierce arms: we to the rapturous leap
Of mated spirits mingling in love’s deep,
Flame to flame, I to thee and thou to me!
Thou to mine arms, Isolt, I to thy breast!
Isolt!
I to thy breast!

John Todhunter.
AUBADE.

THELoose
lights are out in the street, and a cool wind swings
poplar plumes on the sky;
Deep in the gloom of the garden the first bird sings:
Curt, hurried steps go by,
Loud in the hush of the dawn past the linden screen,
Lost in a jar and a rattle of wheels unseen,
Beyond on the wide highway:
Night lingers dusky and dim in the pear-tree boughs,
Hangs in the hollows of leaves, though the thrushes rouse,
And the glimmering lawn grows gray.

Yours, my heart knoweth, yours only the jewelled gloom,


Splendours of opal and amber, the scent, the bloom,
Yours all, and your own demesne—
Scent of the dark, of the dawning, of leaves and dew;
Nothing that was but hath changed—’tis a world made new—
A lost world risen again.

The lamps are out in the street, and the air grows bright;
Come, lest the miracle fade in the broad, bare light,
The new world wither away:
Clear is your voice in my heart, and you call me—whence?
Come—for I listen, I wait,—bid me rise, go hence,
Or ever the dawn turn day.

Graham R. Tomson.
LOVE, THE GUEST.
I DIDI deemed
not dream that Love would stay,
him but a passing guest,
Yet here he lingers many a day.

I said, “Young Love will flee with May,


And leave forlorn the hearth he blest;”
I did not dream that Love would stay.

My envious neighbour mocks me, “Nay,


Love lies not long in any nest;”
Yet here he lingers many a day.

And though I did his will alway,


And gave him even of my best,
I did not dream that Love would stay.

I have no skill to bid him stay,


Of tripping tongue or cunning jest,
Yet here he lingers many a day.

Beneath his ivory feet I lay


Pale plumage of the ringdove’s breast;
I did not dream that Love would stay.

Will Love be flown? I ofttimes say,


Home turning for the noonday rest;
Yet here he lingers many a day.

His gold curls gleam, his lips are gay,


His eyes through tears smile loveliest;
I did not dream that Love would stay.

He sometimes sighs, when far away


The low red sun makes fair the west,
Yet here he lingers many a day.

Thrice blest of all men am I! yea


Thrice blest of all men am I! yea,
Although of all unworthiest;
I did not dream that Love would stay,
Yet here he lingers many a day.

Graham R. Tomson.
A BLUSH AT FAREWELL.

HERThine,
tears are all thine own! how blest thou art!
too, the blush which no reserve can bind;
Thy farewell voice was as the stirring wind
That floats the rose-bloom; thou hast won her heart;
Dear are the hopes it ushers to thy breast;
She speaks not—but she gives her silent bond;
And thou mayst trust it, asking nought beyond
The promise, which as yet no words attest;
Deep in her bosom sinks the conscious glow,
And deep in thine! and I can well foresee,
If thou shalt feel a lover’s jealousy
For her brief absence, what a ruling power
A bygone blush shall prove! until the hour
Of meeting, when thy next love-rose shall blow.

Charles Tennyson Turner.


THE KISS OF BETROTHAL.

WHEN lovers’ lips from kissing disunite


With sound as soft as mellow fruitage breaking,
They loathe to leave what was so sweet in taking,
So fraught with breathless magical delight;
The scent of flowers is long before it fade,
Long dwells upon the gale the Vesper-tone,
Far floats the wake the lightest skiff has made,
The closest kiss when once imprest, is gone;
What marvel, then, that each so closely kisseth?
Sweet is the fourfold touch—the living seal—
What marvel then, with sorrow each dismisseth
This thrilling pledge of all they hope and feel?
While on their lingering steps the shadows steal,
And each true heart beats as the other wisheth.

Charles Tennyson Turner.


THE PARTING-GATE.

IN that old beech-walk, now bestrewn with mast,


And roaring loud—they linger’d long and late;
Harsh was the clang of the last homeward gate
That latch’d itself behind them, as they pass’d—
Then kiss’d and parted. Soon her funeral knell
Toll’d from a foreign clime; he did not talk
Nor weep, but shudder’d at that stern farewell;
’Twas the last gate in all their lovers’-walk
Without the kiss beyond it! Was it good
To leave him thus, alone with his sad mood
In that dear footpath, haunted by her smile?
Where they had laugh’d and loiter’d, sat and stood?
Alone in life! alone in Moreham wood!
Through all that sweet, forsaken, forest mile!

Charles Tennyson Turner.


IRISH LOVE SONG.

WOULD God I were the tender apple-blossom,


Floating and falling from the twisted bough,
To lie and faint within your silken bosom,
As that does now!

Or would I were a little burnished apple


For you to pluck me, gliding by so cold,
While sun and shade your robe of lawn will dapple,
Your hair’s spun gold.

Yea, would to God I were among the roses


That lean to kiss you as you float between!
While on the lowest branch a bud uncloses
To touch you, Queen!

Nay, since you will not love, would I were growing


A happy daisy in the garden path;
That so your silver foot might press me going,
Even unto death!

Katherine Tynan.
GOOD-NIGHT.

IT isI over now, she is gone to rest;


have clasped the hands on the quiet breast;
Draw back the curtain, let in the light,
She will never shrink if it be too bright.

We were two in here but an hour gone by,


No streak was then in the midnight sky;
Now I am one to watch the day
Come glimmering up from the far-away.

What will he say when he comes in,


Waked by the city’s morning din,
Hoping to find and fearing to know
The sorrow he left but an hour ago?

What will he say who has watched so long,


When he shall find who has come and gone?
Come a watcher that will not bide
Love’s morning or noon or eventide.

He thought to kiss her by morning gray,


But God has thought to take her away.
What will he say? God knows, not I;
“Good-night,” he said, but never “good-bye.”

C. C. Fraser Tytler.
I KNOW ’TIS LATE, BUT LET ME STAY.
I KNOW ’tis late, but let me stay,
For night is tenderer than day;
Sweet love, dear love, I cannot go;
Dear love, sweet love, I love thee so.
The birds are in the grove asleep,
The katydids shrill concert keep,
The woodbine breathes a fragrance rare
To please the dewy, languid air,
The fireflies twinkle in the vale,
The river shines in moonlight pale:
See yon bright star! choose it for thine,
And call its near companion mine;
Yon air-spun lace above the moon,—
’Twill veil her radiant beauty soon;
And look! a meteor’s dreamy light
Streams mystic through the solemn night.
Ah, life glides swift, like that still fire—
How soon our gleams of joy expire!
Who can be sure the present kiss
Is not his last? Make all of this.
I know ’tis late, dear love, I know,
Dear love, sweet love, I love thee so.

It cannot be the stealthy day


That turns the orient darkness gray;
Heardst thou? I thought or feared I heard
Vague twitters of some wakeful bird.
Nay, ’twas but summer in her sleep
Low murmuring from the leafy deep.
Fantastic mist obscurely fills
The hollows of Kentucky hills.
The wings of night are swift indeed!
Why makes the jealous morn such speed?
This rose thou wear’st may I not take
For passionate remembrance’ sake?
P ith th li it i h t
Press with thy lips its crimson heart.
Yes, blushing rose, we must depart.
A rose cannot return a kiss—
I pay its due with this, and this.
The stars grow faint, they soon will die,
But love fades not nor fails. Good-bye!
Unhappy joy—delicious pain—
We part in love, we meet again.
Good-bye! the morning dawns—I go;
Dear love, sweet love, I love thee so.

William H. Venable.
CASHEL OF MUNSTER.

I WOULD wed you, dear, without gold or gear, or counted kine;


My wealth you’ll be, would your friends agree, and you be mine.
My grief, my gloom! that you do not come, my heart’s dear hoard!
To Cashel fair, though our couch were there but a soft deal board.

Oh, come, my bride, o’er the wild hill-side to the valley low!
A downy bed for my love I’ll spread where waters flow,
And we shall stray where streamlets play, the groves among,
Where echo tells to the listening dells the blackbird’s song.

Love tender, true, I gave to you, and secret sighs,


In hope to see upon you and me one hour arise,
When the priest’s blest voice would bind my choice and the ring’s strict tie,
If wife you be, love, to one but me, love, in grief I’ll die!

A neck of white has my heart’s delight, and breast like snow,


And flowing hair whose ringlets fair to the green grass flow,
Alas! that I did not early die, before the day
That saw me here, from my bosom’s dear, far, far away!

Edward Walsh.
DAFFODILS.

I QUESTION with the amber daffodils,


Sheeting the floors of April, how she fares;
Where king-cup buds gleam out between the rills,
And celandine in wide gold beadlets glares.

By pastured brows and swelling hedgerow bowers,


From crumpled leaves the primrose bunches slip,
My hot face roll’d in their faint-scented flowers,
I dream her rich cheek rests against my lip.

All weird sensations of the fervent prime


Are like great harmonies, whose touch can move
The glow of gracious impulse: thought and time
Renew my love with life, my life with love.

When this old world new-born puts glories on,


I cannot think she never will be won.

John Leicester Warren.


AVE ATQUE VALE.

FAREWELL my Youth! for now we needs must part,


For here the paths divide;
Here hand from hand must sever, heart from heart,—
Divergence deep and wide.

You’ll wear no withered roses for my sake,


Though I go mourning for you all day long,
Finding no magic more in bower and brake,
No melody in song.

Gray Eld must travel in my company


To seal this severance more fast and sure.
A joyless fellowship, i’ faith, ’twill be,
Yet must we fare together, I and he,
Till I shall tread the footpath way no more.

But when a blackbird pipes among the boughs,


On some dim iridescent day in spring,
Then I may dream you are remembering
Our ancient vows.

Or when some joy foregone, some fate forsworn


Looks through the dark eyes of the violet,
I may recross the set, forbidden bourne, I may forget
Our long, long parting for a little while,
Dream of the golden splendours of your smile,
Dream you remember yet.

Rosamund Marriot Watson.

You might also like