(Ebook) Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python by Shamshad Ansari ISBN 9781484258866, 148425886X - The ebook in PDF/DOCX format is available for instant download
(Ebook) Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python by Shamshad Ansari ISBN 9781484258866, 148425886X - The ebook in PDF/DOCX format is available for instant download
com
https://ebooknice.com/product/building-computer-vision-
applications-using-artificial-neural-networks-with-step-by-
step-examples-in-opencv-and-tensorflow-with-python-50195836
OR CLICK BUTTON
DOWLOAD EBOOK
(Ebook) Building Computer Vision Applications Using Artificial Neural Networks, 2nd
Edition by Shamshad Ansari ISBN 9781484298657, 1484298659
https://ebooknice.com/product/building-computer-vision-applications-using-
artificial-neural-networks-2nd-edition-53726238
ebooknice.com
(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
ebooknice.com
(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
ebooknice.com
(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
ebooknice.com
(Ebook) OpenCV Computer Vision with Python by Howse, Joseph ISBN 9781782163923,
1782163921
https://ebooknice.com/product/opencv-computer-vision-with-python-55662098
ebooknice.com
(Ebook) Artificial Neural Networks with Java - Tools for Building Neural Network
Applications by Igor Livshin ISBN 9781484244203, 1484244206
https://ebooknice.com/product/artificial-neural-networks-with-java-tools-for-
building-neural-network-applications-9951116
ebooknice.com
(Ebook) Ultimate Neural Network Programming with Python: Create Powerful Modern AI
Systems by Harnessing Neural Networks with Python, Keras, and TensorFlow by Rajput,
Vishal; ISBN 9789391246549, 9391246540
https://ebooknice.com/product/ultimate-neural-network-programming-with-python-
create-powerful-modern-ai-systems-by-harnessing-neural-networks-with-python-
keras-and-tensorflow-53620894
ebooknice.com
(Ebook) Computer Vision Using Deep Learning: Neural Network Architectures with
Python and Keras by Vaibhav Verdhan ISBN 9781484266151, 1484266153
https://ebooknice.com/product/computer-vision-using-deep-learning-neural-
network-architectures-with-python-and-keras-24606292
ebooknice.com
(Ebook) Artificial Neural Networks with Java: Tools for Building Neural Network
Applications, 2nd Edition by Igor Livshin ISBN 9781484273678, 1484273672
https://ebooknice.com/product/artificial-neural-networks-with-java-tools-for-
building-neural-network-applications-2nd-edition-35149846
ebooknice.com
Building Computer
Vision Applications
Using Artificial Neural
Networks
With Step-by-Step Examples in
OpenCV and TensorFlow with Python
—
Shamshad Ansari
www.allitebooks.com
Building Computer Vision
Applications Using
Artificial Neural Networks
With Step-by-Step Examples
in OpenCV and TensorFlow
with Python
Shamshad Ansari
www.allitebooks.com
Building Computer Vision Applications Using Artificial Neural Networks: With
Step-by-Step Examples in OpenCV and TensorFlow with Python
Shamshad Ansari
Centreville, VA, USA
www.allitebooks.com
In God we trust.
To my wonderful parents, Abdul Samad and
Nazhat Parween, who always corrected my mistakes and
raised me to become a good person.
To my lovely wife, Shazia, and our two beautiful daughters,
Dua and Erum. Without their love and support, this book
would not have been possible.
www.allitebooks.com
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv
Introduction������������������������������������������������������������������������������������������������������������xxi
www.allitebooks.com
Table of Contents
vi
Table of Contents
Median Blurring��������������������������������������������������������������������������������������������������������������������� 69
Bilateral Blurring������������������������������������������������������������������������������������������������������������������� 71
Binarization with Thresholding��������������������������������������������������������������������������������������������������� 74
Simple Thresholding�������������������������������������������������������������������������������������������������������������� 74
Adaptive Thresholding����������������������������������������������������������������������������������������������������������� 77
Otsu’s Binarization����������������������������������������������������������������������������������������������������������������� 79
Gradients and Edge Detection����������������������������������������������������������������������������������������������������� 82
Sobel Derivatives (cv2.Sobel() Function)������������������������������������������������������������������������������� 82
Laplacian Derivatives (cv2.Laplacian() Function)������������������������������������������������������������������ 87
Canny Edge Detection����������������������������������������������������������������������������������������������������������� 89
Contours�������������������������������������������������������������������������������������������������������������������������������������� 90
Drawing Contours������������������������������������������������������������������������������������������������������������������ 93
Summary������������������������������������������������������������������������������������������������������������������������������������ 94
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
x
Table of Contents
xi
Table of Contents
xii
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 443
xiii
About the Author
Shamshad (Sam) Ansari is president and CEO of Accure
Inc., an artificial intelligence automation company that he
founded. He has raised Accure from startup to a sustainable
business by building a winning team and acquiring customers
from across the globe. He has technical expertise in the areas
of computer vision, machine learning, AI, cognitive science,
NLP, and big data. He architected, designed, and developed
the Momentum platform that automates AI solution
development. He is an inventor and has four US patents in the
areas of AI and cognitive computing.
Shamshad previously worked as a senior software engineer with IBM, as VP of
engineering with Orbit Solutions, and as principal architect and director of engineering
with Apixio.
xv
About the Technical Reviewer
James Baldo is an associate professor at George Mason
University in the Volgenau School of Engineering and the
director of the Data Analytics Engineering (DAEN) Program.
His 38 years as a practicing engineer has provided him
with a broad foundation of knowledge and experience
in data analytics and engineering systems. His data
analytics interests span the areas of data engineering, data
science, and data architecture with a focus on data-centric
applications. His software engineering expertise has been
in support of deploying applications to cloud-based environments and microservice
architectures. As director of the DAEN Program, he has been responsible for developing
and coordinating its new online program offering. He holds a BS in chemistry, MS in
chemistry, MS in computer engineering, and PhD in information technology/software
engineering. He enjoys canoeing, hiking, and golf, and he lives in Manassas, Virginia,
with his wife.
xvii
Acknowledgments
I decided to write this book because I wanted to achieve two objectives: build the
computer vision concepts from the ground up to an advanced level, and provide a guide
to apply the concepts in building real-world vision systems. I will demonstrate every
single concept with use cases and code examples. I have organized the topics, connected
the contents to meaningful and practical use cases, and made sure the code was working
and fully tested. It all required my undivided attention, and I could not have done it
without the support of my family. I can’t thank my wife enough for taking care of our two
daughters and keeping them occupied while I was busy writing this book. She turned
this into a positive experience for them and for me: The kids started keeping track of my
progress and celebrated every time I finished a section, subsection, or chapter. In turn,
this gave me tremendous energy and motivation that I thoroughly enjoyed while working
on this book. I just don’t know what magic my wife used to do this.
My life is indebted to Anumati Bhagi and Ashok Bhagi, who are no less than parents
to me; their love and support always motivate me.
This book is a collection of my lifetime experiences that I gained by working with
some of the greatest engineers, data scientists, and business professionals. I would
like to thank all my colleagues at Accure and all the past companies I have worked at. I
sincerely thank all my teachers, professors, and mentors who enlightened me with their
knowledge and wisdom.
It has been a great experience working with the Apress editorial team. Aditee
Marashi, the coordinating editor, has been prompt with her responses to any question
I have had. She has also been instrumental in keeping track of the schedule. Hats off to
her. It’s been awesome working with Mathew Moodie, the development editor. Thank
you, Aditee and Matt.
My special thanks go to John Celestine, the senior editor. He is a thorough,
thoughtful, and fast decision-maker. Thank you, John, for believing in me. Thanks to
Apress for publishing this book.
xix
Acknowledgments
Professor James Baldo was the most valuable contributor to the book. As a technical
reviewer, he executed every single line of code and made sure that they all worked. He
reviewed every single word of the book, cross-checked references, and provided some
key suggestions that made this book much more valuable than I ever imagined. Thank
you, Professor Baldo.
Finally, I would like to thank the readers of this book. I would love to hear from you
all. Please send your comments, suggestions, and questions to [email protected]. As
the technology evolves, some of the code examples of this book may require updating. I
will try my best to keep all the code up-to-date at the book’s GitHub site. I look forward
to hearing from you.
xx
Introduction
For more than 20 years I have had the pleasure of working with some of the greatest
data scientists and computer vision experts. Along the way I have learned a lot,
especially the best practices of building large-scale computer vision systems. In this
book I present the learnings from my own personal experience and the experience of
people I have had opportunities to work with. I also present the work of some of the
greatest contributors and thought leaders of computer vision, even though I have not
had a chance to work with them. I have provided references to their work at appropriate
places throughout the book.
When I hire new engineers and scientists, one of my biggest challenges has been
to provide them with systematic training so that they can start contributing to the
development of vision systems in the shortest possible time. There are a large number of
online resources and books available on various topics related to computer vision, and it
is easy to get lost in the piles of information they present, given that the field of computer
vision is vast and complex. In this book, I attempted to provide a structured and
systematic approach of building the key concepts and working through example code to
develop real-world computer vision systems. I hope this helps you connect the dots as
you read through the chapters. My goal is to keep this book as practical and hands-on as
possible.
This book starts with the introduction of core concepts of computer vision and
provides code examples to aid in the learning of those concepts. The code examples in
the early part of the book are mainly based on OpenCV with Python.
This book also covers the basic concepts of machine learning and gradually develops
the advanced-level concepts of artificial neural networks or deep learning. Every single
concept is followed by working code examples of real-world use cases. All machine
learning–related code examples are written in TensorFlow with Python.
In this book, there are eight real-world use cases of computer vision with working
code. These use cases are from various industries, such as healthcare, security,
surveillance, and manufacturing. I have provided line-by-line explanations to help you
xxi
Introduction
understand the code. There are three chapters dedicated to practical use cases. These
chapters demonstrate how to build the vision systems from the ground up, starting from
image/video acquisition to building a data pipeline, model training, and deployment.
Training state-of-the-art computer vision models requires a lot of hardware
resources. It is desirable and economically beneficial to train computer vision models on
a cloud infrastructure to leverage the latest hardware resources, such as GPUs, and pay-
as-you-go cost models. The last chapter, Chapter 10, provides step-by-step instructions
for building machine learning–based computer vision applications on the three popular
cloud infrastructures: Google Cloud Platform, Amazon AWS, and Microsoft Azure.
Though the book develops the concepts from one pixel all the way to model training
on the cloud, it has certain prerequisites. You should have a working knowledge of the
Python programming language. This book is intended to help working professionals,
programmers, data scientists, and undergraduate and graduate students gain practical
knowledge of building computer vision applications using artificial neural networks.
xxii
CHAPTER 1
Prerequisites and
Software Installation
This is a hands-on book that describes how to develop computer vision applications
in the Python programming language. In this book, you will learn how to work with
OpenCV to manipulate images and build machine learning models using TensorFlow.
OpenCV, originally developed by Intel and written in C++, is an open source
computer vision and machine learning library consisting of more than 2,500 optimized
algorithms for working with images and videos. TensorFlow is an open source
framework for high-performance numerical computation and large-scale machine
learning. It is written in C++ and provides native support for GPUs. Python is the most
widely used programming language for developing machine learning applications. It is
designed to work with C++. Both TensorFlow and OpenCV provide Python interfaces
to access their low-level functionality. Although TensorFlow and OpenCV provide
interfaces in other programming languages, such as Java, C++, and MATLAB, we will
use Python as the primary language because of its simplicity and its large community of
support.
The prerequisites for this book are practical knowledge of Python and familiarity
with NumPy and Pandas. The book assumes that you are familiar with built-in data
containers in Python, such as dictionaries, lists, sets, and tuples. Here are some
resources that may be helpful to meet the prerequisites:
• Python: https://www.w3schools.com/python/
• Pandas: https://pandas.pydata.org/docs/getting_started/
index.html
• NumPy: https://numpy.org/devdocs/user/quickstart.html
1
© Shamshad Ansari 2020
S. Ansari, Building Computer Vision Applications Using Artificial Neural Networks,
https://doi.org/10.1007/978-1-4842-5887-3_1
Chapter 1 Prerequisites and Software Installation
Before we go any further, let’s prepare our working environment and set ourselves up
for the exercises we will be doing as we move along. Here we will start by downloading
and installing the required software libraries and packages.
$ python3 --version
The output of this command should be something like this: Python 3.6.5.
To check the version number of PIP, execute the following command on your
terminal:
$ pip3 --version
This command should show a version number of PIP 3, for example, PIP 19.1.
brew update
brew install python
Make sure long paths are enabled on Windows. Here are the instructions to do that:
https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-
policy-option-missing.
Install the 64-bit Python 3 release for Windows from https://www.python.org/
downloads/windows/ (select PIP as an optional feature).
If these installation instructions do not work in your situation, refer to the official
Python documentation at https://www.python.org/.
v irtualenv
virtualenv is a tool to create isolated Python environments. virtualenv creates a directory
containing all the necessary executables to use the packages that a Python project will
need. virtualenv provides the following advantages:
• virtualenv allows you to have two versions of the same library so that
both your programs continue to run. Say you have a program that
requires version 1 of a Python library and another program needs
version 2 of the same library; virtualenv will allow you to run both.
3
Chapter 1 Prerequisites and Software Installation
Next, we will install virtualenv and configure the environment with all the required
software. For the remainder of the book, we will assume that our reference program
dependencies will be contained in this virtualenv.
Install virtualenv using the following PIP command (the command is the same
on all OSs):
$ mkdir cv
Then create the virtualenv in this directory, cv
$ virtualenv --system-site-packages -p python3 ./cv
The following is a sample output from running this command (on my MacBook):
When virtualenv is active, your shell prompt is prefixed with (cv). Here’s an
example:
Install packages within a virtual environment without affecting the host system
setup. Start by upgrading PIP (make sure you do not run any command as root or sudo
while in virtualenv).
When you are done and you want to exit from virtualenv, do the following:
T ensorFlow
TensorFlow is an open source library for numerical computation and large-scale
machine learning. You will learn more about TensorFlow in subsequent chapters. Let’s
first install it and get it ready for our deep learning exercises.
I nstalling TensorFlow
We will install the latest version of TensorFlow from PyPI (https://pypi.org/project/
tensorflow/). We will install TensorFlow for CPUs. Make sure you are in virtualenv and
run the following command:
If TensorFlow is successfully installed, the output should not show any errors.
P
yCharm IDE
You can use your favorite IDE for writing and managing Python code, but for the purpose
of this book, we will use the community version of PyCharm, a Python IDE.
5
Chapter 1 Prerequisites and Software Installation
Installing PyCharm
Go to the official website of PyCharm at https://www.jetbrains.com/pycharm/
download/#section=linux, select the appropriate operating system, and click Download
(under Community Version). After the download is completed, click the downloaded
package, and follow the on-screen instructions. Here are the direct links for different
operating systems:
• Linux: https://www.jetbrains.com/pycharm/download/download-
thanks.html?platform=linux&code=PCC
• Mac: https://www.jetbrains.com/pycharm/download/download-
thanks.html?platform=mac&code=PCC
• Windows: https://www.jetbrains.com/pycharm/download/
download-thanks.html?platform=windows&code=PCC
1. Launch the PyCharm IDE and select File ➤ Settings for Windows
and Linux or select PyCharm ➤ Preferences for macOS.
6
Chapter 1 Prerequisites and Software Installation
OpenCV
OpenCV is one of the most popular and widely used libraries for image processing. All
code examples in this book are based on OpenCV 4. Therefore, our installation steps are
for version 4 of OpenCV.
7
Chapter 1 Prerequisites and Software Installation
We will take an easy route to install OpenCV 4 and Python 3 bindings using PIP. We
will install the opencv-python-contrib package from PyPI in the virtual environment
that we created previously.
So here we go!
$ source cv/bin/activate
Additional Libraries
There are some additional libraries that we will need as we work on some of the
examples. Let’s install and keep them in our virtualenv.
Installing SciPy
Install SciPy with the following:
Installing Matplotlib
Install Matplotlib with the following:
Please note that the libraries installed in this chapter are frequently updated. It
is strongly advised to check the official websites for updates, new versions of these
libraries, and the latest installation instructions.
8
CHAPTER 2
• To learn how pixels are organized in an image and how to access and
manipulate them
I mage Processing
Image processing is the technique of manipulating a digital image to either get an
enhanced image or extract some useful information from it. In image processing, the
input is an image, and the output may be an image or some characteristics or features
associated with that image. A video is a series of images or frames. Therefore, the
technique of image processing also applies to video processing. In this chapter, I will
explain the core concepts of digital image processing. I will also show you how to work
with images and write code to manipulate them.
9
© Shamshad Ansari 2020
S. Ansari, Building Computer Vision Applications Using Artificial Neural Networks,
https://doi.org/10.1007/978-1-4842-5887-3_2
Chapter 2 Core Concepts of Image and Video Processing
Image Basics
A digital image is an electronic representation of an object/scene or scanned document.
The digitalization of an image means converting it into a series of numbers and storing
these numbers in a computer storage system. Understanding how these numbers are
arranged and how to manipulate them is the primary objective of this chapter. In this
chapter, I will explain what makes an image and how to manipulate it using OpenCV and
Python.
Pixels
Imagine a series of dots arranged in rows and columns, and these dots have different
colors. This is pretty much how an image is formed. The dots that form an image are
called pixels. These pixels are represented by numbers, and the values of the numbers
determine the color of a pixel. Think of an image as a grid of square cells with each cell
consisting of one pixel of a particular color. For example, a 300×400-pixel image means
that the image is organized into a grid of 300 rows and 400 columns. That means our
image has 300×400 = 120,000 pixels.
Pixel Color
A pixel is represented in two ways: grayscale and color.
Grayscale
In a grayscale image, each pixel takes a value between 0 and 255. The value 0 represents
black, and 255 represents white. The values in between are varying shades of gray. The
values close to 0 are darker shades of gray, and values closer to 255 are brighter shades of
gray.
Color
The RGB (which stands for Red, Blue, and Green) color model is one of the most popular
color representations of a pixel. There are other color models, but we will stick to RGB in
this book.
10
Chapter 2 Core Concepts of Image and Video Processing
In the RGB model, each pixel is represented as a tuple of three values, generally
represented as follows: (value for red component, value for green component, value for
blue component). Each of the three colors is represented by integers ranging from 0 to
255. Here are some examples:
(0,0,128)
(128,0,128)
(128,128,0)
Let’s try to make yellow. Here is a clue: red and green make yellow. That means a
pure red (255), a pure green (255), and no blue (0) will make yellow. So, our RGB tuple
for yellow is (255,255,0).
Now that we have a good understanding of pixels and their color, let’s understand
how pixels are arranged in an image and how to access them. The following section will
discuss the concept of coordinate systems in image processing.
C
oordinate Systems
Pixels in an image are arranged in the form of a grid that is made of rows and columns.
Imagine a square grid of eight rows and eight columns. This will form an 8×8 or 64-pixel
image. This may be imagined as a 2D coordinate system in which (0,0) is the top-left
corner. Figure 2-1 shows our example 8×8-pixel image.
11
Chapter 2 Core Concepts of Image and Video Processing
The left-top corner is the start or origin of the image coordinate system. The pixel
at the top-right corner is represented by (7,0), the bottom-left corner is (7,0), and the
bottom-right pixel is (7,7). This may be generalized as (x,y), where x is the position of the
cell from the left edge of the image and y is the vertical position down from the top edge
of the image. In Figure 2-1, the red pixel is in the fifth position from the left and fourth
from the top. Since the coordinate system begins at 0, the coordinate of the red pixel
shown in Figure 2-1 is (4,3).
To make it a little clearer, let’s imagine an image that is 8×8 pixels, with the letter H
written on it (as shown in Figure 2-3). Also, for simplicity, assume this is a grayscale
image with the letter H written in black and the rest of the area of the image in white.
Remember, in the grayscale model, a black pixel is represented by 0, and a white one
is represented by 255. Figure 2-3 shows the values of each pixel within the 8×8 grid.
12
Chapter 2 Core Concepts of Image and Video Processing
So, what’s the value of the pixel at position (1,4)? And at position (2,2)?
I hope you now have a clear picture of how images are represented by numbers
arranged in a grid. These numbers are serialized and stored in the computer’s
storage system and rendered as an image when displayed to the screen. By now you
know how to access pixels using the coordinate system and how to assign colors to
these pixels.
We have established a solid foundation and learned the basic concepts of image
representation. Let’s get ourselves some hands-on practice with some Python and
OpenCV coding. In the following section, I will show you, step-by-step, how to write
code to load images from the computer’s disk, access pixels, manipulate them, and write
them back to the disk. Without further ado, let’s dive in!
13
Chapter 2 Core Concepts of Image and Video Processing
For a color image, the returned value from NumPy will be a tuple
for red, green, and blue. Note that OpenCV maintains the RGB
sequence in the reverse order. Remember this important feature
of OpenCV to avoid any confusion while working with OpenCV.
In other words, OpenCV stores the colors in BGR sequence and not in RGB
sequence.
Before we write any code, let’s make sure we always use our virtualenv, in the ~/cv
directory, that we already set up with PyCharm.
Launch your PyCharm IDE and make a project (I named my project cviz, short
for “computer vision”). Refer to Figure 2-4 and ensure that you have selected Existing
Interpreter and have our virtualenv Python 3.6(cv) selected.
14
Chapter 2 Core Concepts of Image and Video Processing
Figure 2-4. PyCharm IDE, showing the setup of the project with virtualenv
Filename: Listing_2_1.py
1 from __future__ import print_function
2 import cv2
3
4 # image path
5 image_path = "images/marsrover.png"
6 # Read or load image from its path
7 image = cv2.imread(image_path)
8 # image is a NumPy array
9 print("Dimensions of the image: ", image.ndim)
10 print("Image height: ", format(image.shape[0]))
11 print("Image width: ", format(image.shape[1]))
12 print("Image channels: ", format(image.shape[2]))
15
Chapter 2 Core Concepts of Image and Video Processing
16
Chapter 2 Core Concepts of Image and Video Processing
The image NumPy array consists of three dimensions: height × width × channel. The
first element of the array is the height, which tells us how many rows our pixel grid has.
Similarly, the second element is the width, which represents the number of columns of
the grid. The three channels represent the BGR (not RBG) color components. The size
of the array is 400×640×3 = 768,000. This actually means that our image has 400×640 =
256,000 pixels, and each pixel has three color values.
17
Chapter 2 Core Concepts of Image and Video Processing
As shown in Figure 2-6, the modified image has a 100×100-pixel square at the top-left
corner in aqua, represented by (255,255,0) of the BGR scheme.
D
rawing
OpenCV provides convenient methods to draw shapes on an image. We will learn how to
draw a line, rectangle, and circle on an image using the following methods:
Line: cv2.line()
Rectangle: cv2.rectangle()
Circle: cv2.circle()
Filename: Listing_2_3.py
1 from __future__ import print_function
2 import cv2
3
4 # image path
5 image_path = "images/marsrover.png"
6 # Read or load image from its path
7 image = cv2.imread(image_path)
8
9 # set start and end coordinates
10 start = (0, 0)
11 end = (image.shape[1], image.shape[0])
12 # set the color in BGR
13 color = (255,0,0)
14 # set thickness in pixel
15 thickness = 4
16 cv2.line(image, start, end, color, thickness)
17
18 #display the modified image
19 cv2.imshow("Modified Image", image)
20 cv2.waitKey(0)
Line 11 specifies the coordinates of the endpoint of the image. You will notice that
the expression (image.shape[1], image.shape[0]) represents the coordinates of the
bottom-right corner of the image.
You have probably guessed by now that we are drawing a diagonal line.
Line 13 sets the color of the line we are going to draw, and line 15 sets its thickness.
The actual line is drawn in line 16. The cv2.line() function takes the following
arguments:
–– Image NumPy. This is the image where we are drawing the line.
–– Start coordinates.
–– End coordinates.
–– Color.
Finally, the modified image is shown on line 19. Line 20 waits for the user to press
any key to terminate the program. Figure 2-7 shows the sample output of the image we
just drew a line on.
20
Chapter 2 Core Concepts of Image and Video Processing
Listing 2-4. Loading an Image, Drawing a Rectangle to It, Saving It, and
Displaying the Modified Image
Filename: Listing_2_4.py
1 from __future__ import print_function
2 import cv2
3
4 # image path
5 image_path = "images/marsrover.png"
6 # Read or load image from its path
7 image = cv2.imread(image_path)
8 # set the start and end coordinates
9 # of the top-left and bottom-right corners of the rectangle
10 start = (100,70)
11 end = (350,380)
12 # Set the color and thickness of the outline
13 color = (0,255,0)
14 thickness = 5
15 # Draw the rectangle
16 cv2.rectangle(image, start, end, color, thickness)
17 # Save the modified image with the rectangle drawn to it.
18 cv2.imwrite("rectangle.jpg", image)
19 # Display the modified image
20 cv2.imshow("Rectangle", image)
21 cv2.waitKey(0)
21
Chapter 2 Core Concepts of Image and Video Processing
Line 10 sets the starting point of the rectangle we want to draw on the image. The
starting point consists of the coordinates of the top-left corner of the rectangle.
Line 11 sets the endpoint of the rectangle. This represents the coordinates of the
bottom-right corner of the rectangle.
Line 13 sets the color, and line 14 sets the thickness of the outline of the rectangle.
Line 16 actually draws the rectangle. We are using OpenCV’s rectangle() function,
which takes the following parameters:
Notice that line 16 does not have any assignment operator. In other words, we did
not assign the return value from the cv2.rectangle() function to any variable. The
NumPy array, image, that is passed as an argument to the cv2.rectangle() function is
modified.
Line 18 saves the modified image, with rectangle drawn on it, to a file on the disk.
Line 20 displays the modified image.
Line 21 calls the waitKey() function to allow the image to remain displayed on the
screen until a key is pressed. The function waitKey() waits for a key event infinitely or
for a certain delay in milliseconds. Since the OS has a minimum time between switching
threads, the waitKey() function will not wait, after a key is pressed, for exactly the delay
time passed as an argument to the waitKey() function. The actual wait time depends on
other programs that your computer might be running at the time when a key is pressed
and waitKey() function is called.
Figure 2-8 shows the output of the image with the rectangle drawn on it.
22
Chapter 2 Core Concepts of Image and Video Processing
In the previous example, we first read an image from the disk and drew a rectangle
on it. We will now slightly modify this example and draw the rectangle on a blank canvas.
We will first create a canvas (as opposed to loading an existing image) and draw a
rectangle on it. We will then save and display the resultant image. See Listing 2-5.
Listing 2-5. Drawing a Rectangle on a New Canvas and Saving the Image
23
Chapter 2 Core Concepts of Image and Video Processing
In Listing 2-5, all the lines except lines 3 and 6 are the same as in Listing 2-4.
Line 3 imports the NumPy library that we will use to create the canvas.
Line 6 is where we are creating an image (called the canvas). Our canvas is 200×200
pixels with each pixel holding three channels (to hold BGR values). The variable name,
canvas, is a NumPy array that, in this case, holds a zero value for each pixel. Notice that
the data type of each pixel value of the canvas is an 8-bit unsigned integer (as explained
in Chapter 1).
How would you draw a solid rectangle (meaning, a rectangle filled with a
particular color)?
Clue: set the thickness to -1.
Figure 2-9 shows the output of Listing 2-5. Figure 2-10 shows a canvas with a solid
rectangle drawn on it.
24
Chapter 2 Core Concepts of Image and Video Processing
Filename: Listing_2_6.py
1 from __future__ import print_function
2 import cv2
3 import numpy as np
4
5 # create a new canvas
6 canvas = np.zeros((200, 200, 3), dtype = "uint8")
7 center = (100,100)
8 radius = 50
9 color = (0,0,255)
10 thickness = 5
11 cv2.circle(canvas, center, radius, color, thickness)
12 cv2.imwrite("circle.jpg", canvas)
13 cv2.imshow("My Circle", canvas)
14 cv2.waitKey(0)
The code in Listing 2-6 is not very different from that of Listing 2-5 except that line 7
defines the center of the circle.
In addition, line 8 sets the radius, line 9 defines the color, and line 10 sets the
thickness of the circle. Finally, line 11 draws the circle and accepts the following
parameters:
–– The image on which to draw the circle. This is our NumPy array
containing the image pixels.
–– The coordinates of the center of the circle.
25
Chapter 2 Core Concepts of Image and Video Processing
Summary
In this chapter, we learned the basics of images, starting with pixels and how they are
represented in different color schemes, namely, gray and color. The coordinate system
helps locate a specific pixel and manipulate their values. We learned how to draw some
basic shapes such as a line, a rectangle, and a circle on an image. Although these are very
basic and easy, they are important concepts to do anything in image processing.
In the next chapter, we will explore different techniques and algorithms used in
image processing.
26
Other documents randomly have
different content
"You made goodness seem so charming!"
Pen turned and clung to him. A tear or two rolled down her cheeks. "Oh,
my dear! ... It isn't true! ... But it comforts me so!"
"Stretch out," she whispered. "I will sit on the stool beside you where I
can look at you. I love so to look at you!"
But he sunk lower and lower. Soon he was gone. Pen sitting beside him
could gaze her fill. The moon was coming in the front windows now. The
direct rays did not fall on him, but there was light enough for her to see. All
relaxed and helpless like that he seemed to belong to her more completely
than he ever did awake—and stubborn. She could scarcely bear to look at
him.
In the end she slept too with her cheek on his breast.
She was awakened, she knew not how long afterwards, by a sound. Even
in the instant of waking she recognized the sound. It was the stealthy creak
of the tin roof outside her window. At the touch of her hand on his cheek
Don awoke all of a piece. He slipped noiselessly to the floor. They crept to
the middle of the room.
With her lips at his ear she breathed: "There's a man on the porch roof."
Don made to creep away from her. She laid a hand on his arm. "Wait!"
"He's not coming in," Pen whispered. "He's out there to cut off your
escape."
"It's all right!" whispered Pen. "I intended you should stay here."
The knocking was imperiously repeated. Outside Pen's door they heard
her father's agitated voice.
For the third time that night the worthy little man pattered down stairs in
his bare feet.
Pen opened her door an inch. She heard her father's prudent inquiry
through the closed door, and a gruff voice outside reply:
She heard the key squeak in the lock. Pendleton's remonstrances were
drowned in the sounds made by the entrance of a number of men.
Pendleton's voice was raised in agonized tones. Delehanty said:
Pen had the sense that her little father was trying to bar them out by main
strength. Signing to Don to remain where he was, she hastened to the head
of the stairs. She called down:
Returning to her room she locked the door. Her father came up stairs
accompanied by a pair of shod feet. His voice at Pen's door was utterly
bewildered.
"They insist on searching the house ... searching the house! At this
hour!"
"They say if you'll stay quietly in your room they'll leave that until last.
There's a man out here on guard. Better dress, dear."
She turned and kissed Don with a smile on her lips. Her eyes shone with
the light of battle.
She nodded.
"Well then...?"
"Wait till they come up stairs."
She listened with her ear at the crack of the door. Vague sounds arose
from below. She was tormented by her inability to hear exactly. Finally she
motioned to Don to stand back out of any possible range of vision, and
opening the door, she put her head around it.
"I don't want to come out," said Pen coolly. "I want to hear what's going
on in my house."
Now her ear practised in that house, could follow their movements very
well. They were in the cellar. They took no precautions for silence. They
came stamping up the cellar stairs, and were to be heard in the kitchen and
the outer kitchen. They spread through the main rooms of the house. Pen
smiled to herself, hearing them move heavy objects of furniture, looking for
hiding-places in the walls. Finally they started up the main stairway, but
were diverted into the rear extension. Doors were opened and shut, furniture
pulled about. As they started to move back towards the front, Pen closed her
door.
She took him to the door leading to the rear room. "Lock this door
behind you and put the key in your pocket." She pointed to an open window
in the corner of the room facing the rear. "There's your way out. The
ironing-board is on the floor under the window. Stretch it across catty-
cornered to the sash of the bathroom window. I pulled down the top sash
ready for you. As you go, turn and close this window behind you. When
you get in the bath-room pull the board after you. Don't touch that window.
It squeaks. Wait in the bath-room with the door open. If you hear anybody
coming that way slip down the back stairs and into the cellar. While you're
in the bathroom watch this window. When they're through with this room
I'll raise the window and leave it up. That's your signal to come back."
There was a peremptory knock on the door of Pen's room. The lovers
pressed hands and parted. Slipping through the door, Don closed it
noiselessly and turned the key.
Pen wanted all the time she could gain. "Is my father there?" she asked
as if in doubt.
"One moment!"
She turned down the covers of her bed, and rumpled them. Her ears were
strained for sounds from the back, but she heard nothing. So much the
better!
She opened the door. There was a small crowd in the hall. One carried a
brilliant acetylene lantern which filled the place with a strong white light
and threw grotesque shadows upwards. All the detectives had their hats on;
some were short, some tall. It was like a caricature in violent chiaroscuro.
As for Pendleton, he had his pants pulled over his night-shirt and his bare
feet looked piteous. A picture of ineffectiveness, he was still carrying a
lighted candle in all that glare.
Without so much as by your leave Delehanty strode into the room with
three of his men at his heels. The chief was chewing an extinct cigar which
smelled vilely. Pen choked with rage. She bit her lips to keep back an
outburst. Her father went to her, and squeezed her hand imploringly. The
three men spread around the room like well-trained dogs. One could
imagine them sniffing. They were armed with electric torches with which to
illumine dark corners. Delehanty went direct to the door into the rear room
and rattled it.
"What's behind here?" he demanded.
"The door has been locked for many years. I couldn't tell you."
"Well what's the door from that room into the hall doing locked?"
"Because I keep certain things of value in there. I don't want the servants
to go in."
Pen's father must have wondered at this answer. But perhaps he was too
confused to take in what she was saying. At any rate he kept quiet.
"No," said Pen calmly. "It's among the other keys on the rack in my
sewing-room. My father will get it for you."
The acetylene lantern filled the great bare chamber with light. It was
meagerly furnished, a gigantic bedroom set of the carved walnut period, the
bed with an old-fashioned mosquito bar, an air-tight stove, an humble little
rocking-chair. The great expanse of white wall was guiltless of paper or tint,
and showed long fine cracks running in every direction like the map of a
complicated river system. The floor was covered with matting.
Delehanty sniffed. "The air is fresh. There's been a window open in
here."
Pen's heart contracted. "The room is aired every day," she said quickly.
Delehanty went to the window in the corner. The two windows at the
side of the room were shuttered on the outside. He cast his light along the
sill.
"No, sir."
The bare room offered but few places of concealment, under the bed,
within the washstand, a shallow clothes closet in the wall. They even looked
in the bureau drawers. Finally Delehanty with a grunt, moved towards the
door. Pen's heart swelled big with triumph.
She glanced at Delehanty's cigar. "Would you mind leaving the window
open?" she said cuttingly.
At a nod from the chief, one of the men flung up the sash. Pen felt a little
quiver of inward laughter. There was something humorous in making the
enemy transmit one's signals. All left the room and Pen locked the door. She
handed the key to her father.
Delehanty fixed her with an irascible, suspicious eye. "You come along
with us the rest of the way, Miss. I want no trickery!"
Pen shrugged.
The search went on, that queer crew straggling through the rooms
accompanied by their grotesque up-flung shadows. Through Pen's sewing-
room and into Pendleton's bed-room. From thence they passed into the
extraordinary room behind where he kept all his "Collections." He never
threw anything away. Everything under the sun was to be found there. All
around the walls were rickety, home-made tables heaped with his
impedimenta.
All this occupied the searchers quite a while. They threw his stuff about
regardless of his protests.
Finally there was the third story which Pen had long ago given up to dust
and spiders and last of all the "cupalow" into which Keesing to Pen's
amusement, ascended with drawn revolver.
"Ah! ask your daughter for the explanation!" snarled the detective. "Take
my advice, and keep her home nights!"
"How do I know? A man will say anything when he's sore ... Come on
back to bed."
She pulled him wildly to the foot of the stairs, Pendleton leaning back,
and his bare feet slapping the floor absurdly. Pen laughed so she had to sit
on the bottom step to recover.
That only made her laugh the more. "Come on! Come on!" she said,
dragging him up-stairs.
At the door of his room she kissed him, and gave him a push inside. She
flew across to her own room and let herself in.
She flew to the door between the two rooms. It yielded to her hand. The
key was in it. So he had come back. The window in the corner was still
open. It was very dark in the back room. She felt all around for him, softly
whispering his name. Her breast contracted with apprehension. She ran
back into the front room to make a light.
As soon as the candle flame grew up she saw a piece of paper pinned to
the wooden mantel. It looked like the fly leaf torn out of a book. There was
a pencil scrawl upon it.
"Dearest: Writing in the dark. That was too near a thing. Can't let you
take such risks. I'm off on my own. Don't worry. Love.
"D."
CHAPTER X
DAYS OF SUSPENSE
Pen lay on her bed wide-eyed and dry-eyed until near dawn. It did not
lessen her misery any that a good part of it was anger at having her will
balked. She accused Don by turn of callousness, of ingratitude, of folly; she
tried to tell herself that he was not worth saving, but without abating any of
her torments of anxiety as to his fate. It was worse than anxiety; she had a
horrible, dull certainty that he would be taken as soon as it became light.
Like a wilful child intent only upon having his own way, he had run blindly
out into their trap.
Well, if he was still looking for men Don was not yet caught,
nevertheless, Pen's heart sickened at the sight. It was clear enough what was
happening. During the last few days popular interest in the chase had fallen
off, but the news of the finding of the canoe had revived it. The blood lust
was aroused again. When she got down to the kitchen Pen learned from the
excited negroes that Riever had increased the reward to ten thousand
dollars. That was what had brought the crowd.
Like a woman who had died and whose body was condemned to drag
on, Pen started things going in the kitchen and set the table for breakfast.
When her father came into the dining-room even he who noticed so little,
was struck by the contrast of her present look with the laughing mænad who
had thrust him into his room the night before.
Pen shrugged. She had to make some excuse. "Last night was too much
for me," she muttered.
"I thought so!" he said severely. "I told you you were acting wildly ...
Riever had nothing to do with that affair," he added irrelevantly.
Pendleton had already been out of doors, and he could talk about nothing
but the latest developments of the case. In his new interest, his resentment
against Delehanty had cooled. Pen could not gather from his talk what they
were saying about her. No doubt they spared his feelings—or mocked him
without his being aware of it. With the curious blindness that was
characteristic of him, he had not yet connected the finding of the canoe with
his daughter.
"How strange that Counsell should have come back here after having
paddled away!" he said. "And yet, how natural! It was the last thing anyone
would suppose that he would do!"
Pen let him run on, half attending.
"Of course Riever has been entirely discreet in making his new
announcement. He had it written out and sent it over to the Island last night
to be posted up outside the store. His offer reads: 'Ten thousand dollars for
the apprehension of Donald Counsell.' But everybody understands that it
means dead or alive. Many of the men are armed."
Pen thought she had experienced the extremity of torment. But this was
saving for her. She half rose from her chair with a face of horror, and
dropped back again.
"Cold-blooded murder! ... Cynical murder! ... To set an armed mob after
a defenseless man ... with the promise of reward!"
She saw that she had betrayed herself, but she was beyond caring.
Pushing her chair back she went to the mantel and resting her arms upon it
dropped her head on them. "Oh God! what sort of a world is it where such
things are possible!" she cried.
She could not be still in her agony. She paced up and down stretching up
her arms for the ease to her breast which was not to be had. "Whatever you
like!" she said.
"My God!"
She still went about her daily tasks like a piece of mechanism. She had
to keep in some sort of motion. She experienced strange lapses, discovered
herself offering whole corn in her hand to the newly-hatched chicks; came
to to find herself in places without any notion of what she had come for.
Her father kept out of her way.
It took a long time to organize the searchers. Delehanty was not taking
any chance of failure. He was in no particular hurry since he had already
sent a large party by boat to the head of the creek to cut off any escape up
the Neck. Finally about ten o'clock the rest were ready. They set off in three
parties, the first making its way along the river shore to comb the woods on
the Absolom's Island side; the second setting off towards the lighthouse to
surround the pond in the woods; the third and largest party heading straight
back by the Neck road. Their instructions were to deploy along the edge of
the woods, and wait until they got in touch with the parties on either flank.
Two lads who brought motor-cycles over from the Island were delegated to
act as messengers between Delehanty and the searchers.
Later, Pen came upon her father in the back kitchen, or dairy, evidently
seeking to waylay her. He seemed not greatly affected by the scene in the
dining-room, only for a hang-dog air, and a difficulty in meeting her glance.
As a matter of fact Pen's tragic eyes intimidated him. For himself, he had
been absorbed in trifles for so long that he could not feel anything very
deeply.
He said: "I suppose you've forgotten that we were to lunch on the yacht
to-day."
The gathering storm on her brows warned him not to go any further. But
he still hung around like a child.
"Oh go ahead! Tell him I'm sick. Tell him anything you like."
"Well I will if you think it's all right. I want to talk business with him
anyway."
He donned the old frock coat and the comical, flat straw hat and set off
as blithely as a child with a penny in its hand. Pen's glance after him was
bitter. Nevertheless she was thankful to be rid of him.
There came a time when Pen could no longer keep up even the pretense
of doing her chores. Always with her mind's eyes she was following the
searchers. They had come to the edge of the woods. They were spreading
out. They were waiting until the parties on either side came up. Now they
had climbed the fence and were advancing slowly with their guns held
ready; ignorant, passionate men with their guns cocked! She went to her
room and paced up and down with her clenched hands pressed to her breast.
She could not stay there either. She came down on the porch where she
could hear better and paced endlessly up and down, careless of who might
be a witness to her agitation. All her faculties were concentrated on hearing.
She was listening for shots.
Time passed and there was no news. She sent Ellick, the more intelligent
of Aunt Maria's sons down to the beach to pick up what he could. One or
two negroes had come over in the boats. This was regarded as a white man's
business and they were not allowed to take part in it. Nothing transpired
until mid-afternoon when Ellick came back to say that the motorcycle boys
had brought in Counsell's camping outfit which had been found in the
woods. Of Counsell himself there was no word.
A wild hope arose in Pen's breast. Suppose after all he had succeeded in
getting away up the Neck before the line was drawn across it!
Her hope soon sickened though. What good if he had escaped for the
moment? There was but the one road eighty miles long, by which he could
reach cities and crowds and safety. And by this time everybody along that
road was on the qui vive to catch him, their mouths watering at the ten
thousand dollar reward. What chance had he of succor? Where could he get
food? Or on that sandy peninsula, water?
At five o'clock she beheld her father turning in at the gate accompanied
by Riever. At the sight of the latter Pen saw red. Hideous little creature
lunching on his fine yacht while his dollars sent men into the woods to
murder! And now to come strutting ashore for an afternoon stroll with his
expensive cigar cocked between his lips! How dared he present himself to
her! Her impulse was to project herself down off the porch and tell him! But
a last strand of prudence held. She went to her room instead.
There she struggled with her feelings. Five o'clock! Faint though it might
be, there was a real chance that Don had escaped. She must therefore go on
fighting for him. And in order to fight for him effectually she must maintain
some sort of relations with his loathsome enemy.
There was a knock on her door, and her father said timidly: "Mr. Riever
is down stairs, my dear."
"I scarcely expected to see you," he said smoothly. "I just came to
enquire how you are."
"He's supposed to exercise some discretion ... You're really all right
again?"
"I'm so glad!"
It came to her that he didn't expect her to be taken in. He was satisfied if
she would only appear to be taken in. For different reasons he was just as
anxious to maintain relations as she was. He just wanted everything
unpleasant covered up. That was the spoiled child of it. Pen thought: "I
believe he'd actually marry me without inquiring into my feelings." Well, it
made it easier for her.
Pen however only said: "I'm surprised to see you on foot this afternoon."
His face turned smug again. "I like walking," he said. "It's my ridiculous
people that insist on having me carried every step."
"Sometimes."
"Ah, an apartment."
"No, I detest apartments. One always feels as if the hall servants were
spying on your comings and goings."
"No, clubs are all very well in their way, but I'm not a clubby person. I
like to spread about among my own things. In a club too, the servants are
always under your feet. In New York I like to get away from servants
altogether. I am not so dependent on them as you seem to think."
Pen's heart began to beat a little thickly. "And have you such a place?"
she asked with interest. Apparently they were back just where they had been
before the violent scene of the previous night.
"Yes."
"A salle a manger on the ground floor looking out on a little formal
garden at the back. On the main floor the salon in front and a bedroom in
the rear. In the attic, servants rooms. Just a little house for one.... Or two,"
he added with a sidelong glance.
He held her hand loverly-wise for a long moment, Pen steeling herself
not to shudder. Then he left the room.
Pen began to laugh but there was no sound of mirth in it. She began to
laugh and she could not stop again. The tears ran down her face and her
whole body was shaken with tearing sobs. She ran to her room. She was
horribly unstrung. It was long before she could get hold of herself again.
The collapse eased the strain on her nerves. She came down-stairs and
was able to resume her usual round of tasks. Time was passing, and still no
bad news had been received. Hope grew stronger. Finally word was brought
down the road that the search party had joined forces with the line of guards
drawn across the Neck, and Don Counsell had not been taken. Pen was able
to face the night unafraid.
She presently learned that Delehanty had formed his men into several
camps for the night. The automobile was kept busy running up the road
with supplies for them. At the same time he was preparing to have the road
well patrolled along its whole course through the woods. After dark a
fugitive could not travel any distance except by the road.
The night came on muggy and still and Pen was attacked by a fresh
anxiety. For clouds of mosquitoes arose. She pictured Don fainting with
hunger and thirst, and unable even to make a smudge for fear of betraying
himself, vainly attempting to protect himself from the insects.
She had a wild hope that he might be driven back to her. When the house
had been searched they had found the open cellar door, and in the morning
Delehanty had sent a man to shut the doors and screw them down. Before
she went to bed Pen took lantern and screw driver and satisfying herself that
she was not watched at the moment, knelt behind the bushes and opened the
doors. She also left the way open for Don to return to her room by the route
that he knew of.
She went to bed praying that she might awaken to find him kneeling on
the floor beside her. She did sleep for awhile, for Nature must have her due,
but when she awoke she was still alone.
When she came down-stairs in the morning she heard a new sound that
froze her soul, the deep bay of hounds. Theodo' came into the kitchen, his
eyes rolling wildly in an ashy face, to say that a couple of "man-huntin'
dawgs" had been brought over from the Eastern shore to be put on
Counsell's tracks. These mythical creatures filled the negro with an
extremity of terror. Nothing would tempt him out of doors again.
Meanwhile Pen's collie, Doug, locked up in the barn, hearing these
trespassers on his preserve, and he unable to get at them, went frantic with
rage.
The bloodhounds were taken to the spot in the woods where Don's cache
had been discovered, and were given the scent from Don's clothes. They
picked up his tracks without difficulty and came back over the fields, giving
tongue straight to the cellar door. Delehanty finding it unlocked again,
searched the house once more. The dogs were led around the house. Pen
observing from within, saw that they picked up the trail again outside the
kitchen window. So Don had gone out that way. However they were soon
confused amidst the maze of tracks that tramped down the house grounds in
every direction. Again and again their guardians led them over the ground
with no better success.
Notwithstanding these measures the second day passed like the first with
neither sight nor sound of the fugitive. It was believed that he was still in
the neighborhood, because the bloodhounds, though they were led far and
wide through the woods and up the road, had discovered no tracks leading
away from Broome's Point.
When the morning of the third day broke Pen had reached the point of
desperation again. Not for a moment all night had she closed her eyes. She
was now convinced that Don was lying exhausted and starving in some
hidden spot in the woods. Probably no longer even able to give himself up.
For she was sure he would not willingly perish without a fight to clear his
name. When she first came out of the house the sight of a pair of buzzards
circling high against the blue, turned her faint and sick.
To spend another day of inaction was unthinkable. Madness lay that way.
There was no longer any question of helping him to escape. If he was
anywhere near he must be found, whatever might come of it. In her
extremity Pen went to Delehanty to tell him she was going to take part in
the search.
The detective was considerably taken aback. He pushed out his lower lip
and glowered at Pen. "What's the idea?" he demanded.
Pen shrugged.
"Hold on a minute!" said the detective, "you satisfy me that you're on the
square with me, and I'll work with you fast enough."
Pen was able to tell him the truth—without telling him the whole truth.
"It's very simple," she said. "I don't want him to starve on the place, that's
all."
Pen was silent. It was of little moment to her what they thought so they
did not know anything.
"For one thing," said Pen, "the fields have never been searched. I see you
send your men up the road every morning. There are hollows in the fields
where a man could lie concealed. Some of the fields are growing up with
young pine that would afford cover."
"If he's in the woods when he heard the searchers approach how easy it
would be to climb a tree until they had passed."
"No."
"I shall call him as I go," said Pen. "If he saw or heard others with me he
wouldn't be so likely to answer."
Pen shrugged. She had only mentioned the revolver as a bit of stage
business anyway.
"Go and find him if you want," said Delehanty, "but excuse me from
taking any chances of having my gun slipped to him."
Pen went back to the house and made up a packet of sandwiches. As she
was setting out the second time she ran into Riever coming in by the drive.
He had evidently been with Delehanty, and under his forced air of
politeness an extraordinary conflict of feelings was suggested; hope,
distrust and a gnawing curiosity. He would not speak of what was in his
mind, of course. "Where are you setting out for so busily?" he asked with a
false air of blitheness.
Pen was blunt enough. "I believe this man is starving somewhere on the
place, and I'm going to find him if I can."
Riever put on a look of gladness and delight. The guiding rule of his
kind is that by assuming a thing to be so you make it so. He therefore
assumed that Pen had come over to his side, that the millions had won out,
that he and she were now one in sympathy. It need hardly be mentioned
though, that his eye still rolled with a hideous doubt.
Riever ground his teeth secretly. "How can you be sure?" he said with a
great air of solicitude.
"I believe you're out after the reward!" Riever said, with a ghastly sort of
facetiousness.
Pen caught at the suggestion. If she were obliged to bring Don in, the
money might make all the difference to them. "Well, why not?" she said. "I
could use the money as well as anybody."
There was a quality of eagerness in her voice that could hardly have
been feigned. For the moment it lulled his doubts. "There's nobody I'd
rather pay it to," he said grinning.
"You mean that?" said Pen. "If I give him up to you, will you pay me the
reward?"
"All right!" said Pen. "If I'm successful to-day, I'll hold you to that." She
made to walk on.
Riever's face was full of triumph, but there was still a fear too, another
sort of fear. "Wait a minute," he said. "Suppose you can't handle him?"
"Thanks," she said putting it inside her dress, and walked on.
He strutted after her as far as the gates, and stood there watching. She
turned into the path behind the cottage, and followed it into the woods. Her
idea in making the little temple her starting-point was that Don in need of
succor, might haunt the paths they had followed together.
The sun was looking straight into the little glade through the side that
opened above the pond, filling the place with a rich yellow light. Between
the shadows of the pillars a broad beam lay athwart the inscription of the
gravestone, picking out the curly flourishes of the letters that had been
sculped with such loving care. Pen was indifferent now to her shadowy
brother who lay under the stone. She had not remembered him in many
days. Her thoughts were filled by a man of flesh and blood.
"Don! Don!" she spoke softly, not expecting any answer there, and not
getting any.
She let herself down the bank to the spring around at the left which
welled between the roots of a superb white oak that the axe had spared. For
a tree which guards a spring is sacred even to a timber scout. Pen had hopes
of the spring because it was one of the only two places that Don knew of
where fresh water was to be obtained. She searched carefully about it but
was not rewarded by finding any tracks. She made a wider circuit of the
spot but could not see that the underbrush had been disturbed.
She forced her way slowly through the tangle of thorny creepers and
thickly-springing sassafras around the pond to the old wood road. It curved
away secretly into the gloom; old, undisturbed, overgrown; Nature had
painted in this ancient blemish. Years ago the bed of the road had been
packed so hard that even yet nothing would take root there except a mossy
growth like fur underfoot. But at either side bushes had taken advantage of
the free light to spring up thickly. Now for the most part they met overhead,
though there were places where the sun splashed through.
Pen walked slowly, pausing often to softly call Don's name. Nothing
answered her but bird sounds, and the soft chattering of leaves in the high
sunlight. No breath stirred down below. She made wide detours through
secondary roads, mere cuts through the woods that only a practised eye
could follow now.
It was noon when she came out at the edge of the fields. She sat down
under the fence to rest, and, from a sense of duty, to eat something.
Afterwards she struck clear across the rough, neglected, cleared land to the
woods on the other side, then back again, shaping a course that took her
through every hollow. Her experience with sheep had taught her the exact
lay of the peninsula, how each depression gradually deepened into a gully,
running off to some branch on one side or the other. But nowhere did she
find what she was looking for.
She spent several hours searching the banks of the little stream that
meandered through the woods to the east of the fields. That was where she
had sent him to make his camp that night. She found the site of his camp,
but no evidences that he had revisited it. There were plenty of tracks in the
mud of the stream, for the searchers had passed and re-passed this way, but
no voice answered her soft calls.
Finally she struck across the corner of the farthest field, making for the
path which went down through the woods to the arm of Back creek, that
path they had followed on another night, a night of happiness. She thought
of the old skiff drawn up on top of the bank, and had a wild hope that he
might have launched it and succeeded in making his way down the arm and
across the main creek to the mainland. True, the skiff was leaky and rotten,
but a desperate man might make it serve for a short voyage. She ran the last
part of the way.
The skiff was there, just as before! She dropped down upon it, weary of
body and despairing of heart, and burst into tears.
The sun was low, and there could be no further searching that day. Pen
made her heavy way back through the woods, and across the wide field. As
she walked a merciful apathy descended on her. She could suffer no more.
Imaginary pictures of Don starving in the woods no longer rose before her
mind's eye. She was conscious only of a ghastly vacuum inside her. Within
it a little thought stirred like a snake: "This can't go on! If I don't hear in two
or three days more..." She never completed the thought, but her soul was
aware of her intention.
As she was letting down the bars that admitted her to the road, a squad
of men straggled by, searchers homeward bound. Pen hung back to let them
pass. The business was in the nature of a lark to them; young men relieved
for the time being from the tedium of their usual lives, they were talking
loud, laughing, jostling each other in the road. They stared at Pen as
unabashed as animals, and Pen busied herself with the bars. Nevertheless
she was aware that one of them did not stare at her. She looked at him, and
was struck first, by his curiously self-conscious air. She looked afresh,
rubbed her eyes so to speak, and her heart stood still.
It was Don.
True, his chin was covered with a four days' growth of reddish stubble,
his bare head was touselled and unbrushed, he walked with exactly the
same shambling slouch as the others. But it was Don. He had passed her,
but the line of his cheek was enough, and the muscular back under the
cotton shirt. She recognized the old garments she had herself carried to him.
Far from being the starving wreck she had pictured, his cheek was full and
ruddy, his whole body notwithstanding the shamble he affected, full of
spring. For an instant she thought they had taken him. But that was
manifestly ridiculous. He was skylarking with the rest. His whole bearing
was that of a leader amongst them.
Pen leaned against the fence post. A welter of emotions seemed to shatter
her; joy, incredulity, terror that her wits might be wandering, anger at his
careless air of well-being.
Bye and bye she put up the bars mechanically, and started to walk along
the road with a dazed air. She could not take in what had happened. Dusk
was falling. In a couple of hundred yards a figure stepped out from the
shadow of the bordering growth.
"Pen!" it whispered.
Her first reaction was to a shaking anger. She was a little beside herself.
Stamping her foot in the road she cried in a soft, strained voice: "You Don!
Cutting up like a school-boy in the road! Is that all you have on your mind!"
He fell back a step in surprise. Then he laughed softly like the boy she
accused him of being. "But Pen ... aren't you glad?"
"Yes, laugh! do!" she said bitterly. "It's nothing to you what I've been
through these last three days and nights!"
"There was no way in which I could let you hear from me. I thought
you'd understand everything was all right."
He moved close to her. "Pen dear, don't quarrel with me! We have only a
moment. Even this is risky. There are more men coming along the road."
She attempted to push him away. "Don't touch me! You're heartless and
unfeeling!"
Even as she said it she began to sob. She swayed on her feet, and Don
flung an arm about her. She clung to him piteously.
"Oh my darling! my darling! ... Thank God! I have you! ... Don't pay any
attention to what I say. I have suffered so. I was just at the end of my string.
If I had not found you soon I ... I ..."
"Hush, dearest!" he murmured, sobered and remorseful. "You mustn't
say such things. I can't bear it! ... It's true I never thought. I had such
confidence in your strength."
"I thought you were starving in the woods. I couldn't eat when I thought
you had nothing! I couldn't sleep, seeing you lying there."
"Hush! Hush!" he soothed her. "Everything is all right now. Pull yourself
together, dearest. There are stragglers all along the road."
Indeed they could now hear footfalls coming along behind them. They
started to walk too, Don straining Pen hard against his side. Everybody was
traveling the same way. Gradually Pen's breast quieted down.
"It means I'm one of the searchers for Don Counsell," he said with a
chuckle. "Only place they'd never think of looking for me."
"And I've made good in the job, too," he went on. "I'm considered quite
a valuable man. Delehanty has put me in charge of a squad."
"Delehanty!" she gasped. "Do you mean you have spoken to him?"
"Why not? He doesn't know Don Counsell by sight. None of his men do.
The only one who knows me is Riever, and I take damn good care to keep
out of his way. Luckily it's easy. He doesn't bother with the rough necks.
And you can always see him coming a long way off by his gang."
"Most natural thing in the world. My way is different from yours. You
plan everything out, and I leave it to the inspiration of the moment. When I
tried to get out by the cellar that night I heard a man down there. They had
one out on the kitchen porch, too. So I took the screen out of the window on
the other side, and dropped to the ground and hid in the shrubbery. I
gradually made my way down to the beach. There were some natives
camping there, but I was afraid to join them then, so I kept under cover until
daylight. In the morning a raft of newcomers arrived from all over, and it
was a simple matter to mix amongst them. They didn't all know each other."
"Oh, I kept my mouth shut as much as possible. I gave out that I was
Frank Jones from New Jersey, see? That accounted for my Northern speech.
I said I was off a coasting schooner. Meanwhile I've been practising their
lingo, and I can already speak Mar'land at least well enough to deceive
Delehanty and the other Northerners. Doggone it honey Ah reckon Ah kin
tawk! 'Deed, can I! Gemmen, it's the trewth!"
"Every day that passes makes my position more secure," he said. "I'm
becoming known. At least Frank Jones is. This crop of saw-tooth is a
wonderful disguise."
He softly rubbed his chin against her cheek. Pen liked it.
There came a hail from down the road ahead. "Hey, Jones!"
"No! No!" said Pen. "Everything's going so well. We mustn't take risks
... But we ought to have some way of communicating."
"Name it quick!"
"There's a little water-pan inside it. Look under that for a letter."
"All right," he laughed. "If I'm pinched for swiping chickens you'll have
to clear me!"
He ran down the road. Pen followed at a sober pace—still a little dazed.
CHAPTER XI
It was a justly aggrieved father that Pen found awaiting her in the dining-
room.
Pen was quiet and starry-eyed with happiness. It didn't matter much to
her what she said. But she rather wished to avoid a scene. She juggled with
the truth a little.
"Delehanty! ... Wanted you!" he said amazed. It was too much for him.
The magic name mollified him a little. "Hum! Ha! ... Well, if Riever
knew ... What suddenly started you off on this tack?"
"I confess I fail to understand you!" he said severely ... "What help could
you give them anyway?"
"I had only to raise my voice to bring a dozen to my aid ... Besides, Mr.
Riever lent me a revolver."
"Oh! ... Well you might have taken your father into your confidence ...
Did you find anything?"
"No."
A more perspicacious man might have remarked the little catch of joy
with which she said it, but never Pendleton. "The supper is cold," he said
fretfully. "Aunt Maria's gone home."
"Never mind," said Pen. Out of the riches in her breast she could spare
affection for him, the dear, trying child! She kissed his bald spot. "I'll make
a cup of tea for myself."
"I got the mail this afternoon," he grumbled. "There's a letter for you."
Pen glided swiftly around the table. "I never saw it either," she said.
Which was perfectly true. A scrawling, half-formed hand. The post-mark
"New York" told her all that she needed to know.
She thrust it carelessly in her belt and went out into the kitchen.
Pendleton looked affronted. He was terribly curious. Pen lit the oil stove
and put the kettle on. Then she read her letter.
"Dear Miss:
I'm not much at writing. Please excuse mistakes. Well Miss Broome I
guess you were right, all right. Everything bears out what you said. I and
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.
ebooknice.com