100% found this document useful (2 votes)
241 views55 pages

(Ebook) Programming Computer Vision with Python: Tools and algorithms for analyzing images by Jan Erik Solem ISBN 9781449316549, 1449316549 - Read the ebook online or download it as you prefer

The document promotes the ebook 'Programming Computer Vision with Python' by Jan Erik Solem, which covers tools and algorithms for image analysis. It provides links to download this and other related ebooks on computer vision and programming. The book aims to offer a hands-on approach to computer vision, making it accessible for students and enthusiasts with basic programming and mathematical knowledge.

Uploaded by

fortusvieria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
241 views55 pages

(Ebook) Programming Computer Vision with Python: Tools and algorithms for analyzing images by Jan Erik Solem ISBN 9781449316549, 1449316549 - Read the ebook online or download it as you prefer

The document promotes the ebook 'Programming Computer Vision with Python' by Jan Erik Solem, which covers tools and algorithms for image analysis. It provides links to download this and other related ebooks on computer vision and programming. The book aims to offer a hands-on approach to computer vision, making it accessible for students and enthusiasts with basic programming and mathematical knowledge.

Uploaded by

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

Visit ebooknice.

com to download the full version and


explore more ebooks or textbooks

(Ebook) Programming Computer Vision with Python:


Tools and algorithms for analyzing images by Jan
Erik Solem ISBN 9781449316549, 1449316549

_____ Click the link below to download _____


https://ebooknice.com/product/programming-computer-vision-
with-python-tools-and-algorithms-for-analyzing-
images-2623048

Explore and download more ebooks or textbooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Learn OpenCV with Python by Examples: Implement Computer


Vision Algorithms Provided by OpenCV with Python for Image Processing,
Object Detection and Machine Learning by James Chen ISBN
9781738908448, 1738908445
https://ebooknice.com/product/learn-opencv-with-python-by-examples-
implement-computer-vision-algorithms-provided-by-opencv-with-python-
for-image-processing-object-detection-and-machine-learning-50883868

(Ebook) OpenCV 3 Computer Vision with Python Cookbook: Leverage the


power of OpenCV 3 and Python to build computer vision applications by
Alexey Spizhevoy, Aleksandr Rybnikov ISBN 9781788474443, 1788474449

https://ebooknice.com/product/opencv-3-computer-vision-with-python-
cookbook-leverage-the-power-of-opencv-3-and-python-to-build-computer-
vision-applications-10447758

(Ebook) OpenCV Computer Vision with Python by Howse, Joseph ISBN


9781782163923, 1782163921

https://ebooknice.com/product/opencv-computer-vision-with-
python-55662098

(Ebook) OpenCV with Python blueprints: design and develop advanced


computer vision projects using OpenCV with Python by Michael Beyeler
ISBN 9781785282690, 1785282697

https://ebooknice.com/product/opencv-with-python-blueprints-design-
and-develop-advanced-computer-vision-projects-using-opencv-with-
python-20640218
(Ebook) Parallel Programming with Python by Jan Palach ISBN
9781783288397, 1783288396

https://ebooknice.com/product/parallel-programming-with-python-5030408

(Ebook) Hacking Secret Ciphers with Python: A beginner's guide to


cryptography and computer programming with Python by Al Sweigart ISBN
9781482614374, 1482614375

https://ebooknice.com/product/hacking-secret-ciphers-with-python-a-
beginner-s-guide-to-cryptography-and-computer-programming-with-
python-4449906

(Ebook) Learning Opencv 3 Computer Vision with Python by Joe


Minichino, Joseph Howse ISBN 9781785283840, 1785283847

https://ebooknice.com/product/learning-opencv-3-computer-vision-with-
python-7295256

(Ebook) Computer Vision: Algorithms and Applications by Richard


Szeliski ISBN 9783030343712, 3030343715

https://ebooknice.com/product/computer-vision-algorithms-and-
applications-37249542

(Ebook) Numerical Algorithms: Methods for Computer Vision, Machine


Learning, and Graphics by Justin Solomon ISBN 9781482251883,
1482251884

https://ebooknice.com/product/numerical-algorithms-methods-for-
computer-vision-machine-learning-and-graphics-5239520
Programming Computer Vision
with Python

Jan Erik Solem

Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo


Programming Computer Vision with Python
by Jan Erik Solem

Copyright © 2012 Jan Erik Solem. All rights reserved.


Printed in the United States of America

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (http://my.safaribooksonline.com). For more information,
contact our corporate/institutional sales department: (800) 998-9938 or [email protected].
Interior designer: David Futato Project manager: Paul C. Anagnostopoulos
Cover designer: Karen Montgomery Copyeditor: Priscilla Stevens
Editors: Andy Oram, Mike Hendrickson Proofreader: Richard Camp
Production editor: Holly Bauer Illustrator: Laurel Muller

June 2012 First edition

Revision History for the First Edition:

2012-06-11 First release

See http://oreilly.com/catalog/errata.csp?isbn=0636920022923 for release details.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks
of O’Reilly Media, Inc. Programming Computer Vision with Python, the image of a bullhead fish,
and related trade dress are trademarks of O’Reilly Media, Inc.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc.,
was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors
assume no responsibility for errors or omissions, or for damages resulting from the use of the
information contained herein.

ISBN: 978-1-449-31654-9
[M]
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

1. Basic Image Handling and Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


1.1 PIL—The Python Imaging Library 1
1.2 Matplotlib 3
1.3 NumPy 7
1.4 SciPy 16
1.5 Advanced Example: Image De-Noising 23
Exercises 26
Conventions for the Code Examples 27

2. Local Image Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29


2.1 Harris Corner Detector 29
2.2 SIFT—Scale-Invariant Feature Transform 36
2.3 Matching Geotagged Images 44
Exercises 51

3. Image to Image Mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53


3.1 Homographies 53
3.2 Warping Images 57
3.3 Creating Panoramas 70
Exercises 77

4. Camera Models and Augmented Reality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


4.1 The Pin-Hole Camera Model 79
4.2 Camera Calibration 84
4.3 Pose Estimation from Planes and Markers 86
4.4 Augmented Reality 89
Exercises 98

iii
5. Multiple View Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
5.1 Epipolar Geometry 99
5.2 Computing with Cameras and 3D Structure 107
5.3 Multiple View Reconstruction 113
5.4 Stereo Images 120
Exercises 125

6. Clustering Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127


6.1 K-Means Clustering 127
6.2 Hierarchical Clustering 133
6.3 Spectral Clustering 140
Exercises 145

7. Searching Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147


7.1 Content-Based Image Retrieval 147
7.2 Visual Words 148
7.3 Indexing Images 151
7.4 Searching the Database for Images 155
7.5 Ranking Results Using Geometry 160
7.6 Building Demos and Web Applications 162
Exercises 165

8. Classifying Image Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167


8.1 K-Nearest Neighbors 167
8.2 Bayes Classifier 175
8.3 Support Vector Machines 179
8.4 Optical Character Recognition 183
Exercises 189

9. Image Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191


9.1 Graph Cuts 191
9.2 Segmentation Using Clustering 200
9.3 Variational Methods 204
Exercises 206

10. OpenCV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


10.1 The OpenCV Python Interface 209
10.2 OpenCV Basics 210
10.3 Processing Video 213
10.4 Tracking 216
10.5 More Examples 223
Exercises 226

iv | Table of Contents
A. Installing Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
A.1 NumPy and SciPy 227
A.2 Matplotlib 228
A.3 PIL 228
A.4 LibSVM 228
A.5 OpenCV 229
A.6 VLFeat 230
A.7 PyGame 230
A.8 PyOpenGL 230
A.9 Pydot 230
A.10 Python-graph 231
A.11 Simplejson 231
A.12 PySQLite 232
A.13 CherryPy 232

B. Image Datasets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233


B.1 Flickr 233
B.2 Panoramio 234
B.3 Oxford Visual Geometry Group 235
B.4 University of Kentucky Recognition Benchmark Images 235
B.5 Other 235

C. Image Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237


C.1 Images from Flickr 237
C.2 Other Images 238
C.3 Illustrations 238

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

Table of Contents | v
Preface

Today, images and video are everywhere. Online photo-sharing sites and social net-
works have them in the billions. Search engines will produce images of just about any
conceivable query. Practically all phones and computers come with built-in cameras.
It is not uncommon for people to have many gigabytes of photos and videos on their
devices.
Programming a computer and designing algorithms for understanding what is in these
images is the field of computer vision. Computer vision powers applications like image
search, robot navigation, medical image analysis, photo management, and many more.
The idea behind this book is to give an easily accessible entry point to hands-on
computer vision with enough understanding of the underlying theory and algorithms
to be a foundation for students, researchers, and enthusiasts. The Python programming
language, the language choice of this book, comes with many freely available, powerful
modules for handling images, mathematical computing, and data mining.
When writing this book, I have used the following principles as a guideline. The book
should:

.
Be written in an exploratory style and encourage readers to follow the examples on
their computers as they are reading the text.
.
Promote and use free and open software with a low learning threshold. Python was
the obvious choice.
.
Be complete and self-contained. This book does not cover all of computer vision
but rather it should be complete in that all code is presented and explained. The
reader should be able to reproduce the examples and build upon them directly.
.
Be broad rather than detailed, inspiring and motivational rather than theoretical.

In short, it should act as a source of inspiration for those interested in programming


computer vision applications.

vii
Prerequisites and Overview
This book looks at theory and algorithms for a wide range of applications and problems.
Here is a short summary of what to expect.

What You Need to Know


.
Basic programming experience. You need to know how to use an editor and run
scripts, how to structure code as well as basic data types. Familiarity with Python
or other scripting languages like Ruby or Matlab will help.
.
Basic mathematics. To make full use of the examples, it helps if you know about
matrices, vectors, matrix multiplication, and standard mathematical functions and
concepts like derivatives and gradients. Some of the more advanced mathematical
examples can be easily skipped.

What You Will Learn


.
Hands-on programming with images using Python.
.
Computer vision techniques behind a wide variety of real-world applications.
.
Many of the fundamental algorithms and how to implement and apply them
yourself.
The code examples in this book will show you object recognition, content-based
image retrieval, image search, optical character recognition, optical flow, tracking, 3D
reconstruction, stereo imaging, augmented reality, pose estimation, panorama creation,
image segmentation, de-noising, image grouping, and more.

Chapter Overview
Chapter 1, “Basic Image Handling and Processing”
Introduces the basic tools for working with images and the central Python modules
used in the book. This chapter also covers many fundamental examples needed for
the remaining chapters.
Chapter 2, “Local Image Descriptors”
Explains methods for detecting interest points in images and how to use them to
find corresponding points and regions between images.
Chapter 3, “Image to Image Mappings”
Describes basic transformations between images and methods for computing them.
Examples range from image warping to creating panoramas.
Chapter 4, “Camera Models and Augmented Reality”
Introduces how to model cameras, generate image projections from 3D space to
image features, and estimate the camera viewpoint.
Chapter 5, “Multiple View Geometry”
Explains how to work with several images of the same scene, the fundamentals of
multiple-view geometry, and how to compute 3D reconstructions from images.

viii | Preface
Chapter 6, “Clustering Images”
Introduces a number of clustering methods and shows how to use them for group-
ing and organizing images based on similarity or content.
Chapter 7, “Searching Images”
Shows how to build efficient image retrieval techniques that can store image rep-
resentations and search for images based on their visual content.
Chapter 8, “Classifying Image Content”
Describes algorithms for classifying image content and how to use them to recog-
nize objects in images.
Chapter 9, “Image Segmentation”
Introduces different techniques for dividing an image into meaningful regions
using clustering, user interactions, or image models.
Chapter 10, “OpenCV”
Shows how to use the Python interface for the commonly used OpenCV computer
vision library and how to work with video and camera input.
There is also a bibliography at the back of the book. Citations of bibliographic entries
are made by number in square brackets, as in [20].

Introduction to Computer Vision


Computer vision is the automated extraction of information from images. Information
can mean anything from 3D models, camera position, object detection and recognition
to grouping and searching image content. In this book, we take a wide definition of
computer vision and include things like image warping, de-noising, and augmented
reality.1
Sometimes computer vision tries to mimic human vision, sometimes it uses a data and
statistical approach, and sometimes geometry is the key to solving problems. We will
try to cover all of these angles in this book.
Practical computer vision contains a mix of programming, modeling, and mathematics
and is sometimes difficult to grasp. I have deliberately tried to present the material
with a minimum of theory in the spirit of “as simple as possible but no simpler.”
The mathematical parts of the presentation are there to help readers understand the
algorithms. Some chapters are by nature very math-heavy (Chapters 4 and 5, mainly).
Readers can skip the math if they like and still use the example code.

Python and NumPy


Python is the programming language used in the code examples throughout this book.
Python is a clear and concise language with good support for input/output, numer-
ics, images, and plotting. The language has some peculiarities, such as indentation

1 These examples produce new images and are more image processing than actually extracting information from

images.

Preface | ix
and compact syntax, that take getting used to. The code examples assume you have
Python 2.6 or later, as most packages are only available for these versions. The upcom-
ing Python 3.x version has many language differences and is not backward compatible
with Python 2.x or compatible with the ecosystem of packages we need (yet).
Some familiarity with basic Python will make the material more accessible for read-
ers. For beginners to Python, Mark Lutz’ book Learning Python [20] and the online
documentation at http://www.python.org/ are good starting points.
When programming computer vision, we need representations of vectors and matrices
and operations on them. This is handled by Python’s NumPy module, where both vectors
and matrices are represented by the array type. This is also the representation we will
use for images. A good NumPy reference is Travis Oliphant’s free book Guide to NumPy
[24]. The documentation at http://numpy.scipy.org/ is also a good starting point if you
are new to NumPy. For visualizing results, we will use the Matplotlib module, and for
more advanced mathematics, we will use SciPy. These are the central packages you will
need and will be explained and introduced in Chapter 1.
Besides these central packages, there will be many other free Python packages used
for specific purposes like reading JSON or XML, loading and saving data, generating
graphs, graphics programming, web demos, classifiers, and many more. These are
usually only needed for specific applications or demos and can be skipped if you are
not interested in that particular application.
It is worth mentioning IPython, an interactive Python shell that makes debugging
and experimentation easier. Documentation and downloads are available at
http://ipython.org/.

Notation and Conventions


Code looks like this:
# some points
x = [100,100,400,400]
y = [200,500,200,500]

# plot the points


plot(x,y)

The following typographical conventions are used in this book:


Italic
Used for definitions, filenames, and variable names.
Constant width
Used for functions, Python modules, and code examples. It is also used for console
printouts.
Hyperlink
Used for URLs.
Plain text
Used for everything else.

x | Preface
Mathematical formulas are given inline like this f (x) = wT x + b or centered indepen-
dently:

f (x) = wi x i + b
i

and are only numbered when a reference is needed.


In the mathematical sections, we will use lowercase (s , r , λ, θ , . . .) for scalars, upper-
case (A, V , H , . . .) for matrices (including I for the image as an array), and lowercase
bold (t, c, . . .) for vectors. We will use x = [x , y] and X = [X, Y , Z] to mean points in
2D (images) and 3D, respectively.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Programming Computer Vision with Python
by Jan Erik Solem (O’Reilly). Copyright © 2012 Jan Erik Solem, 978-1-449-31654-9.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at [email protected].

How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international or local)
(707) 829-0104 (fax)
We have a web page for this book, where we list errata, examples, links to the code and
data sets used, and any additional information. You can access this page at:
oreil.ly/comp_vision_w_python
To comment or ask technical questions about this book, send email to:
[email protected]

Preface | xi
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

Safari® Books Online


Safari Books Online (www.safaribooksonline.com) is an on-demand digital
library that delivers expert content in both book and video form from the
world’s leading authors in technology and business.
Technology professionals, software developers, web designers, and business and cre-
ative professionals use Safari Books Online as their primary resource for research,
problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organi-
zations, government agencies, and individuals. Subscribers have access to thousands of
books, training videos, and prepublication manuscripts in one fully searchable data-
base from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley
Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John
Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT
Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol-
ogy, and dozens more. For more information about Safari Books Online, please visit us
online.

Acknowledgments
I’d like to express my gratitude to everyone involved in the development and production
of this book. The whole O’Reilly team has been helpful. Special thanks to Andy Oram
(O’Reilly) for editing, and Paul Anagnostopoulos (Windfall Software) for efficient
production work.
Many people commented on the various drafts of this book as I shared them online.
Klas Josephson and Håkan Ardö deserve lots of praise for their thorough comments and
feedback. Fredrik Kahl and Pau Gargallo helped with fact checks. Thank you all readers
for encouraging words and for making the text and code examples better. Receiving
emails from strangers sharing their thoughts on the drafts was a great motivator.
Finally, I’d like to thank my friends and family for support and understanding when I
spent nights and weekends on writing. Most thanks of all to my wife Sara, my long-time
supporter.

xii | Preface
CHAPTER 1
Basic Image Handling
and Processing

This chapter is an introduction to handling and processing images. With extensive


examples, it explains the central Python packages you will need for working with
images. This chapter introduces the basic tools for reading images, converting and
scaling images, computing derivatives, plotting or saving results, and so on. We will
use these throughout the remainder of the book.

1.1 PIL—The Python Imaging Library


The Python Imaging Library (PIL) provides general image handling and lots of useful
basic image operations like resizing, cropping, rotating, color conversion and much
more. PIL is free and available from http://www.pythonware.com/products/pil/.
With PIL, you can read images from most formats and write to the most common ones.
The most important module is the Image module. To read an image, use:
from PIL import Image

pil_im = Image.open('empire.jpg')

The return value, pil_im, is a PIL image object.


Color conversions are done using the convert() method. To read an image and convert
it to grayscale, just add convert('L') like this:
pil_im = Image.open('empire.jpg').convert('L')

Here are some examples taken from the PIL documentation, available at http://www
.pythonware.com/library/pil/handbook/index.htm. Output from the examples is shown
in Figure 1-1.

Convert Images to Another Format


Using the save() method, PIL can save images in most image file formats. Here’s an
example that takes all image files in a list of filenames (filelist) and converts the images
to JPEG files:

1
Figure 1-1. Examples of processing images with PIL.

from PIL import Image


import os

for infile in filelist:


outfile = os.path.splitext(infile)[0] + ".jpg"
if infile != outfile:
try:
Image.open(infile).save(outfile)
except IOError:
print "cannot convert", infile

The PIL function open() creates a PIL image object and the save() method saves the
image to a file with the given filename. The new filename will be the same as the original
with the file ending “.jpg” instead. PIL is smart enough to determine the image format
from the file extension. There is a simple check that the file is not already a JPEG file
and a message is printed to the console if the conversion fails.
Throughout this book we are going to need lists of images to process. Here’s how you
could create a list of filenames of all images in a folder. Create a file called imtools.py to
store some of these generally useful routines and add the following function:
import os

def get_imlist(path):
""" Returns a list of filenames for
all jpg images in a directory. """

return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]

Now, back to PIL.

Create Thumbnails
Using PIL to create thumbnails is very simple. The thumbnail() method takes a tuple
specifying the new size and converts the image to a thumbnail image with size that fits

2 | Chapter 1: Basic Image Handling and Processing


within the tuple. To create a thumbnail with longest side 128 pixels, use the method
like this:
pil_im.thumbnail((128,128))

Copy and Paste Regions


Cropping a region from an image is done using the crop() method:
box = (100,100,400,400)
region = pil_im.crop(box)

The region is defined by a 4-tuple, where coordinates are (left, upper, right, lower). PIL
uses a coordinate system with (0, 0) in the upper left corner. The extracted region can,
for example, be rotated and then put back using the paste() method like this:
region = region.transpose(Image.ROTATE_180)
pil_im.paste(region,box)

Resize and Rotate


To resize an image, call resize() with a tuple giving the new size:
out = pil_im.resize((128,128))

To rotate an image, use counterclockwise angles and rotate() like this:


out = pil_im.rotate(45)

Some examples are shown in Figure 1-1. The leftmost image is the original, followed
by a grayscale version, a rotated crop pasted in, and a thumbnail image.

1.2 Matplotlib
When working with mathematics and plotting graphs or drawing points, lines, and
curves on images, Matplotlib is a good graphics library with much more powerful
features than the plotting available in PIL. Matplotlib produces high-quality figures
like many of the illustrations used in this book. Matplotlib’s PyLab interface is the
set of functions that allows the user to create plots. Matplotlib is open source and
available freely from http://matplotlib.sourceforge.net/, where detailed documentation
and tutorials are available. Here are some examples showing most of the functions we
will need in this book.

Plotting Images, Points, and Lines


Although it is possible to create nice bar plots, pie charts, scatter plots, etc., only a few
commands are needed for most computer vision purposes. Most importantly, we want
to be able to show things like interest points, correspondences, and detected objects
using points and lines. Here is an example of plotting an image with a few points and
a line:

1.2 Matplotlib | 3
from PIL import Image
from pylab import *

# read image to array


im = array(Image.open('empire.jpg'))

# plot the image


imshow(im)

# some points
x = [100,100,400,400]
y = [200,500,200,500]

# plot the points with red star-markers


plot(x,y,'r*')

# line plot connecting the first two points


plot(x[:2],y[:2])

# add title and show the plot


title('Plotting: "empire.jpg"')
show()

This plots the image, then four points with red star markers at the x and y coordinates
given by the x and y lists, and finally draws a line (blue by default) between the two
first points in these lists. Figure 1-2 shows the result. The show() command starts the
figure GUI and raises the figure windows. This GUI loop blocks your scripts and they
are paused until the last figure window is closed. You should call show() only once per
script, usually at the end. Note that PyLab uses a coordinate origin at the top left corner
as is common for images. The axes are useful for debugging, but if you want a prettier
plot, add:

axis('off')

This will give a plot like the one on the right in Figure 1-2 instead.
There are many options for formatting color and styles when plotting. The most useful
are the short commands shown in Tables 1-1, 1-2 and 1-3. Use them like this:

plot(x,y) # default blue solid line

plot(x,y,'r*') # red star-markers

plot(x,y,'go-') # green line with circle-markers

plot(x,y,'ks:') # black dotted line with square-markers

Image Contours and Histograms


Let’s look at two examples of special plots: image contours and image histograms.
Visualizing image iso-contours (or iso-contours of other 2D functions) can be very

4 | Chapter 1: Basic Image Handling and Processing


Figure 1-2. Examples of plotting with Matplotlib. An image with points and a line with and without
showing the axes.

Table 1-1. Basic color formatting commands for plotting with PyLab.
Color
'b' blue
'g' green
'r' red
'c' cyan
'm' magenta
'y' yellow
'k' black
'w' white

Table 1-2. Basic line style formatting commands for plotting with PyLab.
Line style
'-' solid
'- -' dashed
':' dotted

Table 1-3. Basic plot marker formatting commands for plotting with PyLab.
Marker
'.' point
'o' circle
's' square
'*' star
'+' plus
'x' x

1.2 Matplotlib | 5
useful. This needs grayscale images, because the contours need to be taken on a single
value for every coordinate [x , y]. Here’s how to do it:

from PIL import Image


from pylab import *

# read image to array


im = array(Image.open('empire.jpg').convert('L'))

# create a new figure


figure()
# don't use colors
gray()
# show contours with origin upper left corner
contour(im, origin='image')
axis('equal')
axis('off')

As before, the PIL method convert() does conversion to grayscale.


An image histogram is a plot showing the distribution of pixel values. A number of
bins is specified for the span of values and each bin gets a count of how many pixels
have values in the bin’s range. The visualization of the (graylevel) image histogram is
done using the hist() function:

figure()
hist(im.flatten(),128)
show()

The second argument specifies the number of bins to use. Note that the image needs to
be flattened first, because hist() takes a one-dimensional array as input. The method
flatten() converts any array to a one-dimensional array with values taken row-wise.
Figure 1-3 shows the contour and histogram plot.

Figure 1-3. Examples of visualizing image contours and plotting image histograms with Matplotlib.

6 | Chapter 1: Basic Image Handling and Processing


Random documents with unrelated
content Scribd suggests to you:
CHAPTER LVI.

It was with the greatest surprise that Eugene Mallard received the
message that Nora delivered—that Ida was too ill to attend the
grand ball with him.
"She did not seem to be ill this afternoon," he said to himself.
Obeying a sudden impulse, he hurried from the room, intent upon
going to Ida's boudoir and offering her his sympathy; but, on second
thought, he concluded that in all probability she would not care to
be disturbed.
He felt grievously disappointed. He knew that many of his friends
would be present; and besides, what could he say to Mrs. Staples
and her daughters?
Some of her friends had left Ida apparently in the best of health and
spirits at noon. How could he account to them for her sudden
indisposition?
During the forenoon he saw that there was something on Ida's
mind; that she was greatly troubled.
Perhaps the words he had said to her only a short time before had
much to do with her indisposition. He felt that he ought to have a
talk with Ida. If he were to reassure her that she could have
everything her own way, she might feel much relieved.
A second time he started for her boudoir; but again he drew back.
He could not tell what prompted him to do so.
"Such strange, contradictory emotions seem to possess me," he said.
"I will go out into the grounds and smoke a cigar. That will quiet me
a little, and afterward I will have a talk with Ida."
Eugene Mallard wandered about the grounds for half an hour or
more. He heard a clock strike the hour of eight.
How dark and gloomy it was! There was no moon, but the stars
shed a faint, glimmering light.
He had smoked a cigar; but still he paced aimlessly up and down the
grounds, lost in thought.
He came to one of the garden benches. It looked so inviting that he
threw himself down upon it.
How long he sat there he never knew. Presently he was disturbed by
the sound of slow, cautious footsteps. It could not be one of the
servants stealing through the grounds in that manner. It must be
some poacher.
He drew back into the shadow of the trees, and watched with no
little curiosity. He had been so kind to the villagers that he felt
surprised at this apparent ingratitude.
Presently a figure came down the path. The more he watched the
figure the more certain he became that he had seen it before. Its
every move seemed familiar to him.
Suddenly a thought flashed into his mind that made him hold his
breath.
"Great Heavens! can it be Arthur Hollis?" he ejaculated.
His face paled; great flashes of fire seemed to come from his eyes.
The very blood in his veins seemed to stagnate. Faint and dizzy, he
leaned back against the trunk of a tree.
Great God! what could it mean? His wife supposed him to be by this
time on his way to the ball. During his absence would she meet,
dared she meet Arthur Hollis?
The tall, familiar-looking figure paced impatiently by the brook-side
under the dim light of the stars. Yes, the man was there waiting for
some one.
From where he stood he could plainly see a faint light in the window
of his wife's room, and as his eyes were fixed upon it, the light was
extinguished.
If a sword had been plunged into Eugene Mallard's heart, it could
not have given him a greater shock.
Many a night he had paced up and down the grounds, watching the
light in that window. Then it had never been put out before ten.
Why should it be extinguished so early to-night?
The thought troubled Eugene Mallard, as he turned his head and
saw the figure still pacing restlessly up and down by the brook.
He dared not utter a word. He would await developments. He
scarcely breathed, in his suspense. It seemed to him that the blood
in his veins was turned to ice.
He took up a position where there was no possible danger of being
observed, and there he watched and waited.
Up in her boudoir Ida was donning with trembling hands, the long
cloak that was to disguise her.
She had sent Nora from her room. But it seemed to her that the girl
looked back suspiciously as she went out and closed the door after
her.
"Heaven help me to get through with this exciting scene!" Ida
muttered.
Her heart was throbbing so, her limbs were so weak, that she was
obliged to sit down for a minute.
"Oh, Heaven help me! How thankful I am that Eugene did not send
for me before he left for the ball. He has reached there by this
time!" she muttered.
She looked at the clock, and said to herself that time was flying, and
she must hasten to keep her appointment.
Again she counted over the money which Eugene had given her—the
money that was to restore her little child to her—the money that
was to purchase her freedom and end forever Royal Ainsley's
persecutions.
"What would Eugene say if he knew all?" she asked herself, in great
trepidation.
She trembled even at the thought of it.
Was she doing right in concealing the truth from Eugene Mallard?
She sprung from her chair and paced hurriedly up and down the
room.
If Eugene knew all, he would certainly tell her that her path lay with
Royal Ainsley, that his roof would shelter her no more. And now she
could not part from him. Every fiber of her heart was woven about
him.
She tried to look into the future; but, think what she would, the
pictures presented frightened her.
Presently she paused before the window. Was it only her fancy, or
did she hear the patter of rain-drops?
She turned out the light and threw open the window. She felt
relieved to find that it was only the leaves that were tapping against
the window-pane. She closed the window, with a sigh, and opened
the door softly.
The corridor was empty; the gas-jets of the great chandelier were
turned low. Like a thief in the night, she stole noiselessly down the
winding passageway.
The sound of laughter from the servants' hall below floated up to her
through the awful stillness.
What if one of the doors on either side should open, and some one
step out and confront her?
She drew her long cloak closely about her, and pulled the hood down
over her head.
There was a side door opening on to a porch, and leading directly
into the grounds.
Ida hurried toward this door and opened it cautiously. For a moment
she stood on the threshold, and in that moment a gust of wind blew
the cloak from about her shoulders, and it fell at her feet.
The light from the hall lamp clearly revealed her form to Eugene
Mallard, who stood leaning against an oak-tree scarcely one hundred
feet distant.
"It is Ida!" he muttered, hoarsely.
She turned her steps down toward the brook, as he had feared she
would do.
"She stayed away from the ball to meet that scoundrel!" he
muttered under his breath.
With hesitating steps, little dreaming of what the end of her
adventure would be, Ida hurried on to her doom.
The wind sighed a mournful requiem in the trees, the songs of the
birds were hushed, and the sweet murmur of the brook seemed to
end in a sob as it rushed onward to the sea.
The night was warm, but a great shiver crept over Ida as she turned
out of the path and hurried along through the garden by a short cut
to the place where she knew Royal Ainsley was impatiently waiting
for her.
CHAPTER LVII.

Royal Ainsley was not a man to be trusted when under the influence
of drink. As the minutes went by, and Ida did not come, he was
beside himself with rage.
"What does she mean by keeping me waiting in this manner?" he
roared. "By the Lord Harry, I'll make her pay for this!"
Then, like Eugene Mallard, who was watching but a few feet from
him, he saw the light go out in Ida's room.
"That must be her room. She is coming at last," he murmured.
He braced himself against the trunk of a tree, for by this time his
limbs were none too steady under him.
When the door opened, and he saw Ida approach, an exclamation of
satisfaction broke from his lips.
He sat down upon the mossy rock and watched the slim figure as it
moved slowly over the greensward.
"She is certainly in no hurry to see me," he muttered, with a grim
smile. "But I'll change all that."
Meanwhile, Ida had stopped short, and was standing motionless in
the path.
Putting her hand into the pocket of her dress, the girl found, to her
great amazement, that she had come away without the roll of bills
she had intended to bring with her. In her excitement she had left
the money on the table.
What should she do? There was no course to pursue but go back for
it.
Then a superstitious terror for which she could not account seemed
to seize her.
"It will surely be a bad omen to return to the house." she told
herself; "and yet I dare not meet Royal Ainsley without the money.
He will say that my story about forgetting the money is only an
excuse."
CHAPTER LVIII.

As Ida paused for a moment, wondering what course would be best


to pursue, she concluded that her only course would be to return to
the house for the money.
She had scarcely turned, before a piercing cry sounded through the
grounds, coming from the direction of the brook.
Ida, terrified, stood for a moment rooted to the spot. She tried to fly,
but if her life had depended upon it, she could not have stirred hand
or foot.
She distinctly heard the sound of voices. Still, all power to fly
seemed to have left her.
What could it be? Had some of the servants discovered Royal
Ainsley's presence?
She tried to think, but she was powerless. Every sound seemed
confusing.
Guided by the light, Nora had dashed quickly down toward the
brook. But ere she could reach the figure pacing up and down so
impatiently, she was seized from behind by a pair of strong arms, a
white angry face bent over her, and a voice, which she instantly
recognized as her master's, cried harshly:
"Let me understand what this means!"
The girl was too frightened to speak.
"This is why you would not come to the ball, is it?" he cried,
excitedly, dragging her toward the spot where her lover stood.
"Come, you and I will confront the lover whom you stayed away
from the ball to meet here!"
Royal Ainsley took in the situation at once. He recognized Eugene's
voice.
"He has discovered Ida Mallard's appointment with me in some way,"
he thought. And the knowledge terrified him, coward as he was.
He turned and beat a hasty retreat, dodging directly into the arms of
old Joe.
"Ha! I've caught you this time!" cried the old servitor.
With an oath, Royal Ainsley flung Joe from him.
"Out of my way!" he cried, fiercely, "or I'll kill you!"
The voice, as well as the words, startled old Joe, and threw him
entirely off his guard for an instant. In that instant a heavy blow was
dealt him which caused him to loosen his hold on the intruder.
Then Royal Ainsley sped like a deer through the grounds, every foot
of which he knew well, and was quickly lost to sight in the darkness.
After that first sharp cry, Nora regained something of her natural
bravado.
In less time than it takes to tell it, her master had dragged her
toward the house and under the full light of the swinging lamp.
"Oh, master!" she cried, gaining her breath at last "It's I, Nora, the
maid!"
Eugene Mallard's tightly clinched hands fell from her; he stared
aghast at the girl.
"You, Nora!" he cried, in the greatest amazement, with a world of
relief and thankfulness blended in his voice.
"Pray for—forgive me, Mr. Mallard," sobbed the girl. "I—I did not do
any intentional wrong. I was only going down to the old south gate
to meet my lover, sir. I—I did not think for a moment that any one
would mind. My lady did not need me for an hour or more. Oh,
please forgive me if my action has displeased you!"
"It was your lover that you were going to meet?" repeated Eugene
Mallard, as if to satisfy himself that he had heard aright.
He drew back and looked at Nora with fixed intentness, the color
that had left his face surging back to it again.
Eugene Mallard now walked to his library, and flung himself down to
think over the situation.
He felt grateful beyond words that matters were no worse. He was
ashamed of the thought that for a moment had found lodgment in
his brain against the wife whom he had wedded.
Then it came to him—his love for Ida, whom he knew now that he
worshipped with all the passionate love of his heart. How different it
was from the love he had borne Hildegarde Cramer!
He wondered that he had been so blind as not to have noticed his
love for her sooner. He could scarcely wait until the day dawned,
that he might go to her and tell her of the great love for her that
was consuming his soul.
He said to himself that it was only her innate modesty that caused
her to hold aloof from him of late, and to make her hesitate about
giving him her answer.
He looked shudderingly backward over the past for the last time.
Yes, he would urge her to give him his answer on the morrow. It
never once occurred to him but that her answer would be "Yes."
CHAPTER LIX.

When Royal Ainsley shook himself free from old Joe's detaining
grasp, his first impulse was to get as far away from the place as
possible.
With second thoughts, however, came another decision. No; he must
learn all that was taking place.
Quickly circling the grounds, he soon gained a vantage-place behind
a group of bushes not far from the house. There he could easily see
and hear all that transpired without being seen himself.
He saw Eugene Mallard as he drew the girl beneath the swinging
lamp in the hall, and heard the conversation that passed between
them.
"So!" he muttered, grinding his white teeth savagely, "the girl is my
lady's maid, eh? I dare say, she sent her with some message to me
when she was intercepted by Eugene Mallard. But Ida will find that
this will not work with me. See her I shall, if I have to stay in these
grounds till broad daylight."
He watched and waited until he saw even old Joe relax his vigilance
and go into the house.
Royal Ainsley waited there until the old mansion was wrapped in
gloom and darkness, then he slipped from his hiding-place, passed
noiselessly over the graveled walk, and stood beneath Ida's window.
Stooping, he caught up a handful of pebbles. One by one he flung
them up against the window-pane. Just as he had expected, he saw
a white, terrified face appear at the window, and two white hands
threw up the sash.
He saw at once that it was Ida. He moved out from the shadow of
the trees. She saw him at once, and recognized him.
"Is it you?" she cried, in the greatest alarm. "What in Heaven's name
are you doing there, pray?"
"Your common sense ought to tell you that;" he retorted, harshly.
"Come down here at once, I tell you, and be sure to bring that
money with you!"
"Oh, no! no! I can not!" she answered him, piteously.
"Why?" he demanded, with something very much like an imprecation
upon his lips.
"I dropped the money in the dining-room as I was passing through it
to get out into the grounds. The room is locked; I can not get it until
to-morrow morning. Old Joe always carries the key with him."
"It is a lie!" he cried, fiercely.
"No! no! On my life, it is true!" she answered, with a piteous quiver
in her voice; adding: "I was hurrying through the room, and there I
must have dropped it. I searched for it in every other place."
"Then hear what I say," he retorted, with an oath, "in these very
grounds I shall stay until you come to me. I know well that old Joe is
astir at dawn. You must be up then, find the money which you say
you dropped, and bring it out to me. I will be waiting for you at the
same place."
Before she could utter a word of protest, he had turned and
disappeared in the darkness.
All night long Ida Mallard paced the floor of her room, scarcely
heeding the hours that dragged their slow lengths by. Dawn came
before she realized it. She was startled from her reverie by hearing
old Joe throwing open the shutters about the house. That recalled
her to a realization of passing events.
Joe had unlocked the door of the dining-room at last, but his sight
was so poor that he could not espy a small roll of bills lying on the
floor.
Ida, gliding into the room as soon as his footsteps echoed down the
corridor, found the package.
She stole to the door as soon as it was unlocked.
Ah! how sweet and fragrant was the early morning. How cool and
green the grass looked, wet with the morning dew! Little she
dreamed that ere the day waned that same grass would be dyed
with a human being's blood.
She shivered as she stepped forth into the grounds. With hurried
steps she crossed the lawn, and went into the rose-garden beyond.
There she saw Royal Ainsley. He was pacing the little path by the
brook, his face white, his eyes angry-looking, downcast and sullen.
"So you have come at last, eh?" he exclaimed, angrily.
"I am here," she responded, tremulously.
"I was just about to go and wake up the household," he cried, his
rage increasing.
"Now, that I am here, you will not have to do that," she answered,
wearily.
"Where is the money?" he asked, abruptly.
She held it in her hand, but clutched it more tightly.
"I have it with me," she responded; "but it is not yours until you
carry out your promises!"
He looked at her with a cunning gleam in his eyes.
"To be sure I will carry out my agreement," he said.
"But I must have proof that you will do so before I part with so
much money," she said. "You must give me your written word that
you will never trouble me again. You must also tell me where I can
find my child, for I see that you have not kept your word about
bringing her with you!"
He laughed aloud—a harsh, mocking laugh.
"I am not surprised at hearing a remark like that from your lips. A
woman who could abandon her child as easily as you did, without so
much as knowing its fate, and who is content to live here as Eugene
Mallard's wife, whenever he is ready to take you to his heart, is
capable of doing anything. I do not wonder that you supposed the
little one was here in the grounds all night long awaiting your fancy
to appear!"
She recoiled at the words as though he had struck her a blow.
"Let me tell you where your child is," he said, hoarsely. "You shall
know its fate!"
As he spoke, he seized the hand that held the money, and tore the
bills from her grasp.
CHAPTER LX.

Ida sunk on her knees before him.


"Come," he said; "you must go quietly with me."
"Inhuman monster!" moaned Ida.
"Come. This is no time to exchange compliments," he said. "We have
parleyed here too long already."
His grasp tightened on the slender wrist, but she did not seem to
heed the pain of it.
"I can not, I will not go with you!" she panted.
A taunting laugh answered her. He was dragging her by main force
down the path, when the figure of a man suddenly sprung before
him.
"You!" cried Royal Ainsley, furiously.
"Yes, it is I!" returned Eugene Mallard, sternly. "I am just in time, it
appears, to save my—this lady from you."
At the sight of Eugene, Ida flung up her hands with a wild cry, and
sunk at his feet unconscious. Royal Ainsley sprung forward to catch
her in his arms, but Eugene dashed up to him.
"Lay one hand on her at your peril!" he commanded.
"And who shall prevent me, when she is my wife?" sneered Royal
Ainsley.
"She is not your wife!" cried Eugene Mallard, his face darkening;
"and here and now, I propose to avenge the wrongs you have done
her. There will be a duel to the death between us! I have two pistols
in my pocket, you shall take one and defend yourself, I will use the
other."
Royal Ainsley sprung forward. Quick as a flash he drew something
from his vest-pocket. It was a sharp steel dagger which he always
carried.
He made a lunge forward, but his foot slipped, and he fell to the
earth in mortal pain. The dagger he had intended to plunge into the
body of his cousin had been the cause of his own death.
In an instant Eugene was bending over him.
"It is too late!" gasped the miserable man—"it is all over with me
now. I am about to pass in my checks. Don't you think so?"
"Yes," said Eugene; "you are mortally wounded, I can see that.
Heaven forgive you for the sins you have committed!"
Eugene carried Ida to her own room, thanking Heaven that he had
met no one. No one would know of her presence in the grounds.
Then he quickly summoned the servants.
Royal Ainsley, lying there with his face upturned to the sunlight and
his hand clutching the fatal dagger, told its own story.
As soon as Ida was able to see him Eugene sent for her to come to
the library.
When she received the summons, the poor soul, white as death, fell
upon her knees.
"He is going to denounce me for my sin, and for not telling him
when I found it out," she said.
Could she face him, now that he knew all?
As she knelt there she caught a glimpse of herself in the great mirror
opposite.
Again the girl knocked at the door.
"Tell your master that I will see him to-morrow," she whispered in a
strained, strange voice; and the girl went away.
Strange fancies seemed to throng through her brain.
Royal Ainsley was dead, she had heard them say; and she fancied
that her child was dead, too.
And now the man she loved had sent for her to turn her from the
house, and she would never see him again.
Then she thought of the brook, so deep, so wide, that struggled on
to meet the sea.
Yes, she would go there where some of the happiest, ay, and some
of the most sorrowful moments of her life had been spent. The deep
waters would carry her away on their bosom.
At intervals the girl came to the door to inquire if she wanted
anything. The answer was always the same—"No."
She never knew how the long hours passed; she was like one in a
dream.
At last night came. She waited until the house was dark and still.
There was silence in the hall. All the lights were out, every one was
asleep, and the troubles of the day were blotted out.
She raised the long French window that opened out onto the lawn
and stepped out into the garden.
As she passed the room in which Eugene Mallard was quietly
sleeping, she knelt and laid her cold white lips on the threshold his
feet would press.
How cruelly Heaven had punished her, because in those other days
she had longed to be a lady, like the heroines she had read of in the
great world of beauty and fashion.
She reached the brook and knelt down beside it. The moon threw a
silvery light upon it, and in its song she seemed to hear Eugene's
voice mingled with that of the little child she had lost.
"I am coming to you, little baby!" she muttered below her breath.
Then aloud, she said: "Good-bye, Eugene—good-bye forever!"
Suddenly a pair of strong arms clasped her, and Eugene's voice
whispered:
"Not good-bye, my darling!"
Only the stars and the moonlight and the rippling waters of the
brook heard what he said—how he pleaded with her to live only for
him and her little child.
Ida could not believe the great happiness that had suddenly fallen
upon her like a mantle from God's hands.
They talked by the brook-side for long hours. The next day the
master and mistress of the great mansion went away.
When they reached New York, another ceremony was performed,
which made Ida Eugene Mallard's wife until death should part them.
Then they quietly went and obtained the little child, whom both
idolized, and went abroad, where they remained for years.
No one learned the strange romance of the fair young girl whom
Eugene Mallard worshipped so fondly.
When they returned to their home, years after, with a lovely, dark-
eyed little girl and a sturdy, blue-eyed boy, no one guessed but that
they were Eugene Mallard's children.
While they had been abroad they read of the marriage of Hildegarde
Cramer to Philip Ravenswood, the noble young man who had loved
her ever since they had first met on the Newport sands.
The same paper also brought the intelligence of the engagement of
Arthur Hollis and pretty Dora Staples, and the sad ending, in a
railroad accident, of beautiful, hapless Vivian Deane and her maid
Nora.
Eugene passed the paper to his wife, and Ida read it, making no
comments. But after awhile, as though the subject weighed heavily
on her mind, she went up to Eugene, and laid her soft white arms
round his neck, and whispered:
"Does the knowledge of Hildegarde's marriage bring you any regrets,
Eugene?"
"No, my darling!" he cried, clasping her in his strong arms. "For all
the love of my heart is yours now, and—and—our children's."
"I have often wanted to ask you, Eugene," she murmured, with her
face hidden on his breast, "if the story of my past were known, how
would people judge me? Would the world say, 'Ida May had
sinned'?"
Let us hope all our readers will join heartily in his answer—"No."

THE END.
THE A. and L. SERIES
POPULAR CLOTH
BOUND BOOKS

Issued ONLY by
THE ARTHUR WESTBROOK COMPANY

The Arthur Westbrook Company, in furtherance of its policy


to give the reading public the best stories at the lowest
price, now offers books by the foremost writers not only of
to-day but of the last decade.

These books are bound in cloth.

The covers are attractive.

Each book costs only TWENTY-FIVE CENTS.

Among the writers whose works are offered at this


POPULAR PRICE are such men and women as Rider
Haggard, Guy Boothby, Charles Garvice, Marie Corelli,
Augusta Evans, Laura Jean Libbey, and many others whose
names are only a little less dear to the hearts of the reading
public who like to read real books, written about real
people, who have real experiences.
The A. and L. Series Popular Cloth Bound Books is on sale
at all newsdealers and booksellers, but it is only published
by

THE ARTHUR WESTBROOK COMPANY,


Cleveland, Ohio, U.S.A.

If you wish to read entertaining, fascinating books, look


for the name, A. and L. SERIES.

These popular cloth bound books are issued only by The


ARTHUR WESTBROOK COMPANY.

The A. and L. SERIES will contain, among others, the


following stories by

GUY BOOTHBY

The Kidnapped President


A Prince of Swindlers
The Mystery of the Clasped Hands

H. RIDER HAGGARD

Cleopatra
King Solomon's Mines
She
The Witches' Head
The World's Desire
LOUIS TRACY

The Jewel of Death


A Japanese Revenge

FRED M. WHITE

Mystery of the Crimson Blind

J. PHILLIPS OPPENHEIM

Mysterious Mr. Sabin

MAX PEMBERTON

The Shadow on the Sea

F. DU BOISGOBEY

The Severed Hand

LAURA JEAN LIBBEY

Kidnapped at the Altar


Gladiola's Two Lovers
A Bride for a Day
Aleta's Terrible Secret
The Romance of Enola
A Handsome Engineer's Flirtation
Was She Sweetheart or Wife
Della's Handsome Lover
Flora Garland's Courtship
My Sweetheart Idabell
Pretty Madcap Dorothy
The Loan of a Lover
A Fatal Elopement
The Girl He Forsook
Which Loved Her Best
A Dangerous Flirtation
Garnetta, the Silver King's Daughter
Flora Temple
Pretty Rose Hall
Cora, the Pet of the Regiment
Jolly Sally Pendleton

MARIE CORELLI

Vendetta
A Romance of Two Worlds

CHARLES GARVICE

She Loved Him


The Marquis
A Wasted Love
Her Ransom

AUGUSTA EVANS

St. Elmo
Inez

MRS. SOUTHWORTH
Ishmael
Self-Raised
The Missing Bride
India

CHARLOTTE M. BRAEME

Thorns and Orange Blossoms


A Dark Marriage Morn
Dora Thorne

TRANSCRIBER'S NOTE:
Obvious printer errors have been corrected. Otherwise, the author's original spelling,
punctuation and hyphenation have been left intact.
The cover image was restored by the transcriber and is placed in the public domain.
*** END OF THE PROJECT GUTENBERG EBOOK A DANGEROUS
FLIRTATION; OR, DID IDA MAY SIN? ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright
law in the United States and you are located in the United
States, we do not claim a right to prevent you from copying,
distributing, performing, displaying or creating derivative works
based on the work as long as all references to Project
Gutenberg are removed. Of course, we hope that you will
support the Project Gutenberg™ mission of promoting free
access to electronic works by freely sharing Project Gutenberg™
works in compliance with the terms of this agreement for
keeping the Project Gutenberg™ name associated with the
work. You can easily comply with the terms of this agreement
by keeping this work in the same format with its attached full
Project Gutenberg™ License when you share it without charge
with others.

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

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


Gutenberg:

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


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project
Gutenberg™ work (any work on which the phrase “Project
Gutenberg” appears, or with which the phrase “Project
Gutenberg” is associated) is accessed, displayed, performed,
viewed, copied or distributed:

This eBook is for the use of anyone anywhere in the


United States and most other parts of the world at no
cost and with almost no restrictions whatsoever. You
may copy it, give it away or re-use it under the terms
of the Project Gutenberg License included with this
eBook or online at www.gutenberg.org. If you are not
located in the United States, you will have to check the
laws of the country where you are located before using
this eBook.

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


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

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


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

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


Gutenberg™ License terms from this work, or any files
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!

ebooknice.com

You might also like