100% found this document useful (2 votes)
11 views

Image operators image processing in Python First Edition Kinser - The latest updated ebook version is ready for download

The document promotes the ebook 'Image Operators: Image Processing in Python' by Jason M. Kinser, available for download at textbookfull.com. It includes a detailed table of contents outlining various chapters on image processing techniques, Python scripting, and mathematical concepts related to image manipulation. Additionally, it provides links to other related ebooks on image processing and computer vision.

Uploaded by

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

Image operators image processing in Python First Edition Kinser - The latest updated ebook version is ready for download

The document promotes the ebook 'Image Operators: Image Processing in Python' by Jason M. Kinser, available for download at textbookfull.com. It includes a detailed table of contents outlining various chapters on image processing techniques, Python scripting, and mathematical concepts related to image manipulation. Additionally, it provides links to other related ebooks on image processing and computer vision.

Uploaded by

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

Explore the full ebook collection and download it now at textbookfull.

com

Image operators image processing in Python First


Edition Kinser

https://textbookfull.com/product/image-operators-image-
processing-in-python-first-edition-kinser/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Image Operators: Image Processing in Python 1st Edition


Jason M. Kinser

https://textbookfull.com/product/image-operators-image-processing-in-
python-1st-edition-jason-m-kinser/

textbookfull.com

Mathematical Image Processing Kristian Bredies

https://textbookfull.com/product/mathematical-image-processing-
kristian-bredies/

textbookfull.com

Computing Colour Image Processing Alan Parkin

https://textbookfull.com/product/computing-colour-image-processing-
alan-parkin/

textbookfull.com

Image Processing and Computer Vision in iOS Oge Marques

https://textbookfull.com/product/image-processing-and-computer-vision-
in-ios-oge-marques/

textbookfull.com
Digital Image Processing Practical Approach Borko Furht

https://textbookfull.com/product/digital-image-processing-practical-
approach-borko-furht/

textbookfull.com

Computer Vision and Image Analysis Digital Image


Processing and Analysis 4th Edition Scott E Umbaugh

https://textbookfull.com/product/computer-vision-and-image-analysis-
digital-image-processing-and-analysis-4th-edition-scott-e-umbaugh/

textbookfull.com

Image Processing and Pattern Recognition Based on Parallel


Shift Technology First Edition Bilan

https://textbookfull.com/product/image-processing-and-pattern-
recognition-based-on-parallel-shift-technology-first-edition-bilan/

textbookfull.com

Nonlinear Eigenproblems in Image Processing and Computer


Vision Guy Gilboa

https://textbookfull.com/product/nonlinear-eigenproblems-in-image-
processing-and-computer-vision-guy-gilboa/

textbookfull.com

Digital image interpolation in MATLAB First Edition Kok

https://textbookfull.com/product/digital-image-interpolation-in-
matlab-first-edition-kok/

textbookfull.com
Image Operators
Image Operators
Image Processing in Python

Jason M. Kinser
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2019 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
No claim to original U.S. Government works

Printed on acid-free paper


International Standard Book Number-13: 978-1-4987-9618-7 (Hardback)
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made
to publish reliable data and information, but the author and publisher cannot assume responsibility for the validity of all
materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all
material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been
obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future
reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or utilized in
any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, micro-
filming, and recording, or in any information storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://www.
copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-
750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations
that have been granted a photocopy license by the CCC, a separate system of payment has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identifi-
cation and explanation without intent to infringe.

Library of Congress Cataloging-in-Publication Data

Names: Kinser, Jason M., 1962- author.


Title: Image operators: image processing in Python/Jason M. Kinser.
Description: First edition. | Boca Raton, FL: CRC Press/Taylor & Francis Group, [2019] |
“A CRC title, part of the Taylor & Francis imprint, a member of the Taylor & Francis Group,
the academic division of T&F Informa plc.” | Includes bibliographical references and index.
Identifiers: LCCN 2018017140 (print) | LCCN 2018017764 (ebook) | ISBN 9780429451188 (eBook) |
ISBN 9780429835940 (Adobe PDF) | ISBN 9780429835933 (ePUB) |
ISBN 9780429835926 (Mobipocket) | ISBN 9781498796187 (hardback: acid-free paper)
Subjects: LCSH: Image processing—Digital techniques. | Python (Computer program language)
Classification: LCC TA1637 (ebook) | LCC TA1637 .K48 2019 (print) | DDC 006.6—dc23
LC record available at https://lccn.loc.gov/2018017140

Visit the Taylor & Francis Web site at


http://www.taylorandfrancis.com

and the CRC Press Web site at


http://www.crcpress.com
This book is dedicated to my beautiful wife – Sue Ellen.
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
Preface
Image processing and analysis is a burgeoning field that is gaining renewed interest in recent years.
The need for image analysis tools is ever increasing. Along with this is also the need to be able to
efficiently and explicitly describe processes used in analyzing images. Unfortunately, the current
state of publications is that each author has their own way of describing processes. Two different
authors describing the same process will often provide vastly different ways of communicating their
proposed process.
The recent development of high-powered scripting languages such as Python compounds the
issue. Publications can consume more real estate in explaining the process than it takes to write
the Python script to execute the process. Furthermore, the descriptions can be imprecise, because
some authors prefer to describe their processes through textual descriptions. Readers attempting to
replicate their results may find it a difficult process as not all of the steps are clearly explained.
The purpose of this text is to provide a unified mathematical language that coincides with Python
scripting. Image operators represent processes in a image analysis sequence, and these are associated
with Python scripts. Thus, a concise mathematical description of a process is easily translated into
Python scripts through this correlation. The conversion of Python scripts to image operators is nearly
as easy. Thus, this text introduces the initial set of image operators, complete with associated Python
scripts and examples.

Jason Kinser, D.Sc.


George Mason University
Fairfax, VA, USA
jkinser@gmu.edu

xxi
Software and Data
Software and data used in this text are available at:
https://jmkinser49.wixsite.com/imageoperators
Software and images copyright (c) Jason M. Kinser 2018. Software and images provided on this
site may be used for educational purposes. All other rights are reserved by the author.

xxiii
Author
Jason M Kinser, DSc, has been an associate professor at George Mason University for more than
18 years teaching courses in physics, computational science, bioinformatics and forensic science.
Recently, he converted the traditional university physics course into an active learning technology
environment at GMU. His research interests include modern teaching techniques, more effective
methods in text-based education, image operators and analysis, pulse image processing and multi-
domain data analysis. This book was born from a desire to engage students in physics education
and to find ways of reducing the external costs that both students and institutions incur within the
traditional education framework.

xxv
Part I

Image Operators
Discovering Diverse Content Through
Random Scribd Documents
Flor. (aside). Betrothed, i’ faith!
They’re lovers, then!

Vav. I must devise some gift


To mark this happy day. What shall it be?
I’ll weave a bower of rose and eglantine
To place above thy head at eventide,
When the full moon’s abroad. No foolish moon
Shall cast false shadows on thy sleeping face,
Or make thee mutter incoherent tales
Of hours long since gone by or yet to come.
No madcap moon shall mar thy nightly rest,
Or in the mischief of half-witted glee
Awake thy sleeping hours before their time.

Flor. (aside). He doesn’t answer—the insensate dolt!—


And yet such words are warm enough to rouse
A tombstone into life!

Vav. I’ve brought thee flowers


To deck thy stem. They live their little life,
And then they die; but others follow them—
And thou shalt have thy garland day by day
While I am here to weave it for thee?

Flor. (aside). Well,


This is the oddest wooing! On my word,
A thousand pities that the lady’s love
Should be lopsided! Come, arouse thee, dial—
Be eloquent with thanks! I’ve half a mind
To thank her for thee, in the interests
Of all true horologes!

Vav. I’m content


To sit and deck thee, silent though thou art.
And yet I would thou hadst the gift of speech
For one brief second—time enough to say,
“Vavir, I love thee with my whole, whole heart!”

Flor. (aloud). “Vavir, I love thee with my whole, whole heart!”

Vav. (recoiling, horrified). Who spake?

Flor. ’Twas I—thy dial!

Vav. Oh, terrible!


What shall I do?

Flor. Fair lady—have no fear.

Vav. “Fair lady”—It’s a man! My sisters, help!


I am betrayed!

Flor. Have patience for a while—

Vav. Who and what art thou?—speak!

Flor. (aside). What shall I say?


(Aloud.) I am a poor, long-suffering, mortal man,
Whom in the stony substance of thy dial,
A cruel magician holds incarcerate!

Vav. Oh, marvellous!

Flor. And very pitiful!

Vav. Aye, pitiful indeed, poor prisoned soul! (advancing.)

Flor. “There shalt thou lie,” said he, “till some pure maid
Shall have been constant to thine unseen self
A twelvemonth and a day.” That maid art thou!

Vav. Alas! poor man, I fain would set thee free.


Yet I have loved not thee, but this thy tomb!
Flor. Thou canst not separate me from my tomb
Except by loving me. In loving it
Thou lovest me who am bound up with it;
And in so loving me—provided that
Thy love, a twelvemonth old, lasts one day more—
Thou givest me my freedom and my life!
If thou hast loved thy dial thou hast loved me.

Vav. Yes, I have loved my dial!

Flor. But earnestly—


With a surpassing love?

Vav. I cannot say—


I am ill-versed in the degrees of love.
Judge for thyself—When I am weak and ill
My sisters place my couch beside my dial
That I may lay my poor thin hand on it:
It gives me life and strength—I know not why.
Judge for thyself—
When the black winter comes my sisters weep
To see me weep my darling’s brief day-life;
And when the bright, long summer days return
They join my joy—because with Light comes Hope,
And Hope is Life—and they would have me live!
Judge for thyself—
At dawn of day I seek my dial alone,
To watch its daily waking into life;
At set of sun I come to it again,
To kiss “good night” upon its fading shade:
Then, with a prayer that I may lay to heart
The lesson of its silent eloquence,
I seek my bed. So speeds my little life.
If this be love, then have I loved indeed!
Judge for thyself. (Rises.)
Enter Melusine (a small hand-mirror hangs from her waist).

Mel. Vavir, the evening dews are falling fast;


The night air teems with damp. So, come, dear love,
Return at once with me.

Vav. Oh, Melusine,


I have a secret. (Aside to dial.) May I tell it?

Flor. (whispering). Yes.

Mel. A secret?

Vav. Ay, a wondrous secret, too!


My sun-dial hath ears to hear withal—
And eyes to see withal—and a sweet voice,
A gentle, tender voice to woo withal!

Mel. Oh, marvellous! Oh, fortunate Vavir!


To woo—and to be woo’d—and, being woo’d,
To keep her vow intact! I’d give the world
If my loved mirror were endowed with speech!

Flor. Have then thy wish, fair lady!

Mel. Why, who spake?

Vav. Thy mirror spake!

Mel. Oh, day of wonderment!


Who gave thee speech? Art thou enchanted too?

Flor. Ay, that in truth I am, as all must be


On whom those eyes are turned so lovingly!

Mel. A very polished mirror!

Flor. As for that,


We mirrors are as other gallants are—
Teeming with compliment to fair young maids—
But apt to be extremely curt and rude
With old and wrinkled faces. On the whole
We are good gallants as good gallants go!

Mel. And dost thou love me?

Flor. Love thee, gentle maid?


Have I not laughed with thee, and wept with thee,
And ever framed my face in sympathy
With all the changes of thy varying moods?
Hast thou e’er cast thine eyes upon my face
And found me light of heart when thou wast sad?
Or sad when thou wast light of heart?

Mel. No! no!


Most wonderful!

Flor. And yet not wonderful!


I am but one of many. This fair isle
Teems with poor prisoned souls! There’s not a tree—
There’s not a rock, a brook, a shrub, a stone,
But holds some captive spirit who awaits
The unsought love that is to set him free!

Mel. (to Vavir). We’ll keep this secret safely to ourselves.


If it should get abroad, this little isle
Will barely hold the maidens who will come,
Prepared to pass the spring-time of their lives
In setting free these captives! Come, Vavir,
And we will warn our sisters.

Vav. Fare thee well,


Beloved dial: I go to dream of thee,
Dream thou of me! God send thee Sun. Good night!
[Exeunt Vavir and Melusine.
Flor. Two maids, at once bewitching—and bewitched!
One loves a mirror—well, that’s not so strange,
Though she’ll grow angry with it ten years hence!
The other loves a dial—a cold stern fact
That surely marks the deadly flight of time!
Wonders will never cease! let none despair—
Old Chronos, enemy of womankind,
Has found a pretty sweetheart, after all!

Enter Lady Hilda, singing and playing on mandolin.

Far from sin—far from sorrow


Let me stay—let me stay!
From the fear of to-morrow
Far away—far away!
I am weary and shaken,
Let me stay—let me stay,
Till in death I awaken
Far away—far away!

[Towards the close of the song, she sinks on her knees as a


ray of moonlight falls on her. Florian has watched her
eagerly during the song, with every symptom of the
profoundest admiration.

Flor. Oh, Heaven enlighten me—is this fair thing


A soul of Earth—a being, born of woman,
Conscious of sin and destined to decay?
Oh, Good and Ill, how share ye such a spoil!
Can this pure form, instinct with Heaven’s own light,
Clothed in the majesty of innocence,
Have aught in common with the vapid toy
We break and cast aside? Oh, sordid Earth,
Praise Heaven that leaves this angel yet unclaimed.
Oh, heart of mine—oh, wilful, wayward heart,
Bow down in homage—thou art caught and caged!
[During these lines Hilda, seated by the fountain, has been
playing with its water, and kissing her wet hands.

Hil. The sun has set—the fierce hot thirsty sun


Who, like a greedy vampire as he is,
Drinks my love’s life-blood till it pines away,
And dwindles to a thread. The moon’s abroad—
She is not jealous of my fountain love;
She sheds her gentle light upon our tryst
And decks my love with diamonds of her own!

Flor. (aside). Poor, senseless fount! To have thy home in Heaven


And not to know it!

Hil. Shall I tell thee how


I came to give my poor bruised heart to thee?
Or art thou of those churlish lovers who
Can brook no love that is not born of them?
Why, then, I am unworthy in thine eyes,
For I have loved, as women love but once!
He was a prince—a brave, God-fearing knight—
The very pink and bloom of Chivalry,
Proud as a war-horse—fair as the dawn of day—
Staunch as a Woman—tender as a Man!
He knew not that I loved him. Who was I
That he should mark the flushing of my face,
Amid a thousand maids whose stricken hearts
Danced to their lips, as he, my prince, rode by?
One sullen winter day—dark as his doom,
He left his home to seek a distant land.
A weary while I wept—months passed away,
And yet no tidings came. Then tales were told
Of ships o’erwhelmed by boisterous wintry seas;
And rough men prayed, and maidens wept aloud,
For he was loved of all! Then came the news;
At first in shuddering whispers, one by one—
Then babbled by ten thousand clamorous tongues—
The cold fierce sea had robbed me of my love!
My star—my light—my life—my Florian!

Flor. (aside). Oh, senseless dullard—to have turned away


From Heaven’s own threshold at thine own free will!

Hil. I wept no more.


Tears are the balm of sorrow—not of woe.
I fled my home—
A gentle sister whose poor little life
Lives on the love I bear it, fled with me;
So, hand in hand, we wandered through the world
Till, in this haven of pure peace and rest,
We found safe sanctuary from our woe.

Flor. (aloud). Who would not die to be so mourned by thee?


[Hilda expresses alarm and intense surprise.
Fear nothing. I who speak am but a voice—
The murmur of the waters, shaped to words
By the all-potent alchemy of Love!

Hil. Oh, foolish maid—this is some madcap dream!

Flor. No dream indeed—or if it be, dream on!

Hil. Canst thou then hear the words I speak to thee?

Flor. Ay, that I can—and every word I hear


Adds fuel to my love!

Hil. Oh, wonderful!


Hast thou the power to love?

Flor. Indeed I have!

Hil. And is thy love akin to mine?


Flor. It is
So near akin that, as it comes of thine,
And lives on thine, so, without thine, it dies!

Hil. If my poor love


Hath called thine into life—so is my love
In duty bound to thine—its kith and kin!

Flor. But if the rumours of thy Florian’s death


Should prove, as rumours often prove, untrue?
If he should be alive—loving thee well—
Eager to tell his love to thee—what then?

Hil. (sadly). Thou jealous fount, what untold miracle


Would bear the tidings to this lonely isle?

Flor. Say that in wandering through the unknown world


Chance led Prince Florian to these shores, and he,
Flushed with the radiance of thy loveliness,
Stood manifest before thine eyes—what then?

Hil. Oh, Heaven, what then! Joy kills as sorrow kills.


I dare not think what then! Let it suffice
That I have given thee all—that I am thine
For ever and for aye!

Enter Mousta unperceived; he places himself so that the dial


conceals him from Florian and Hilda.

Flor. “Ever and aye”


Are fragile flowers that fade before the breath
Of an old love long lost!

Hil. Oh, gentle voice,


Born of the falling water—have no fear—
In Heaven’s sight I pledge myself to thee—
What love is in me, that I give to thee—
What love thou hast to give, I take from thee—
Kiss thou my hands—(holding her hands for the water to
fall on)—henceforth we twain are one!
ACT II.
Scene, same as Act I. Time, Sunrise.
Enter Mousta, cautiously.

Mous. I left him sleeping soundly in my hut,


He did not drink the wine—but still he sleeps.
(Producing veil.) I stole it from his pillow! Here’s a prize!
Poor devil that I am—whose only hope
Of meeting other men on equal terms,
Lies in his chance of keeping out of sight!
Ha! someone comes. I’ll hide thee carefully.
[Places it under a stone of dial.
Some day, maybe, thou’lt do as much for me!

Enter Florian, angrily.

Flor. So here you are: I’ve sought you everywhere—

Mous. Ay, I am here. You’re early from your bed—


Well, it’s no bed for such fine folk as you;
I’m very sorry, but ’twas all I had.

Flor. The bed was well enough. I have been robbed.

Mous. Ay, ay? And how was that?

Flor. There is a thief


Upon this isle.

Mous. It’s very possible.


When people come and go invisibly,
It’s hard to say who is or is not here.
What has the villain robbed? a woman’s heart?
Two women’s hearts? How many women’s hearts?
If there’s a thief here, it is you or I,
It comes to that. Now, what is it you’ve lost?

Flor. My Talisman.

Mous. Your Talisman? Oh ho!

Flor. I see no cause for jest.

Mous. You don’t? Observe—


A prince, or someone who so styles himself,
With power to make himself invisible,
Employs that power to gain admission to
An isle where certain maidens dwell—when there
His Talisman is stolen and he stands
Revealed before their eyes—the helpless butt
Of all their ridicule, with naught to say
But “Ladies, pray forgive me—I had thought
To enter unobserved—to wander here
And watch your movements—also unobserved;
And when grown weary of this novel sport
To take my leave of you—still unobserved,
But as I’ve failed, so pray you pardon me.”
And off he goes, his tail between his legs,
Like a well-beaten hound!

Flor. (seizing him). Misshapen imp,


Have you so little care for such dog-life
As warms your twisted carcase, that you dare
To bandy jests with me?

Mous. Release me, sir!


Had I your Talisman, do you suppose
I should be here before your eyes? No, no—
Whoever has the veil is using it.
There are but six of us, besides myself.
If one of those is missing, why, be sure
That one hath taken it. I’ll go and see.
[Exit Mousta.

Flor. The imp is right, and yet the Talisman


Was safe with me last night. But, who comes here!
Confusion! ’tis Vavir. I shall be seen!
Where can I hide myself?

Enter Vavir; she starts in intense alarm on seeing Florian.

Vav. Kind Heaven protect me!


Who art thou, and what dost thou on this isle?

Flor. Fair maiden, have no fear. I am a knight,


Sworn on the sacred code of Chivalry,
To hold all womankind in reverence.
Listen, and I will tell thee all—

Vav. (who has recognized his voice, kneels as in adoration.)


No need!
Thy voice hath told me all! I know thee now!
Oh, foolish heart, be still, for all is well—
He will not harm thee; this is he whose words,
Through the still watches of the long, long night,
Rang like a mighty clarion in mine ears,
“Vavir, I love thee with my whole, whole heart!”
Thou art the messenger of hope and life,
For Heaven hath not bestowed this joy on me
To take me from it. Yes, I am to live!

Flor. (raising her). Why, Heaven forgive me, maiden—can it be


That thou hast loved this dial of thine with love
Akin to that which women bear to men?

Vav. Ay, that I have, as I’ve a soul to save!


Why, I have sat for hours and clung to it,
Until I half believed I felt a heart
Beating within its frame—and as I clung
Methought I drew both warmth and life from it!
I wondered then that such a thing could be—
Oh, my dear love, I do not wonder now! (Embracing him.)

Flor. (aside). God help thee, gentle maid! I little thought


My heedless words, conceived in arrant jest,
Chimed in so aptly with thy fantasies!
(Aloud.) Be not deceived;
I am a mortal like thyself, in all
Except thine innocence!—A sinning man,
Unworthy of thy love. Be not deceived.

Vav. I know thee, and I love thee as thou art—


Not as the Spirit of my nightly dreams,
But as thou art—a man of Life and Death.

Flor. Hast thou then seen a Spirit in thy dreams?

Vav. I have—the Spirit of the Sun-dial—


A godlike form of fearful excellence,
Clad, like the Sun, in golden panoply—
His head surmounted with a diadem
That shed eternal rays—and, in his hand,
A mighty javelin of gold and fire.
So pictured I the Sun’s Ambassador—
A god to worship—not a man to love! (Leaning on his breast.)
I had not guessed at half my happiness!

Flor. (aside). Now, by my knighthood, I would give ten years—


To find some way to break the truth to her!

Vav. Time was when I was very glad to die;


I did not fear what others seem to fear.
I have heard say that brave, stout-hearted men,
Whose reckless valour has withstood the test
Of many a battle-plain, will quail and blanch
Brought face to face with unexpected death.
I am a poor weak girl, whose fluttering heart
Quakes at the rustle of a leaf, and yet
I did not fear to die—I prayed to die!
But now thou hast so bound me to the earth,
Thou, oh my first, my last, my only love,
I dare not think of death! Oh, let me live,
My life is in thine hands—Oh, let me live!

Flor. Yes, thou shalt live, Vavir, so have no fear.

Vav. Thou wilt not leave me?

Flor. Only for a while;


I will return to thee.

Vav. So, hand in hand


We shall grow old, and die, still hand in hand?

Flor. Yes, ever hand in hand.

Vav. Oh, gentle Heaven,


I have more happiness than I can bear!
[Exit Vavir.

Flor. Poor soul, what shall I say? To tell her now


Would be to kill her!
[Pauses irresolute, then exit.

Enter Mousta, watching them.

Mous. Oh, ho! young knight! I’m sorry for Vavir!


Well, it concerns me not: the girl is fair;
And traps are set for her because she’s fair,
And she’ll fall into them because she’s fair.
Good looks
Should pay some penalty—that’s only fair.
Better be such as I am, after all;
No one sets traps for me. Ha! who comes here?
The Lady Hilda, parting from Vavir—
Come forth, my Talisman, the time has come
To test thy power.

[Takes veil from behind stone as Hilda enters hurriedly. He


winds it about his head.

Hil. Oh, Spirit of the Well,


I’ve wondrous news! The poor enchanted soul,
Till now entombed within the sun-dial,
Hath taken human form!
Oh, gentle spirit, grant my trembling prayer,
If thou hast power to quit thy silver stream
And stand in human form before mine eyes,
Then by my long and faithful love, I pray
That thou wilt suffer me to see thy face!

[Mousta hobbles across behind the fountain, and replies as


Florian.

Mous. Yes, I can take such form, but press me not——

Hil. And wherefore not?

Mous. I dare not show myself


Lest all thy love should fade?

Hil. Ah, have no fear,


My love runs with my life.

Mous. So women say,


Who live but once, yet love a dozen times!

Hil. I am not such as they!


Mous. I know it well—

Hil. Then let me see thy face—but once—but once—


Then thou shalt hie thee to thy well again
For ever if thou wilt!

Mous. That may not be—


Once seen in human form I must remain
A man—with more than man’s infirmities.
I am no shapely spirit framed to catch
A woman’s fancy—I am roughly hewn—
Somewhat uncouth—misshapen, some might say—
Dost thou not fear to look on me?

Hil. No, no.


Take thou thy form, whate’er that form may be!

Mous. But stay—


Thou hast a serving man—a crumpled wretch—
One-eyed and lame—but passing honest—say
That I am such a twisted thing as he?
What then?

Hil. (tenderly). Oh, Spirit of the Well, fear not,


My love is not a thing of yesterday;
Nor does it spring from thought of face and form.
I love thee for thy boundless charity,
That seeks no recompense—doing good works
In modest silence from the very love
Of doing good—bestowing life and strength
On high and low, on rich and poor alike;
Embracing in thy vast philosophy,
All creeds, all nations, and all ranks of men!
Holding thyself to be no higher than
The meanest wretch who claims thy charity,
Yet holding none to be of such account
As to deserve thine homage. Just to all,
Lovely in all thy modest deeds of good,
Excelling type of godliest charity,
Show thyself in whatever form thou wilt,
Oh, Spirit of the Well,
And I perforce must love thee!

Mous. Be it so!
Thou shalt behold me as I am. But first,
Ere I do that which cannot be undone,
Give me a solemn token that shall serve
As evidence of troth twixt thee and me.

Hil. Dost thou still doubt me then?

Mous. I doubt myself—


I doubt my rugged form, my rough-hewn face,
My crumpled limbs!—See, lady, I exchange
My immortality for Life and Death,
My demi-godhead for the state of Man—
Man, undersized and crippled, and accurst!
All this I do for thee—Let me be sure
That when I’ve done all this, thou wilt not cry,
“Away, distorted thing,
My love is not for such a one as thou!”

Hil. Oh, doubting Spirit, take this sacred ring.


It is a holy relic—and a vow
Spoken thereon binds her who utters it
Through life to death. Upon this sacred stone,
I do repeat my vow of yesternight!
I am thy bride! (Throws ring into the fountain.)

Mous. (taking the ring out of the fountain). Then, lady, have thy
will!
But, bear in mind that modest virtue oft
Will clothe herself in most unlikely garb—
Mistrust all prejudice—well-favoured hearts
May underlie ill-favoured heads. We spurn
The dirt beneath our feet—but never less
We grovel in such dirt for diamonds,
And sometimes find them there! A comely face
Is but the food of Time—a kindly heart
Time touches but to soften—think of this,
And in thy breast some pity may be found,
For the poor wretch to whom thy troth is given!

[Mousta reveals himself. Hilda, whose fears have been


gradually aroused during this speech, recoils in horror and
amazement at seeing him.

Hil. Mousta! Oh, Heaven, what have I said and done!


Was thine the voice that spake?

Mous. (abashed). My lady, yes!

Hil. Oh, cruel, cruel!

Mous. Lady, pardon me.


I knew not what I did!

Hil. Oh, wretched man!


I pardon thee—thou dost not, canst not know
How deep a wound thine idle words have riven!
Oh, heart! my broken heart! (Sinks on to ground by dial.)
My Mousta, shame upon thee for this jest—
This heartless jest—this scurril mockery!
When thou wast sick to death I tended thee,
Through weary days, and weary, weary nights,
And bathed thy fevered brow, and prayed with thee,
And soothed thy pain with such poor minstrelsy
As I am mistress of—I sang to thee,
And brought thee pleasant books to help thee speed
The lagging hours of thy recovery.
Has my heart seemed to thee so stony hard
That it could bear this deadly blow unbruised?
Oh, Mousta, shame upon thee for this jest!

Mous. Jest, Lady Hilda? Nay, I did not jest!


Why, look at me!

Hil. (gazing at him). Oh, Mousta! Can it be


That thou hast dared—No, no, impossible,——
It is too terrible!

Mous. Ay, I have dared!


I studied necromancy—and I learnt
To weave a mighty engine for myself—
A web that gives invisibility. (Producing veil.)
Shrouded in this, I woo’d thee yesternight!
Oh, I can woo—At least, I’ve shown thee that!
A voice rang music in thine ears—’twas mine!
Words thrilled thee to the core—I spake those words!
Love filled thy very soul—’twas I that woo’d!
My very self, stripped of the hideous mask
In which my soul stands shrouded from the world.
I’ll woo like that all day! But shut thine eyes,
Or turn thine head away, and I shall make
As fair a husband as the best of them!

Hil. Oh, horrible! Go—get thee hence, away—


Take money—what thou wilt—but get thee hence!
Oh, madman! madman!

Mous. Why, what could I do?


Should I have reasoned with myself, and said,
“Mousta, when thou wast sick and like to die,
The Lady Hilda came to thy bedside,
And sat, and nursed thee day by day—’twas nothing!
When writhing at thy very worst, her tears
Fell on thy face like rain,—a woman’s trick!
When baffled Death was tugging at thy throat,
Her gentle prayers rose to the gate of Heaven,
Mingled with the insensate blasphemies
Of thy delirium—account it naught!
Go to thy labour—get thy spade and dig,
And when a foolish sob of gratitude
Rises unbidden to thy choking throat”
(They sometimes will—one can’t be sure of them),
“Swear a big oath and whistle it away,
Lest it take root and blossom into love!”
Was this my duty, think ye? No, no, no,
My body’s twisted, lady, not my heart.

Hil. (with forced calmness). But say that, bound in duty to the troth
That thou hast wrung from me, I taught myself
I will not say to love—to bear with thee—
How could I hope to live at peace with one
Armed with so terrible a Talisman?
A Talisman that vests in him the power,
To come to me and go from me, unseen,
And play the truant at his own free will?
Thou askest more than womankind can grant.

Mous. (trembling with excitement).


Oh, lady, lady, give me but thy love,
And in that gift will lie the surest proof
That I will not misuse my Talisman!

Hil. It may be so—but Time’s an alchymist,


Who changes gold to dross. Some day, may be,
This love of thine will sicken, wane, and die.
How could I bear this widowhood of soul,
Knowing that thou hast power to come and go,
Unseen?
Mous. (overjoyed). Be sure I’ll neither come nor go:
My place is at thy side. Such love as thine
Would surely chain the proudest prince on earth,
And how much more so poor a wretch as I!

Hil. I’ll trust thee not.


Doubt would lie heavy at my heart, not less
Because I had no reason for that doubt.
Give me thy Talisman.

Mous. Nay, bear with me.

Hil. Give me thy Talisman.

Mous. Well, well, ’tis thine.


But bear in mind, the troth that thou hast pledged
Upon this ring can never be recalled.

Hil. I know it well.


I’ll keep my troth. Give me thy Talisman.

Mous. Lady, ’tis thine. See how I trust in thee.


Do with it as thou wilt—rend it apart,
And cast it to the winds—its work is done! (giving it to her)
Behold me now unarmed.

Hil. (changing her manner). Unarmed be thou


As all should be who use a deadly power
To such foul traitorous ends! I am thy bride—
I am thy bride! Make thou the very most
Of such poor comfort as those words may hold.
Proclaim thy victory—say to thyself,
“She is my bride—I wrung an oath from her,
With miserable lies—she is my bride!
She saved my wretched life, and in return
I poison hers—but still she is my bride.
She shudders at my all-polluting touch—
She loathes my mean and miserable soul:
What matters it, so that she be my bride?”
Oh, purblind fool—thy plot so subtly laid
Is laid too subtly—and the cunning snare
That trapped thy bird is laid too cunningly;
For as it made me thy poor prisoner,
So shall it hold me from thy deadly grasp
For ever and for ever! Raise thine head,
And look upon thy bride for once and all,
For by the Heaven above, the eye of man
Shall never rest upon my face again!
[She covers her face with veil, and exit.

Mous. (furiously). Fiends tear your throat to rags!—No, no, I rave


——
Hilda—come back to me—I’ll be thy slave,
Thy willing slave once more! I did but jest:
My jest is dead and gone—come back to me!
I will release thee from thy plighted troth:
I love thee—love thee—love thee! Oh, come back,
And save my soul and body! ’Twas a jest—
An idle jest. I am thy drudging slave,
No more than that! I never thought of love—
’Twas but a jest—’twas idly done, but well—
Oh, Lady Hilda—oh, come back to me!

Enter Florian.

Flor. What is this outcry?

Mous. It concerns you not.

Flor. Where is the Lady Hilda?

Mous. Who shall say?

Flor. Why, thou shalt say. As there’s a heaven above


I’ll wring a civil answer from thy lips.

Mous. Take any answer that may fit your mood,


And leave me to myself. I’m not in cue
For more cross-questioning.

Flor. Thine impish tongue


Is set awry to-day.

Mous. (savagely). It is awry.


Take care! But stay; when you were seeking for
Your Talisman, you bade me ascertain,
If any one were missing. Very well,
The Lady Hilda’s missing.

Flor. Foolish ape,


Dost thou infer—

Mous. I draw no inference.


I state the figures—add them for thyself.

Enter Hilda, still veiled; she gazes in amazement at Florian.

Hil. (aside). Merciful Heaven, restore me if I rave—


His form, his face, his voice!

Flor. (to Mousta). Base liar, know


That we are plighted lovers, she and I—
She gave her heart to me but yesternight;
Why should she hide herself from me to-day?

Mous. Perhaps excess of joy hath driven her mad!

Flor. I’ll not believe thy tale. The maid is here,


And can and shall be found!

Mous. Well, go and search.


And if thou findest her, why, I’m a liar—
Reward me as thou wilt!

Flor. A fit reward


Will be a yard of steel between thy ribs,
And thou shalt have it!

Mous. Thank you kindly, sir!


[Exit Mousta; Florian sits dejectedly by fountain.

Hil. ’Twas he that spake to me! How can I doubt?


Are there two such as he? Oh, Heaven, is this
The senseless herald of a mind unstrung?
Let me be sure.
He spake of me, who long had mourned him dead—
He told how, shrouded from my gaze last night,
He gave his love to me. Oh, gentle Heaven,
Give me more strength to bear this weight of joy!

[She advances to reveal herself, when Vavir enters, and sits


lovingly at Florian’s feet. Hilda, horrified, veils herself again.

Vav. At last I’ve found thee, Florian—far and near


I’ve sought thee, for I’m very strong to-day.
Why, what a wise physician is this Love!
For see—my eyes are bright—my face is flushed—
Flushed with the glow of health. This new-born love
Gives me a new-born strength. Oh, Florian,
Place thine arms round me—let me rest on thee;
I draw my life from thee—my heart—my heart!

Flor. (aside.) Alas, poor maiden—I must tell thee all,


May Heaven help me break the truth to thee!
(Aloud.) Dear little lady, yield not up thine heart
Too readily. The world is set with traps
And hidden pitfalls. Keep thy gentle heart
For one who, by his pure and godly life,
Hath given thee proof of his right worthiness.

Vav. (surprised). Why speakest thou in parable? Behold,


Have I not loved thee for a long, long year?

Flor. What proof hast thou that I indeed am he


Whom thou hast loved so long?

Vav. I have thy word,


And had I not thy word, I have my heart
To tell me whom to seek and whom to shun.

Flor. Mistrust that little heart. It is not framed


To guide thee of itself. Like virgin gold
Untainted by alloy, it is too pure
For this rough-ready world of work-a-day!
I have a tale to tell. There was a knight
Who, as he journeyed, met a gentle maid,
With whom he, light of heart and light of tongue,
Conversed in playful strain. The maid was fair,
And he, in jest, spake loving words to her,
Believing that she knew them to be feigned. (At this point it begins
to dawn upon Vavir that Florian is referring to her.)
She, pure as Faith—having no thought of guile
Tender and trustful in her innocence—
Believed the madcap knight’s unworthy words,
And nursed them in her heart. He, smit with shame,
For he was plighted to her sister (Vavir, finding her fears confirmed,
rises, shrinking from Florian, expressing extreme pain. He rises
after her) whom
He loved with an exceeding love, essayed,
With clumsy hint and far-fetched parable,
To break the truth to her. At length—at length,
By very slow degrees—light came to her!
Shall I go on?
Vav. (faintly). No need—I know the rest!
The maiden died—she pardoned him, and died!
(Vavir during the ensuing lines shows symptoms of fainting.)

Flor. (passionately). No, no—Vavir—she lived—the maiden lived!


He was not worth a tear—she loved him well,
But still she lived, Vavir—but still she lived!
If only for the gentle sister whom
She loved so tenderly, and for whose sake
She, in the blushing day-break of her life,
Had yielded up the world. Oh, say she lived!

[Vavir falls senseless in Florian’s arms. Hilda, who has been


listening eagerly to the latter part of Florian’s tale, kneels,
praying, as the act drop falls.
ACT III.
Scene, same as Act I. About half an hour before Sunset.
Vavir discovered sleeping at foot of Sun-dial. Melusine is
kneeling. Amanthis is standing, leaning on dial. Vavir’s head
rests on pillows, and a cloak envelopes her.

Am. How peacefully she sleeps! Oh, Melusine,


Can it be that this solemn death-like calm
Is but the silent herald of the end?

Mel. As she has lived, so will our darling die—


Gently and peacefully. This tranquil sleep
May change to tranquil death, and give no sign.
So will she pass away!

Am. But see—she wakes:


Would Heaven that we had fairer news for thee,
My poor Vavir!

Vav. (awaking, and very feebly). Thy face is very sad—


Are there no tidings of my sister?

Mel. None!

Vav. Dear Melusine, keep not the truth from me!


Some fearful evil has befallen her—
Tell me the truth. See, I am stronger now.

Mel. Nay, calm thyself, Vavir—save only that


She has been sought, and has not yet been found,
We have no truth to tell.

Vav. How speeds the day?


Am. Thy dial points to eight.

Vav. One little hour,


And then my Sun will set. Farewell, oh Sun!
How gloriously he dies!

Mel. The sun will sink,


To rest throughout the night, as we shall rest,
But not to die.

Vav. To die as we should die:


The night is given to the world that she
May mourn her widowhood. He knows no night,
But journeys calmly on his heavenly path
Wrapt in eternal light—in all, a type
Of the excelling life we try to live—
Of the all-glorious death we hope to die!

Mel. See, Vavir, see upon the Beacon-hill,


Mousta, returning from his weary search—

Vav. Is he alone?

Mel. Alas, my darling, yes!


But still perchance he brings some news to us:
I’ll go and meet him. Stay thou here, Vavir,
And I will bring thee tidings.

Vav. Be it so—
Be quick, be quick, dear Melusine—and then (to both)
Go, seek Prince Florian—and say to him
That I would fain have speech with him alone,
If he will deign to grant me audience.
[Exeunt Melusine and Amanthis.
Another hour—and then, my Sun will set!
Oh, Hilda—oh, my sister—come to me!
Hilda enters, veiled.

The loving day is drawing to a close:


I dare not face the cold, black night alone!
I want thine arms around me, and thy face
Pressed once again on mine, before I die.
Oh, Hilda—oh, my sister—come to me!

Hil. (unveiling, and kneeling). Vavir! Fear nothing.


I am here, my child.

Vav. (embracing her). Hilda! My sister! Heaven is merciful!


And thou art safe and well?

Hil. Yes, safe and well.

Vav. Where hast thou been? Throughout the long, long day
My weeping sisters have been seeking thee.

Hil. No matter now, Vavir. When thou art strong


I’ll tell thee all.

Vav. But I have news for thee,


Rare news, dear sister! Dry those gentle eyes;
The mighty sorrow that hath bowed thy heart
Is at an end! Thy prince—thy Florian,
Whom thou hast loved so tenderly—he lives!
Hilda, my sister, he is seeking thee!
Here, on this island, he is seeking thee!
Hilda, he loves thee; for he told me so!

Hil. I know he loves me.

Vav. Thou hast seen him then?

Hil. I know he loves me; ay, even more,


Vavir, I know the secret of thy heart—
Poor broken heart!

Vav. Oh! sister, pardon me.


I did not seek his love—nor knew I then
That he had loved thee—Sister, pardon me,
For I have suffered very bitterly!

Hil. Vavir, I have a prayer to make to thee.


Vavir, thou lovest him: thy little life,
More precious to us all than all the world,
Lies in his hands—he is thy life to thee,
And pitying Heaven hath led him to our shores
To save thee for us. Take no thought for me,
For I have wrestled with this love of mine
And vanquished it—it lies beneath my feet! (With assumed gaiety.)
Remember, thou and I have but one heart,
And so that it is happy—what care we
Whose bosom it may beat in—thine or mine?
(Nay, but thou shalt not speak!) I’ll keep away.
His eyes shall never rest on me again;
He will forget me, then, and wondrous soon!
Men’s hearts are in their eyes—this love of theirs
Must have its daily food or it will die:
I’ll keep away—so take him to thine heart,
And tell him—tell him—that I spake in jest,
That I had plucked his image from my heart
And cast it from me twelve long months ago.
Say that my heart is cold and dead to him.
Say that-say that— (Hilda breaks down, and sobs in Vavir’s lap.)

Vav. Oh, sister, weep no more!


Thy prince hath chosen, and hath chosen well.
Of what account is such a life as mine?
Why, it is ebbing fast! Grieve not for me.
And yet I fain would live a little while,
To see thy face once more alight with joy,
As in the old, old days!

Hil. So shalt thou live


To see my joy at thine own happiness.
Vavir, he will be sorry for a while.
Be kind to him—he will forget me then.
Remember, all my love for him is dead.
Kiss me, my child. Kiss me again. Farewell!

[Hilda pauses, looking at Vavir for a moment, then covers her


face with the veil, and exit.

Vav. Oh, loving heart—sweet, gentle sister-heart—


To bid me blight the outset of thy life
That I may count the time that’s left to me
By days instead of hours! Come back to me—
I have no time to love—the end is near!

Enter Melusine, followed by Florian.

Flor. Obedient to thy summons I am here.


Yet I am very loth to look upon
The misery my heedlessness hath caused.

Vav. (leaning on Melusine, with an effort to appear cheerful).


Sir Florian, my pain is at an end.
The blow was heavy: for I am not strong,
And jests are new to me. Forgive me, sir.
My brain is filled with foolish fantasies
That carry me beyond my reasoning self.
I pray your pardon. Think no more of me,
Save as the subject of a merry tale—
How a mad maiden loved a sun-dial,
And very dearly, too! I have some news
To give you comfort. Hilda has been here.
She is alive and well.
Flor. Then Heaven be thanked!

Vav. But stay—you met her as you came?

Mel. No, no,


We saw no sign of her.

Vav. It’s very strange.


She left me but a minute since, and took
The path by which you came. Go, seek her, sir;
Be very sure she waits you close at hand.
Come, Melusine. Farewell, Sir Florian;
Deal gently with me when you tell the tale!

[Exit Vavir, supported by Melusine. She shows by her change of


expression that the effort to appear cheerful has caused her
great suffering.

Flor. She took that path—and yet I saw her not!


There’s but one clue to this strange mystery:
She has the Talisman! By what strange means
It found its way into her spotless hands
I’ve yet to learn!

Mousta has entered during this speech.

Mous. Let me assist you, sir,


I stole it from your pillow as you slept,
And used it for my ends. I took your place
Beside the fountain, and I woo’d her there.
And there she pledged herself to be my wife—
And, as a token, gave this ring to me! (Showing ring.)

Flor. Why, miserable ape, hast thou then lost


The mere life-seeking instinct that inspires
The very meanest of thy fellow-beasts,
That thou hast come to say these things to me?
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like