100% found this document useful (6 votes)
41 views

(Ebook) Raspberry Pi Image Processing Programming: Develop Real-Life Examples with Python, Pillow, and SciPy by Ashwin Pajankar ISBN 9781484227305, 1484227301 all chapter instant download

The document provides information about various ebooks related to Raspberry Pi programming, particularly focusing on image processing and scientific programming by Ashwin Pajankar. It includes links to download these ebooks in different formats and outlines their contents, including chapters on Python, digital image processing, and practical applications. Additionally, it mentions copyright details and the availability of supplementary materials for readers.

Uploaded by

einstzaitov
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 (6 votes)
41 views

(Ebook) Raspberry Pi Image Processing Programming: Develop Real-Life Examples with Python, Pillow, and SciPy by Ashwin Pajankar ISBN 9781484227305, 1484227301 all chapter instant download

The document provides information about various ebooks related to Raspberry Pi programming, particularly focusing on image processing and scientific programming by Ashwin Pajankar. It includes links to download these ebooks in different formats and outlines their contents, including chapters on Python, digital image processing, and practical applications. Additionally, it mentions copyright details and the availability of supplementary materials for readers.

Uploaded by

einstzaitov
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/ 81

Download the Full Ebook and Access More Features - ebooknice.

com

(Ebook) Raspberry Pi Image Processing Programming:


Develop Real-Life Examples with Python, Pillow,
and SciPy by Ashwin Pajankar ISBN 9781484227305,
1484227301
https://ebooknice.com/product/raspberry-pi-image-processing-
programming-develop-real-life-examples-with-python-pillow-
and-scipy-50195000

OR CLICK HERE

DOWLOAD EBOOK

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


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

Start reading on any device today!

(Ebook) Raspberry Pi Image Processing Programming: With


NumPy, SciPy, Matplotlib, and OpenCV by Ashwin Pajankar
ISBN 9781484282694, 1484282698
https://ebooknice.com/product/raspberry-pi-image-processing-
programming-with-numpy-scipy-matplotlib-and-opencv-44512010

ebooknice.com

(Ebook) Raspberry Pi Image Processing Programming: With


NumPy, SciPy, Matplotlib and OpenCV, 2nd Edition by Ashwin
Pajankar ISBN 9781484282700, 9781484282694, 1484282698,
1484282701
https://ebooknice.com/product/raspberry-pi-image-processing-
programming-with-numpy-scipy-matplotlib-and-opencv-2nd-
edition-44555732
ebooknice.com

(Ebook) Raspberry Pi Supercomputing and Scientific


Programming: MPI4PY, NumPy, and SciPy for Enthusiasts by
Ashwin Pajankar (auth.) ISBN 9781484228777, 9781484228784,
1484228774, 1484228782
https://ebooknice.com/product/raspberry-pi-supercomputing-and-
scientific-programming-mpi4py-numpy-and-scipy-for-enthusiasts-5880908

ebooknice.com

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason;


Viles, James ISBN 9781459699816, 9781743365571,
9781925268492, 1459699815, 1743365578, 1925268497
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com
(Ebook) Raspberry PI Computer Vision Programming by
Pajankar, Ashwin ISBN 9781784398286, 1784398284

https://ebooknice.com/product/raspberry-pi-computer-vision-
programming-55322632

ebooknice.com

(Ebook) Instant Raspberry Pi: The Beginner's Guide to


Raspberry Pi setup by Ashwin Pajankar

https://ebooknice.com/product/instant-raspberry-pi-the-beginner-s-
guide-to-raspberry-pi-setup-47486426

ebooknice.com

(Ebook) Practical Linux with Raspberry Pi OS: Quick Start


by Ashwin Pajankar ISBN 9781484265093, 1484265092

https://ebooknice.com/product/practical-linux-with-raspberry-pi-os-
quick-start-34608638

ebooknice.com

(Ebook) Raspberry Pi By Example by Pajankar, Ashwin,


Kakkar, Arush ISBN 9781785285066, 1785285068

https://ebooknice.com/product/raspberry-pi-by-example-55322468

ebooknice.com

(Ebook) Learn Raspberry Pi Programming with Python by


Wolfram Donat

https://ebooknice.com/product/learn-raspberry-pi-programming-with-
python-54981222

ebooknice.com
TECHNOLOGY IN AC TION™

Raspberry Pi
Image Processing
Programming
Develop Real-Life Examples with
Python, Pillow, and SciPy

Ashwin Pajankar
Raspberry Pi
Image Processing
Programming
Develop Real-Life Examples with
Python, Pillow, and SciPy

Ashwin Pajankar
Raspberry Pi Image Processing Programming: Develop Real-Life Examples with Python,
Pillow, and SciPy
Ashwin Pajankar
Nashik, Maharashtra, India
ISBN-13 (pbk): 978-1-4842-2730-5 ISBN-13 (electronic): 978-1-4842-2731-2
DOI 10.1007/978-1-4842-2731-2
Library of Congress Control Number: 2017936370
Copyright © 2017 by Ashwin Pajankar
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject
to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for
any errors or omissions that may be made. The publisher makes no warranty, express or implied, with
respect to the material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Celestin Suresh John
Technical Reviewer: Lentin Joseph
Editorial Board: Steve Anglin, Pramila Balan, Laura Berendson, Aaron Black,
Louise Corrigan, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John,
Nikhil Karkal, James Markham, Susan McDermott, Matthew Moodie, Natalie Pao,
Gwenan Spearing
Coordinating Editor: Sanchita Mandal
Copy Editor: Kezia Endsley
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference
our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text are
­available to readers at www.apress.com. For detailed information about how to locate your book’s
source code, go to www.apress.com/source-code/. Readers can also access source code at
SpringerLink in the Supplementary Material section for each chapter.

Printed on acid-free paper


Contents at a Glance

About the Author������������������������������������������������������������������������������ xi


About the Technical Reviewer�������������������������������������������������������� xiii
Acknowledgments��������������������������������������������������������������������������� xv
Introduction����������������������������������������������������������������������������������� xvii

■■Chapter 1: Introduction to Single Board Computers and


Raspberry Pi����������������������������������������������������������������������������������� 1
■■Chapter 2: Introduction to Python and Digital Image
Processing������������������������������������������������������������������������������������ 25

■Chapter 3: Getting Started������������������������������������������������������������ 41

■Chapter 4: Basic Operations on Images��������������������������������������� 51

■Chapter 5: Advanced Operations on Images�������������������������������� 65

■Chapter 6: Introduction to Scientific Python�������������������������������� 81

■Chapter 7: Transformations and Measurements�������������������������� 93

■Chapter 8: Filters and Their Application��������������������������������������� 99

■Chapter 9: Morphology, Thresholding, and Segmentation���������� 111

Index���������������������������������������������������������������������������������������������� 123

iii
Contents

About the Author������������������������������������������������������������������������������ xi


About the Technical Reviewer�������������������������������������������������������� xiii
Acknowledgments��������������������������������������������������������������������������� xv
Introduction����������������������������������������������������������������������������������� xvii

■■Chapter 1: Introduction to Single Board Computers and


Raspberry Pi����������������������������������������������������������������������������������� 1
Single Board Computers (SBCs)�������������������������������������������������������������� 1
Differences Between SBCs and Regular Computers������������������������������������������������ 2
System on Chips (SoCs)�������������������������������������������������������������������������������������������� 2
History of SBCs��������������������������������������������������������������������������������������������������������� 3
SBC Families������������������������������������������������������������������������������������������������������������� 3

The Raspberry Pi������������������������������������������������������������������������������������� 4


Raspberry Pi Setup���������������������������������������������������������������������������������� 5
Required Hardware��������������������������������������������������������������������������������������������������� 6
Preparation of the microSD Card for Raspberry Pi��������������������������������������������������� 9
Download the Required Free Software������������������������������������������������������������������� 10
Writing the Raspbian OS Image to the microSD Card��������������������������������������������� 10
Altering the Contents of the config.txt File for a VGA Monitor�������������������������������� 12
Booting Up the Pi���������������������������������������������������������������������������������������������������� 13
Configuring the Pi��������������������������������������������������������������������������������������������������� 15

The Raspbian OS����������������������������������������������������������������������������������� 18


The config.txt File���������������������������������������������������������������������������������� 18

v
■ Contents

Connecting the Raspberry Pi to a Network and to the Internet������������� 19


WiFi������������������������������������������������������������������������������������������������������������������������� 19
Ethernet������������������������������������������������������������������������������������������������������������������ 21

Updating the Pi�������������������������������������������������������������������������������������� 22


Updating the Firmware������������������������������������������������������������������������������������������� 22
Updating and Upgrading Raspbian������������������������������������������������������������������������� 22
Updating raspi-config��������������������������������������������������������������������������������������������� 23

Shutting Down and Restarting Pi���������������������������������������������������������� 24


Conclusion��������������������������������������������������������������������������������������������� 24
■■Chapter 2: Introduction to Python and Digital Image
Processing������������������������������������������������������������������������������������ 25
A History of Python�������������������������������������������������������������������������������� 25
Features of Python�������������������������������������������������������������������������������� 26
Simple�������������������������������������������������������������������������������������������������������������������� 26
Easy to Learn���������������������������������������������������������������������������������������������������������� 27
Easy to Read����������������������������������������������������������������������������������������������������������� 27
Easy to Maintain����������������������������������������������������������������������������������������������������� 27
Open Source����������������������������������������������������������������������������������������������������������� 27
High-Level Language���������������������������������������������������������������������������������������������� 27
Portable������������������������������������������������������������������������������������������������������������������ 27
Interpreted�������������������������������������������������������������������������������������������������������������� 28
Object-Oriented������������������������������������������������������������������������������������������������������ 28
Extensible��������������������������������������������������������������������������������������������������������������� 28
Extensive Libraries������������������������������������������������������������������������������������������������� 28
Robust�������������������������������������������������������������������������������������������������������������������� 28
Rapid Prototyping��������������������������������������������������������������������������������������������������� 29
Memory Management�������������������������������������������������������������������������������������������� 29
Powerful����������������������������������������������������������������������������������������������������������������� 29
Community Support������������������������������������������������������������������������������������������������ 29

vi
■ Contents

Python 3������������������������������������������������������������������������������������������������ 29
The Differences Between Python 2 and Python 3�������������������������������������������������� 30
Why Use Python 3��������������������������������������������������������������������������������������������������� 31

Python 2 and Python 3 on Raspbian������������������������������������������������������ 31


Running a Python Program and Python Modes������������������������������������� 31
Interactive Mode����������������������������������������������������������������������������������������������������� 32
Normal Mode���������������������������������������������������������������������������������������������������������� 32

IDEs for Python�������������������������������������������������������������������������������������� 33


IDLE������������������������������������������������������������������������������������������������������������������������ 33
Geany���������������������������������������������������������������������������������������������������������������������� 34

Introduction to Digital Image Processing���������������������������������������������� 36


Signal Processing��������������������������������������������������������������������������������������������������� 36
Image Processing��������������������������������������������������������������������������������������������������� 37
Using Raspberry Pi and Python for Digital Image Processing (DIP)������������������������ 38

Conclusion��������������������������������������������������������������������������������������������� 39

■Chapter 3: Getting Started������������������������������������������������������������ 41
Image Sources�������������������������������������������������������������������������������������� 41
Using the Webcam�������������������������������������������������������������������������������������������������� 42
The Pi Camera Module�������������������������������������������������������������������������������������������� 44
Using Python 3 for Digital Image Processing���������������������������������������� 46
Working with Images���������������������������������������������������������������������������������������������� 47

Conclusion��������������������������������������������������������������������������������������������� 50

■Chapter 4: Basic Operations on Images��������������������������������������� 51
Image Module���������������������������������������������������������������������������������������� 51
Splitting and Merging Image Channels������������������������������������������������������������������� 51
Image Mode Conversion����������������������������������������������������������������������������������������� 53
Image Blending������������������������������������������������������������������������������������������������������� 53
Resizing an Image�������������������������������������������������������������������������������������������������� 55

vii
■ Contents

Rotating an Image�������������������������������������������������������������������������������������������������� 56
Crop and Paste Operations������������������������������������������������������������������������������������� 57
Copying and Saving Images to a File���������������������������������������������������������������������� 58
Knowing the Value of a Particular Pixel������������������������������������������������������������������ 58

ImageChops Module������������������������������������������������������������������������������ 59
ImageOps Module��������������������������������������������������������������������������������� 61
Conclusion��������������������������������������������������������������������������������������������� 63

■Chapter 5: Advanced Operations on Images�������������������������������� 65
The ImageFilter Module������������������������������������������������������������������������ 65
The ImageEnhance Module������������������������������������������������������������������� 74
Color Quantization��������������������������������������������������������������������������������� 76
Histograms and Equalization����������������������������������������������������������������� 77
Histogram Equalization������������������������������������������������������������������������������������������� 78

Conclusion��������������������������������������������������������������������������������������������� 79

■Chapter 6: Introduction to Scientific Python�������������������������������� 81
The Scientific Python Stack������������������������������������������������������������������ 81
Installing the SciPy Stack��������������������������������������������������������������������������������������� 82
A Simple Program��������������������������������������������������������������������������������������������������� 82
Simple Image Processing��������������������������������������������������������������������������������������� 83
Introduction to NumPy�������������������������������������������������������������������������������������������� 84
Matplotlib���������������������������������������������������������������������������������������������������������������� 86
Image Channels������������������������������������������������������������������������������������� 89
Conversion Between PIL Image Objects
and NumPy ndarrays����������������������������������������������������������������������������� 91
Conclusion��������������������������������������������������������������������������������������������� 92

viii
■ Contents


■Chapter 7: Transformations and Measurements�������������������������� 93
Transformations������������������������������������������������������������������������������������ 93
Measurements�������������������������������������������������������������������������������������� 95
Conclusion��������������������������������������������������������������������������������������������� 98

■Chapter 8: Filters and Their Application��������������������������������������� 99
Filters���������������������������������������������������������������������������������������������������� 99
Low-Pass Filters��������������������������������������������������������������������������������������������������� 100
High-Pass Filters�������������������������������������������������������������������������������������������������� 105
Fourier Filters������������������������������������������������������������������������������������������������������� 108

Conclusion������������������������������������������������������������������������������������������� 110

■Chapter 9: Morphology, Thresholding, and Segmentation���������� 111
Distance Transforms���������������������������������������������������������������������������� 111
Morphology and Morphological Operations����������������������������������������� 113
Structuring Element���������������������������������������������������������������������������������������������� 113
Various Morphological Operations������������������������������������������������������������������������ 113
Grayscale Morphological Operations�������������������������������������������������������������������� 115

Thresholding and Segmentation��������������������������������������������������������� 117


Conclusion������������������������������������������������������������������������������������������� 121
Book Summary������������������������������������������������������������������������������������ 121
What’s Next����������������������������������������������������������������������������������������� 121

Index���������������������������������������������������������������������������������������������� 123

ix
About the Author

Ashwin Pajankar is a polymath. He is a Science popularizer, a programmer, a maker, an


author, and a YouTuber. He graduated from IIIT Hyderabad with MTech in Computer
Science and Engineering. He has a keen interest in the promotion of science, technology,
engineering, and mathematics (STEM) education. He has written three books with Packt
Publication, six books with Leanpub, and one book with Apress Media, and he has also
reviewed four books for Packt Publications. He’s currently working on several more books
with Apress Media as well.
His personal web site is found at www.AshwinPajankar.com.
His LinkedIn profile is found at https://in.linkedin.com/in/ashwinpajankar.

xi
About the Technical
Reviewer

Lentin Joseph is an author, entrepreneur, electronics


engineer, robotics enthusiast, machine vision expert,
embedded programmer, and the founder and the
CEO of Qbotics Labs (http://www.qboticslabs.com)
from India.
He completed his bachelor’s degree in electronics
and communication engineering at the Federal
Institute of Science and Technology (FISAT), Kerala.
For his final year engineering project, he made a social
robot that interacted with people. The project was a
huge success and was mentioned in many forms of
visual and print media. His robot can communicate with people and reply intelligently
and has image-processing capabilities such as face, motion, and color detection. The
entire project was implemented using the Python programming language. His interest in
robotics, image processing, and Python started with that project.
After his graduation, he worked for three years at a startup company focusing on
robotics and image processing. In the meantime, he learned to work with famous robotic
software platforms such as Robot Operating System (ROS), V-REP, and Actin (a robotic
simulation tool), as well as with image-processing libraries such as OpenCV, OpenNI, and
PCL. He also knows about robot 3D designing and embedded programming on Arduino
and Tiva Launchpad.
After three years, he started a new company called Qbotics Labs, which mainly
focuses on research to build great products in domains such as robotics and machine
vision. He maintains a personal web site (at http://www.lentinjoseph.com) and a
technology blog called technolabsz (see http://www.technolabsz.com). He publishes
his works on his tech blog. He was also a speaker at PyCon2013, India, on the topic of
learning about robotics using Python.
Lentin is the author of the books, Learning Robotics Using Python (see http://
learn-robotics.com to find out more) and Mastering ROS for Robotics Programming
(see http://mastering-ros.com to find out more), both by Packt. The first book was
about building an autonomous mobile robot using ROS and OpenCV. This book was
launched at ICRA 2015 and was featured in the ROS blog, Robohub, OpenCV, the Python
web site, and various other such forums. The second book is on mastering the Robot
Operating System, which was also launched at ICRA 2016, and is one of the bestselling
books on ROS. The third book is on ROS robotics projects (see http://rosrobots.com),
and is expected to be published by April 2017.

xiii
■ About the Technical Reviewer

He also reviewed one book about the Robot Operating System called Effective
Robotics Programming Using ROS (https://www.packtpub.com/hardware-and-
creative/effective-robotics-programming-ros-third-edition).
Lentin and his team were also winners of the HRATC 2016 challenge conducted
as part of ICRA 2016. He was also a finalist in the ICRA 2015 challenge, HRATC
(see http://www.icra2016.org/conference/challenges/).

xiv
Acknowledgments

Writing a book is a journey that I am glad I undertook. First, I want to thank my wife
Kavitha, without whose support the journey would never have been possible. The journey
spanned a few months but the experience will last a lifetime. I had my wife Kavitha with
me onboard this journey and I wish to express my deepest gratitude to her. Without her
unwavering support and affection, I couldn’t have pulled it off.
I am grateful to the community of professionals, students, trainers, and teachers
who, with their continual bombardment of queries, impelled me to learn more, simplify
my knowledge and findings, and place it neatly in the book. This book is for all of them.
I want to thank my friends and colleagues—the practitioners from the industry and
experts from academia—for their good counsel and filling me in with the knowledge
on the latest in the fields of single board computers, computer vision, digital image
processing, and Python.
I want to thank the technical reviewer for his vigilant reviews, suggestions,
corrections, and expert opinion.
I consider myself very fortunate for the editorial assistance provided by Apress
Media. This is my second book with Apress and collaborating with them on both the
books has been fabulous. I am thankful to Celestin Suresh John, Senior Manager, Editorial
Acquisition, Apress and Springer Science and Business Media Company, for giving me a
long-desired opportunity to collaborate and write for Apress. I also want to acknowledge
Sanchita Mandal, coordinating editor, Anila Vincent, development editor, and the team
of associates from Apress Media who adeptly guided me through the entire process of
preparation and publication.

xv
Introduction

Why This Book?


I have been using Python for more than 10 years for a variety of tasks. Initially, I used it
for GUI applications. Then I quickly moved to scientific uses as my academic projects
demanded it. When I entered professional life, I used it for automation first and then
for implementation of alert mechanisms. I have been using Python the last six years
for various fields like scientific computing, the Internet of Things, and single board
computers. I have written plenty of Python code all these years. I prefer Python to Bash
scripting, which offers limited capabilities to users like me. Over the last 10 years, I have
worked as a developer, an R&D engineer, a maker, an author, and a QA specialist. I used
Python in every single role.
This is my third dedicated book on the topic of digital image processing. I have
extensive work experience in the field of digital image processing and computer vision.
Almost all of the digital image processing programming I did was in C++ and Python. For
beginners in image processing programming, I always recommend Python, as it is easy
to learn. Also, if you are working in the research areas like Medical imaging, optics, and
biology, where the core expertise is not computer science but you must use digital image
processing, Python is the best choice, as you won’t get bogged down with its syntax.
To prepare for and write this book, I spent a lot of time writing code examples from
scratch, testing them, and then checking the PEP-8 compatibility. Also, I spent numerous
hours writing and editing the text in order to explain the image processing concepts in very
simple and plain language. I did not keep track of the time I spent posting on various forums
and discussing problems with colleagues from the industry and academia. I have poured my
heart and soul into writing this book. I hope that you readers who want to get started with
digital image processing and single board computers will find this book immensely valuable.
I wrote this book to share my knowledge and experiences while programming in
the field of digital image processing with Python 3 and Raspberry Pi. I explored multiple
techniques, frameworks, and libraries for capturing, processing, and displaying digital
images in this book. I hope you will enjoy reading and following the book as much as I
enjoyed writing it. The book covers the following topics:
• Introduction to single board computers, Python 3, and Raspberry Pi
• Interfacing Raspberry Pi with the Pi Camera module and a
Webcam
• Exploring various image-processing libraries like Pillow and
scipy.ndimage
• Introduction to additional libraries such as NumPy, matplotlib,
and Tkinter, which assist us in image processing

xvii
■ Introduction

Who This Book Is For


Raspberry Pi enthusiasts are the main audience of this book. This includes a large and
diverse set of people such as developers, students, researchers, and novice learners.
The book is for those who have some prior knowledge of the Python programming
language. If you are a developer, student, or a researcher with some experience in Python
programming, you can quickly learn the concepts related to digital image processing with
your favorite little British computer, Raspberry Pi.

What This Book Is Not


This is not a book for learning Python 3 programming and syntax from scratch. It is more
of a DIY cookbook for Raspberry Pi and digital image processing. If your understanding
of coding is limited or you are not from computer science background, you will find it
difficult to follow this book.

How This Book Is Organized


This book has nine chapters. Here is a sneak peek into the chapters of the book:
Chapter 1: This chapter introduces the readers to the history and the philosophy of
single board computers. Then it explores Raspberry Pi basics. It teaches readers to set up
the Raspberry Pi and connect it to a network.
Chapter 2: This chapter introduces the readers to the history and the philosophy
of Python. It teaches you how to install Python and how to set up the environment for
Python 3 programming. It also explores new features of Python 3 in brief and introduces
the readers to a few popular Python 3 IDEs. The chapter concludes with a brief
introduction to the concepts related to digital image processing and related areas.
Chapter 3: The aim of this chapter is to quickly get the readers started with digital
image processing in Python 3. The chapter introduces the readers to capture images with
a Webcam and Pi Camera. It introduces the readers to Pillow for image processing and to
Tkinter for GUI.
Chapter 4: This chapter serves to introduce basic arithmetic and logical operations
on Image. Readers also study the image channels in this chapter.
Chapter 5: This chapter explores advanced operations like filtering and effects on
images. Readers are introduced to the concept of the histogram and its computation.
Chapter 6: This chapter introduces you to the world of scientific image processing.
We will install the SciPy stack on Raspberry Pi. We also get started with SciPy, NumPy,
and matplotlib in this chapter.
Chapter 7: This chapter helps readers understand the measurements and
transformations using the scipy.ndimage module of SciPy library.
Chapter 8: This chapter introduces readers to the important concept of filtering. We
will study types of filters (such as low-pass and high-pass filters) and their applications.
Chapter 9: This chapter helps readers understand the concepts related to
morphology. It also covers thresholding. Finally, the chapter uses both concepts to
achieve segmentation in binary images.

xviii
■ Introduction

How Do You Get the Most Out of This Book


It is easy to leverage the book to gain the maximum amount of information you can,
simply by abiding to the following:
• Read the chapters thoroughly. Perform the examples hands-on by
following the step-by-step instructions stated in the code. Do not
skip any code example. If need be, repeat the examples a second
time or until the concept is firmly etched in your mind.
• Join a Python community or discussion forum.
• Read the online documentation available for various image-
processing frameworks in Python 3.
• Read blogs covering computer vision, signal and image
processing, and Python 3.

Where Next?
I endeavored to unleash the power of digital image processing libraries for Python 3 as an
aid to the Raspberry Pi community. I recommend you read the book from cover to cover
without skipping any of the chapters, text, code examples, or exercises.
I wish you well in exploring Python and Raspberry Pi!

A Quick Word for the Instructor’s Fraternity


Attention has been paid in arriving at the sequence of chapters and also to the flow of
topics within each chapter. This is done particularly to assist my fellow instructors and
academicians in carving out a syllabus for their training from the Table of Contents (ToC).
I ensured that each concept discussed in the book includes adequate hands-on
content to enable you to teach better and provide ample hands-on practice to your
students.

A Quick Word for the Non-Computer Science Readers


If you are reading this book and do not belong to the computer science-related field then
you might face a few hurdles to understanding the concepts and mathematics behind
them. If you are working in allied fields like mathematics, electronics, signal processing,
bio-medical imaging, digital imaging, or bio-informatics, and you are reading this book
for work, I recommend reading a few books on the fundamentals of the topics explained
here. This is essential, as the book focuses more on the practicals.
Happy learning and Pythoning!!!
Author, Ashwin Pajankar

xix
CHAPTER 1

Introduction to Single
Board Computers and
Raspberry Pi

We will start this exciting journey exploring the scientific domain of digital image
processing with Raspberry Pi. To begin the journey, you must be comfortable with the
basics of single board computers (SBCs) and with Raspberry Pi. This chapter discusses
the definition, history, and philosophy behind SBCs. It compares SBCs to regular
computers. Then it moves toward the most popular and best selling SBC of all time, the
Raspberry Pi. By the end of this chapter, you will have adequate knowledge to set up your
own Raspberry Pi independently. This chapter aims to make you comfortable with the
basic concepts of SBCs and Raspberry Pi setup.

Single Board Computers (SBCs)


A single board computer (referred to as an SBC from now on) is a fully functional computer
system built around a single printed circuit board. An SBC has a microprocessor(s),
memory, input/output, and other features required of a minimally functioning computer.
Unlike with desktop personal computers (PC), most SBCs do not have expansion slots for
peripheral functions or expansion. As all the components—processor(s), RAM, and GPU,
etc.—are integrated on a single printed circuit board (PCB), you cannot upgrade an SBC.
Few SBCs are made to plug into a backplane for system expansion. SBCs come in
many varieties, sizes, shapes, form factors, and feature sets. Due to the advances in the
electronics and semiconductor technologies, prices of most SBCs are very low. One of the
most important features of SBCs is their inexpensive cost. With a price at around $50 a
piece, you have in your hand a development tool suitable for new applications, hacking,
debugging, testing, hardware development, and automation systems.

© Ashwin Pajankar 2017 1


A. Pajankar, Raspberry Pi Image Processing Programming,
DOI 10.1007/978-1-4842-2731-2_1
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

SBCs are usually manufactured with the following form factors:


• Pico-ITX
• PXI
• Qseven
• VMEbus
• VPX
• VXI
• AdvancedTCA
• CompactPCI
• Embedded Compact Extended (ECX)
• Mini-ITX
• PC/104
• PICMG

Differences Between SBCs and Regular Computers


Table 1-1 lists the differences between SBCs and regular computers.

Table 1-1. Differences Between SBCs and Regular Computers

Single Board Computer Regular Computer


Not modular Modular
Components cannot be upgraded or Components can be upgraded or
replaced replaced
A System On Chip Not a System On Chip
Has a small form factor Has a large form factor
Is portable Is mostly non-portable or semi-portable
Consumes less power Consumes more power
Cheaper than a regular computer Costs more than a SBC

System on Chips (SoCs)


All the SBCs are predominantly SoCs. A system on a chip (SoC) is an integrated circuit
(IC) that has all the components of a computer on a single chip. SoCs are very common
with mobile electronic devices because of their low power consumption and versatility.
SoCs are widely used in mobile phones, SBCs, and embedded hardware. A SoC includes
all the hardware and software needed for its operation.

2
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

SoC versus Regular CPU


The biggest advantage of using a SoC is its size. If you use a CPU, it’s very hard to
make a compact computer, only because of the number of individual chips and other
components that you need to arrange on a board. However, when using SoCs, you can
place complete application-specific computing systems in smartphones and tablets,
and still have plenty of space for batteries, the antenna, and other add-ons required for
remote telephony and data communication.
Due to the very high level of integration and the compact size, a SoC uses
considerably less power than a regular CPU. This is a significant advantage of SoCs
when it comes to mobile and portable systems. Also, reducing the number of chips by
eliminating redundant ICs on a computer board results in a compact board size.

History of SBCs
Dyna-Micro was the first true SBC. It was based on the Intel C8080A and used Intel’s first
EPROM, the C1702A. The Dyna-Micro was rebranded and marketed by E&L Instruments
of Derby, CT in 1976 as the MMD-1 (Mini-Micro Designer 1). It became famous as
the leading example of microcomputers. SBCs were very popular in the earlier days of
computing, as many home computers were actually SBCs. However, with the rise of PCs,
the popularity of SBCs declined. Since 2010, there has been a resurgence in the popularity
of SBCs due to their lower production costs.
Apart from the MMD-1, here are a few other popular historical SBCs:
• The BBC Micro was built around an MOS technology 6502A
processor running at 2MHz.
• The Ferguson Big Board II was a Zilog Z80-based computer
running at 4MHz.
• The Nascom was another Zilog Z80-based computer.

SBC Families
Based on the manufacturers and designers, the SBCs are grouped into families, models,
and generations. Here are a few popular SBC families:
• Raspberry Pi by the Raspberry Pi Foundation
• Banana Pi and Banana Pro
• Intel Edison and Galileo
• CubieBoard
• BeagleBone and BeagleBoard

3
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

The Raspberry Pi
The Raspberry Pi is a family of credit card-sized SBCs developed in the United
Kingdom by the Raspberry Pi Foundation. The Raspberry Pi Foundation formed
in 2009. The aim behind developing Raspberry Pi was to promote the teaching of
basic computer science in schools and developing countries by providing a low-cost
computing platform.
Raspberry Pi Foundation’s Raspberry Pi was released in 2012. It was a massive
hit and sold over two million units in two years. Subsequently, the Raspberry Pi
Foundation revised versions of the Raspberry Pi. They also released other accessories
for the Pi.
You can find more information about the Raspberry Pi foundation on the Raspberry
Pi Foundation’s web site at https://www.raspberrypi.org.
The product page for Raspberry Pi's current production models and other
accessories is at https://www.raspberrypi.org/products.
I have written, executed, and tested all the code examples in this book on Raspberry
Pi Models B+, 2B, and 3B. Raspberry Pi 3 Model B (also known as 3B) is the most recent
model of Raspberry Pi. Table 1-2 lists the specifications of the Raspberry Pi 3, Model B.

Table 1-2. Specifications of the Raspberry Pi 3 Model B

Release Date February 2016


Architecture ARMv8
SoC broadcom BCM2837
CPU 1.2GHz 64-bit quad-core ARM Cortex-A53
GPU Broadcom VideoCore IV (3D part of GPU @ 300MHz, video part
of GPU @ 400MHz)
Memory 1 GB (shared with GPU)
USB 2.0 ports 4
Video output HDMI rev 1.3 and Composite Video RCA jack
On-board storage Micro SDHC slot
On-board network 10/100 Mbps Ethernet, Bluetooth, and WiFi
Power source 5V via MicroUSB
Power ratings 800 mA (4W)

Figure 1-1 shows the top view of Raspberry Pi 3 Model B. The components relevant
to this book are labeled in the image.

4
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Figure 1-1. Raspberry Pi 3 Model B, top view

Figure 1-2 shows the bottom view of Raspberry Pi 3 Model B.

Figure 1-2. Raspberry Pi 3 Model B, bottom view

You can get more Information on Raspberry Pi 3 Model B by visiting the product
page at https://www.raspberrypi.org/products/raspberry-pi-3-model-b.

Raspberry Pi Setup
You have to set up Raspberry Pi before you can use it for exploration and adventure. This
section explains in detail how to set it up. As mentioned earlier, I am using Raspberry Pi 3
Model B for this setup. The setup process is exactly same for Raspberry Pi 2 Model B and
Raspberry Pi 1 Model B+. Here is the list of hardware materials to be procured for the setup.

5
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Required Hardware
The following hardware is required to set up the Raspberry Pi.

Raspberry Pi
You need to use Raspberry Pi 3 Model B or Raspberry Pi 2 Model B or Raspberry Pi 1
Model B+ for the setup.

Computer
A Windows computer or laptop with an Internet connection is required. You need to use
a computer to prepare a microSD card with a Raspbian OS image for the Pi.

I/O Devices
A standard USB keyboard and a USB mouse are required.

microSD Card
A microSD card (see Figure 1-3) with at least 8GB of storage is needed. You’ll use the card
for secondary storage for the Pi. A card of Class 10 is recommended as the data transfer
speed with class 10 is great. I recommend using at least an 8GB card to be on the safe side.
Choosing a 16GB card will be adequate for most of the use cases.

■■Note Before purchasing a card, visit http://elinux.org/RPi_SD_cards to check the


compatibility of the card with the Raspberry Pi.

Figure 1-3. Class 10 microSD card

6
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Power Supply
For all the Raspberry Pi models, a 5V Micro USB power supply unit (PSU) is required. The
recommended current capacity of the PSU for Raspberry Pi 3 Model B is 2.5 amp. For all
the other models, a 2 amp PSU is more than enough.
You can find Raspberry Pi's official power supply (see Figure 1-4) at
https://thepihut.com/products/official-raspberry-pi-universal-power-supply.

Figure 1-4. Raspberry Pi official power supply

Card Reader
You also need a card reader. Many laptops have a built-in SD card reader.
If the laptop or the card reader works with an SD card only, you need a additional
microSD-to-SD card adapter. Figure 1-5 shows a card reader and an adapter.

7
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Figure 1-5. Card reader and microSD-to-SD adapter

Monitor
You need an HDMI or VGA monitor.
For an HDMI monitor, you need an HDMI male-to-male cable (see Figure 1-6). It is
typically packaged with the HDMI monitor.

Figure 1-6. HDMI male-to-male cable

8
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

For the VGA monitor, you need a VGA cable (see Figure 1-7). This too is usually
packaged with the VGA monitor.

Figure 1-7. VGA male-to-male cable (also known as a D-SUB cable)

If you are using a VGA monitor, you need an HDMI to VGA adapter (see Figure 1-8),
because Raspberry Pi has an HDMI port only for the video output.

Figure 1-8. HDMI to VGA adapter

Preparation of the microSD Card for Raspberry Pi


Manually preparing the microSD card for Pi is the best way of installing any OS into
a microSD card for SBCs. Many users (including me) prefer it, because it allows the
contents of microSD card to be modified manually (if needed) before it is used for
booting. The other way to prepare the microSD is to use NOOBS (New Out Of the Box
Software), which I have not used in this book.

9
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

This approach allows you to access to the configuration files like /boot/config.txt
before booting. You might have to modify the configuration files in a few cases
(we will discuss that soon) before booting up the Pi. The default Raspbian image has two
partitions, called boot and system. Be sure to use at least a 16GB microSD card for the Pi
considering any possible future upgrades to the OS.

Download the Required Free Software


Let's download the required software.

Download Accelerator Plus


Download the Download Accelerator Plus setup from its download page (http://www.
speedbit.com/dap/download/downloading.asp). This freeware is used to manage
downloads. It is useful for large downloads, as you can pause and resume downloads. If
your computer shuts down suddenly or the Internet is interrupted, it resumes the download
from the last checkpoint. Once you download and install it, use it to manage any further
downloads.

Win32 Disk Imager


Download the Win32 Disk Imager setup from its download page (https://sourceforge.net/
projects/win32diskimager/files/latest/download). Install it.

WinZip or WinRaR
You need a file extraction utility. Download WinZip (http://www.winzip.com/win/
en/index.htm) or WinRaR (http://www.win-rar.com/download.html). Install the one
you chose.

Download and Extract the Raspbian OS Image


You will use the Raspbian OS for the Pi. (We will discuss Raspbian in detail in a later part
of the chapter.) As of now, download the latest ZIP of the image of the Raspbian OS from
https://www.raspberrypi.org/downloads/raspbian. Extract the image ZIP file using
WinZip or WinRaR.

Writing the Raspbian OS Image to the microSD Card


Insert the microSD card into the card reader. If your computer or laptop has a built-in
card reader, insert it there. You might have to use a microSD-to-SD card adapter if the
card reader or your computer has a slot only for the SD card reader.
Open Win32 Disk Imager. Select the location of the image file and click the Write
button (see Figure 1-9).

10
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Figure 1-9. Win32 Disk Imager

If you see the warning message shown in Figure 1-10, toggle the write protection
notch of the card reader or the SD card adapter (or both). Then click the Write button
again.

Figure 1-10. Write protection error message

Figure 1-11 shows the warning message that will be displayed. Click Yes to continue.

Figure 1-11. Overwrite warning message

11
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Once the OS image has been written to the SD card, the message in Figure 1-12 will
be displayed. Click OK.

Figure 1-12. The Write Successful message

This means the Raspbian OS has been flashed to the microSD card.

Altering the Contents of the config.txt File for a VGA


Monitor

■■Note This step is a must if you are planning to use a VGA monitor. You should skip this
step if you are using an HDMI monitor.

You need to change the contents of the config.txt file to get the Pi working with
VGA monitors. You will learn more about config.txt later in this chapter.
Insert the microSD card into the card reader again and browse it in Windows
Explorer. In Windows Explorer, it will be represented as a removable media drive
called boot.
Open the config.txt file and make the following changes to it:
• Change #disable_overscan=1 to disable_overscan=1
• Change #hdmi_force_hotplug=1 to hdmi_force_hotplug=1
• Change #hdmi_group=1 to hdmi_group=2
• Change #hdmi_mode=1 to hdmi_mode=16
• Change #hdmi_drive=2 to hdmi_drive=2
• Change #config_hdmi_boost=4 to config_hdmi_boost=4
Save the file after making these changes. The microSD card is now ready for the Pi
and for a VGA monitor.

12
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Booting Up the Pi
Let's boot the Pi up with the prepared microSD card. The steps for that are as follows.

1. If you are using an HDMI monitor, connect the monitor


directly to the Pi’s HDMI port using the HDMI male-to-male
cable. If you are using a VGA monitor, use the HDMI-to-VGA
adapter to convert HDMI signals to VGA.
2. Insert the microSD card into the microSD card slot of the Pi.
3. Connect the USB mouse and the USB keyboard.
4. At this point, make sure that the power is switched off. Then
connect the Pi to the power supply with a micro USB power
cable discussed earlier.
5. Connect the monitor to the power supply.
6. Check all the connections. Switch on the power supply of the
Pi and the monitor.

At this point, the Raspberry Pi will boot up.


For all the models of Raspberry Pi with the single core processor, the boot screen will
resemble the screen in Figure 1-13.

Figure 1-13. Single-core CPU RPi model boot screen

13
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

For all the models of Raspberry Pi with the quad-core processor, the boot screen will
resemble Figure 1-14.

Figure 1-14. Quad-core CPU RPi model boot screen

Once the Pi boots up, the monitor displays the desktop, as shown in Figure 1-15.

Figure 1-15. Raspbian desktop (as of February 2017)

14
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Configuring the Pi
You need to configure the Pi for further use. Let’s do that.
On the desktop, there is a taskbar. In the taskbar, you’ll see the icon shown in
Figure 1-16.

Figure 1-16. LXTerminal icon

Click the icon to open the LXTerminal window, as shown in Figure 1-17.

Figure 1-17. The LXTerminal window

The terminal is a desktop-independent VTE-based terminal emulator for LXDE


without any unnecessary dependencies. Type sudoraspi-config in the prompt and press
Enter. The raspi-config is the configuration tool for Raspberry Pi.

15
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

First expand the filesystem, as shown in Figure 1-18.

Figure 1-18. The raspi-config utility’s main menu

Then navigate to the boot options, which are highlighted in Figure 1-19.

Figure 1-19. The raspi-config with the Boot Options highlighted

Set the Boot Options to Desktop Autologin, as shown in Figure 1-20.

Figure 1-20. Desktop Autologin is highlighted

16
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

In the Internationalization Options section, change the time zone and the WiFi
country (see Figure 1-21). Change the keyboard layout to US.

Figure 1-21. The raspi-config internationalization options

Once you’re done, go back to the the main screen and click Finish, as shown in
Figure 1-22.

Figure 1-22. Finish

17
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

It will ask if you want to reboot at this point, as shown in Figure 1-23. Choose Yes.

Figure 1-23. Reboot prompt

It will reboot the Pi.


Your job is not done yet. You need to learn how to connect the Pi to the Internet and
how to update it.

The Raspbian OS
An operating system is the set of basic programs and utilities that make a computer work.
It is an interface between the user and the computer. Raspbian is a free operating system
based on the popular Linux distribution, Debian. Raspbian is optimized for the Raspberry
Pi family of SBCs. It is even ported to the other similar SBCs like Banana Pro.
Raspbian has more than 35,000 packages and lots of pre-compiled software
bundled for easy installation and use on the Raspberry Pi. The first build of Raspbian
was completed in June of 2012. Raspbian is still under active development and updated
very frequently. Visit the Raspbian home page at https://www.raspbian.org and the
Raspbian documentation page at https://www.raspbian.org/RaspbianDocumentation
for more information on Raspbian.

The config.txt File


Raspberry Pi does not have a conventional BIOS. The BIOS (basic input/output system)
is the program that a computer’s microprocessor uses to get the computer system started
after it is turned on. It also manages data flow between the computer’s operating system
and attached peripheral devices such as the hard disk, video adapter, keyboard, mouse,
and printer.

18
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Since the Raspberry Pi does not have a BIOS, the various system configuration
parameters that are normally stored and modified using the BIOS are instead stored in a
text file called config.txt.
The Raspberry Pi config.txt file is on the boot partition of the Raspberry Pi. It is
normally accessible as /boot/config.txt from Linux. However, from Windows and Mac
OS, it is seen as a file in the accessible part of the microSD card. The accessible part of the
card is labeled as boot. As you learned earlier in this chapter, you must edit the /boot/
config.txt file if you want to connect it to a VGA display.
On Raspberry Pi, you can edit this file with the following command in the
LXTerminal:

sudo nano /boot/config.txt

■■Note nano is a simple and easy-to-learn text-based text editor for Linux. Visit its home
page at https://www.nano-editor.org to learn more about it. I find it easier to use than
the vi or vim editors.

To learn more about config.txt, visit the page http://elinux.org/RPiconfig.


A sample configuration can also be found at http://elinux.org/R-Pi_configuration_
file.

Connecting the Raspberry Pi to a Network and


to the Internet
To connect the Pi to any network, you have to edit the /etc/network/interfaces file.
If the network the Pi is connected to is connected to the Internet, the Pi can access the
Internet as well.

WiFi
Raspberry Pi 3 Model B has built-in WiFi. For all the other models of Pi, you need to use a
USB WiFi adapter.
Once the USB WiFi adapter is attached to the Pi, take a backup of the /etc/network/
interfaces file using the following command:

sudo mv /etc/network/interfaces /etc/network/interfaces.bkp

The original /etc/network/interfaces file is safe this way, and it can be restored if
something goes wrong.
Now create a new /etc/network/interfaces file as follows:

sudo nano /etc/network/interfaces

19
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Type the lines from Listing 1-1 into that new file.

Listing 1-1. /etc/network/interfaces


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "ASHWIN"
wpa-psk "internet"

In Listing 1-1, replace ASHWIN with the SSID of your WiFi network and replace
internet with the password of your WiFi network. Save the file by pressing Ctrl+X and
then y.
Run the following command to restart the networking service:

sudo service networking restart

If you followed the steps correctly, the Pi should be connected to the WiFi network
and to the Internet (provided that the WiFi network is connected to the Internet, of
course).
To verify connectivity with the Internet, use the following command:

ping -c4 www.google.com

It should show output similar to this:

PING www.google.com (216.58.197.68) 56(84) bytes of data.


64 bytes from maa03s21-in-f4.1e100.net (216.58.197.68): icmp_seq=1 ttl=55
time=755 ms
64 bytes from maa03s21-in-f4.1e100.net (216.58.197.68): icmp_seq=2 ttl=55
time=394 ms
64 bytes from maa03s21-in-f4.1e100.net (216.58.197.68): icmp_seq=3 ttl=55
time=391 ms
64 bytes from maa03s21-in-f4.1e100.net (216.58.197.68): icmp_seq=4 ttl=55
time=401 ms

--- www.google.com ping statistics ---


4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 391.729/485.695/755.701/155.925 ms

This output indicates that the Pi is connected to the Internet.

20
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

To determine the IP address of Pi, use the ifconfig command. Check the output for
wlan0. It will appear as follows:

wlan0     Link encap:Ethernet  HWaddr 7c:dd:90:00:e2:1e


          inet addr:192.168.0.122  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::7edd:90ff:fe00:e21e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1974 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1275 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:195049 (190.4 KiB)  TX bytes:1204336 (1.1 MiB)

In this output, 192.168.0.122 is IP address of the Pi. Because the IP address is


allocated using the DHCP protocol, it will be different for you depending on your WiFi
network settings.

Ethernet
You can also connect the Pi to a LAN network. Based on the LAN switch’s settings, you
can allocate an IP address to the Pi statically or dynamically.

Static IP Address
If the LAN network allocates IP addresses statically, configure the /etc/network/
interfaces file as shown in Listing 1-2.

Listing 1-2. /etc/network/interfaces


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
# Your static IP
address 192.168.0.2
# Your gateway IP
gateway 192.168.0.1
netmask 255.255.255.0
# Your network address family
network 192.168.0.0
broadcast 192.168.0.255

21
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

In the file shown in Listing 1-2, the parameters address, gateway, netmask, network,
and broadcast are based on the LAN’s configuration. Check the manual of the LAN
switch or router. If you are working for an organization, then check with the network
administrator for these parameters.

Dynamic IP Address
This is an easy one. If the LAN has DHCP capability, configure the /etc/network/
interfaces file as shown in Listing 1-3.

Listing 1-3. /etc/network/interfaces


source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

This will configure the Pi to acquire the IP address automatically with DHCP.

■■Note All the information needed for network setup on Debian and its derivatives can be
found at https://wiki.debian.org/NetworkConfiguration.

Updating the Pi
Pi must be connected to the Internet in order to update it successfully.

Updating the Firmware


To update the firmware, run sudo rpi-update. It will do the update for you.

Updating and Upgrading Raspbian


You will use APT for this. APT (Advanced Package Too) is a program that handles the
installation and removal of software on the Debian and other Debian derivatives.
APT simplifies the process of managing software on Debian systems by automating the
fetching, configuration, and installation of software packages. You need an Internet
connection for this too.

22
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

First, update the system’s package list by entering the following command in the
LXTerminal:

sudo apt-get update

apt-get update downloads the package lists from the respective remote repositories
and updates them in the local computer so that information on the newest versions of
packages and their dependencies is available for the installation and update. It should be
run before running the install or upgrade command.
Next, upgrade all the installed packages to their latest versions using this command:

sudo apt-get dist-upgrade -y

apt-get dist-upgrade fetches new versions of the packages on the local machine
that are marked for upgrade. It also detects and installs any dependencies. It might also
remove obsolete packages.
Doing this regularly will keep your Raspbian OS up to date. After entering these
commands, it will take a while to update the OS, because these commands fetch the data
and the packages from remote repositories.

■■Note sudo apt-get --help will list all the options associated with apt-get.

Updating raspi-config
In raspi-config, go to the advanced options (see Figure 1-24) and choose Update.

Figure 1-24. Updating raspi-config

23
Chapter 1 ■ Introduction to Single Board Computers and Raspberry Pi

Shutting Down and Restarting Pi


You can shut down Pi safely using the sudo shutdown -h now command. You can restart
Pi using the sudo reboot -h now command.

Conclusion
This chapter introduced the concept and philosophy of SBCs. You also learned about a
popular family of SBCs, Raspberry Pi. Now you can confidently move ahead with further
exploration. In the next chapter, you will learn a few things about Python and digital
image processing.

24
CHAPTER 2

Introduction to Python and


Digital Image Processing

In the last chapter, we explored the amazing world of single board computers and
Raspberry Pi. We booted up the Raspberry Pi, connected it to the Internet, and updated
the Raspbian OS.
In this chapter, we will get started with Python and the concepts of digital image
processing (DIP).
Let’s begin this chapter with an introduction to Python. I personally find Python
amazing and have been enchanted by it. Python is a simple yet powerful programming
language. When programmers use Python, it’s easy to focus on solving a given problem
as they do not have to worry about the syntax. Python perfectly fits the philosophy of
Raspberry Pi, which is programming for everyone. That’s why it’s the most preferred
programming platform for Raspberry Pi and many other SBCs.

A History of Python
Python was designed and conceived in the late 1980s. Its actual implementation was
started in late 1989 by Guido van Rossum in Centrum Wiskunde & Informatica (National
Research Institute for Mathematics and Computer Science) in the Netherlands. Python
is a successor to the ABC Programming Language, which itself was inspired by SETL. In
February of 1991, Van Rossum publically published the Python source code to the alt.
sources newsgroup. The name Python was inspired by the British television show Monty
Python’s Flying Circus. Van Rossum is a big fan of Monty Python.
Van Rossum is the principal author of the Python programming language. He plays
a central role in guiding the direction of the development, enhancement, and further
evolution of Python programming language. He holds the title Benevolent Dictator for Life
for Python. He currently (as of February 2017) works for Dropbox and dedicates almost
half of his time toward further development of the Python programming language.
The central philosophy of the Python programming language (the Zen of Python) is
explained in PEP-20 (PEP stands for Python Enhancement Proposal), which can be found
at https://www.python.org/dev/peps/pep-0020.

© Ashwin Pajankar 2017 25


A. Pajankar, Raspberry Pi Image Processing Programming,
DOI 10.1007/978-1-4842-2731-2_2
Chapter 2 ■ Introduction to Python and Digital Image Processing

It is a collection of 20 software principles, out of which 19 have been documented.


The principles are as follows:
• Beautiful is better than ugly.
• Explicit is better than implicit.
• Simple is better than complex.
• Complex is better than complicated.
• Flat is better than nested.
• Sparse is better than dense.
• Readability counts.
• Special cases aren’t special enough to break the rules.
• Practicality beats purity.
• Errors should never pass silently.
• Unless explicitly silenced.
• In the face of ambiguity, refuse the temptation to guess.
• There should be one—and preferably only one—obvious way
to do it.
• Although that way may not be obvious at first unless you’re Dutch.
• Now is better than never.
• Although never is often better than right now.
• If the implementation is hard to explain, it’s a bad idea.
• If the implementation is easy to explain, it may be a good idea.
• Namespaces are one honking great idea—let’s do more of those!

Features of Python
The following are the features of Python that have made it popular and beloved in the
programming community.

Simple
Python is a simple language with a minimalist approach. Reading a well written and good
Python program makes you think you are reading English text.

26
Chapter 2 ■ Introduction to Python and Digital Image Processing

Easy to Learn
Due to its simple and English-like syntax, Python is extremely easy to learn. That is
the prime reason that it is taught as the first programming language to high school
and university students who take introductory programming courses. An entire new
generation of programmers is learning Python as their first programming language.

Easy to Read
Unlike other high-level programming languages, Python does not obfuscate the code and
make it unreadable. The English-like structure of the Python code makes it easier to read
compared to the code written in other programming languages. This makes it easier to
understand and easier to learn compared to other high-level languages like C and C++.

Easy to Maintain
As Python code is easy to read, easy to understand, and easy to learn, anyone maintaining
the code becomes comfortable with the codebase very quickly. I can vouch for this from
personal experiences of maintaining and enhancing large legacy codebases which were
written in a combination of Bash and Python 2.

Open Source
Python is an open source project, which means its source code is freely available. You
can make changes to it to suit your needs and use the original and modified code in your
applications.

High-Level Language
While writing Python programs, you do not have to manage the low-level details like
memory management, CPU timings, and scheduling processes. All these tasks are
managed by the Python interpreter. You can write the code directly in the easy-to-
understand English-like syntax.

Portable
The Python interpreter has been ported to many OS platforms. Python code is also
portable. All the Python programs will work on the supported platform without requiring
many changes if you are careful enough to avoid system-dependent coding.
You can use Python on GNU/Linux, Windows, Android, FreeBSD, Mac OS, iOS,
Solaris, OS/2, Amiga, Palm OS, QNX, VMS, AROS, AS/400, BeOS, OS/390, z/OS, Psion,
Acorn, PlayStation, Sharp Zaurus, RISC OS, VxWorks, Windows CE, and PocketPC.

27
Chapter 2 ■ Introduction to Python and Digital Image Processing

Interpreted
Python is an interpreted language. Let’s take a look at what that means. Programs written
in high-level programming languages like C, C++, and Java are compiled first. This means
that they are first converted into an intermediate format. When we run the program, this
intermediate format is loaded from secondary storage (i.e., from the hard disk) to the
memory (RAM) by the linker/loader.
So, C, C++, and Java have a separate compiler and linker/loader. This is not the case
with Python. Python runs the program directly from the source code. You do not have to
bother compiling and linking to the proper libraries. This makes Python programs truly
portable, as you can copy the program to one computer from another and the program
runs fine as long as the necessary libraries are installed on the target computer.

Object-Oriented
Python supports procedure-oriented programming as well as object-oriented
programming paradigms.
All the object-oriented programming paradigms are implemented in Python.
In the object-oriented programming languages, the program is built around objects
that combine data and the related functionality. Python is a very simple but powerful
object-oriented programming language.

Extensible
One of the features of Python is that you can call C and C++ routines from the Python
programs. If you want the core functionality of the application to run faster, you can code
that part in C/C++ and call it in the Python program (C/C++ programs generally run faster
than Python).

Extensive Libraries
Python has an extensive standard library that comes pre-installed. The standard library
has all the essential features for a modern day programming language. It has provisions
for databases, unit testing (we will explore this later in this book), regular expressions,
multi-threading, network programming, computer graphics, image processing, GUI, and
other utilities. This is the part of Python’s batteries-included philosophy.
Apart from the standard library, Python has numerous and ever-growing sets of
third-party libraries. The list of these libraries can be found on the Python Package Index.

Robust
Python provides robustness by means of the ability to handle errors. The full stack trace of
the encountered errors is available and makes the life of the programmer more bearable.
The runtime errors are known as exceptions. The feature that handles these errors is
known as an exception handling mechanism.

28
Chapter 2 ■ Introduction to Python and Digital Image Processing

Rapid Prototyping
Python is used as a rapid prototyping tool. As you learned earlier, Python has extensive
libraries and is easy to learn, which has led many software architects to use it as a tool to
rapidly prototype their ideas into working models quickly.

Memory Management
In assembly language and in programming languages like C and C++, memory
management is the responsibility of the programmer. This is in addition to the task at
hand. This creates an unnecessary burden on the programmer. In Python, the Python
interpreter takes care of the memory management. This helps the programmers steer
clear of memory issues and focus on the task at hand.

Powerful
Python has everything in it that a modern programming language needs. It is used in
applications such as computer visioning, supercomputing, drug discovery, scientific
computing, simulation, and bioinformatics. Millions of programmers around the world
use Python. Many big organizations like NASA, Google, SpaceX, and Cisco use Python for
their applications and infrastructure.

Community Support
I find this to be the most appealing feature of Python. Recall that Python is open source.
It also has community of almost a million programmers throughout the world (probably
more, as today high school kids are learning Python too). There are also plenty of forums
on the Internet to support programmers who encounter a roadblock. None of my queries
related to Python have ever gone unanswered.

Python 3
Python 3 was released in 2008. The Python development team decided to do away with
some of the redundant features of Python, simplify some more features, rectify some
design flaws, and add a few much needed features.
It was decided that a major revision number was needed for this and the resultant
release would not be backward compatible. Python 2.x and 3.x were supposed to coexist
in parallel for the programmer community to have enough time to migrate their code and
the third-party libraries from 2.x to 3.x. Python 2.x code cannot be run as-is in most cases,
as there are significant differences between 2.x and 3.x.

29
Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of The plums of
New York
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.

Title: The plums of New York

Author: U. P. Hedrick

Contributor: W. H. Alderman
Maxwell Jay Dorsey
O. M. Taylor
R. Wellington

Release date: January 21, 2024 [eBook #72770]

Language: English

Original publication: United States: J. B. Lyon Company, 1911

Credits: Steven Giacomelli, Mark C. Orton and the Online


Distributed Proofreading Team at
https://www.pgdp.net (This file was produced from
images produced by Core Historical Literature in
Agriculture (CHLA), Cornell University)

*** START OF THE PROJECT GUTENBERG EBOOK THE PLUMS OF


NEW YORK ***
WILLIAM ROBERT PRINCE

State of New York—Department of Agriculture


Eighteenth Annual Report—Vol. 3—Part II
THE
PLUMS OF NEW YORK
BY
U. P. HEDRICK
ASSISTED BY

R. WELLINGTON
O. M. TAYLOR
W. H. ALDERMAN
M. J. DORSEY

Report of the New York Agricultural Experiment Station for the Year 1910
II
ALBANY
J. B. LYON COMPANY, STATE PRINTERS
1911

NEW YORK AGRICULTURAL EXPERIMENT STATION,


Geneva, N. Y., December 31, 1910.
To the Honorable Board of Control of the New York Agricultural
Experiment Station:
Gentlemen:—I have the honor to transmit herewith Part II of the report
of this institution for the year 1910, to be known as The Plums of New
York. This constitutes the third in the series of fruit publications that is
being prepared under your authority.
The data embodied in the volume are the result of long-continued
studies and observations at this institution as well as throughout the
State, to which has been added a large amount of information that
commercial plum-growers have very kindly furnished. The attempt has
been made to produce a monograph including all the cultivated plums,
and it is hoped that the result will be recognized as a worthy advance in
the literature of this class of fruits.
W. H. JORDAN,
Director.
PREFACE
The Plums of New York is the third monograph of the fruits of this
region published by the New York Agricultural Experiment Station.
The aims of these books have been stated in full in The Grapes of
New York, but it is considered best to re-state some of these briefly
and to indicate some features in which the book on plums differs
from the one on grapes.
Broadly speaking, the aim has been to make The Plums of New
York a record of our present knowledge of cultivated plums. The
book has been written for New York but its contents are so general
in character that the work applies to the whole country and more or
less to the world. The first chapter is a historical account and a
botanical classification of plums; the second, a discussion of the
present status of plum-growing in America; while the third and
fourth are devoted to varieties of plums. The first and last two of
these chapters contain the synonymy and bibliography of the species
and varieties of plums. In the foot-notes running through the book
biographical sketches are given of the persons who have contributed
most to plum culture in America; here may be found also matters
pertaining to plums not properly included in the text but necessary
for its best understanding. Important varieties, so considered from
various standpoints, with the bark and the flowers of several species,
are illustrated in colors.
The Plums of New York is a horticultural and not a botanical work.
But in a study of the fruit from a horticultural standpoint one must of
necessity consider botanical relationships. It is hoped that in this
enforced systematic study of plums, however, something has been
added to the botanical knowledge of this fruit. In classifying the
varieties and species, to show their characters and relationships, the
author has chosen to dispose of the groups in accordance with his
own views though the arrangement adopted is, for most part,
scarcely more than a modification of existing classifications.
Attention must be called to the indefiniteness of species and
varieties of plums due chiefly to the extreme responsiveness of the
plants to environment. On each side of the specific or varietal types
there are wide ranges of variation. Since the relationships between
types are often very close it is impossible to avoid some confusion in
characters, for outliers of the types cannot but overlap. It might be
well said that these outliers are connecting links and that groups so
connected should be combined, but this would make specific division
of the genus and varietal division of the species almost impossible.
The groups must, therefore, be separated along more or less
arbitrary lines. But such arbitrary separation does not prevent
natural groups, if nature be broadly interpreted.
The chief value of the work in hand lies in its discussion of
varieties. In the descriptions the aim has been to give as tersely as
possible an idea of all of the characters of the plums described. With
very few exceptions the technical descriptions of varieties are
original and were made by those who have taken active part in the
preparation of this book. Nearly all of the varieties having full
descriptions grow on the Station grounds but whenever possible
specimens of each variety from different localities have been
compared with those growing here.
A special effort has been made to give as exactly as possible the
regions in which the species and varieties of plums grow. Such an
effort is made under the belief that this knowledge is of great value
in the study of the factors which govern the distribution of wild and
domesticated plants. If the boundaries of the regions in which a few
scores of varieties of the several fruits grow can be accurately
established valuable generalizations can be drawn regarding life
zones and plant distribution.
The reader should know what considerations have governed the
selection of varieties for color-plates and full descriptions. These are:
(1) The known value of the variety for the commercial or amateur
grower. (2) The probable value of new varieties. (3) To furnish data
for the plum-breeder; to show combinations of species or varieties,
or new characters, or the range in variation. (4) Some sorts have
been described because of historical value—to better show what the
trend of plum evolution has been. (5) To indicate the relationships of
species and varieties. The varieties are divided into three groups
according to their importance as gauged from the standpoints given
above.
In botanical nomenclature the code adopted by the American
botanists in Philadelphia in 1904 and modified by the International
Botanical Congress at Vienna in 1905, has been used. For
horticultural names, lacking a better code, the revised rules of the
American Pomological Society have been followed, though in a few
cases we have not seen fit to follow the rules of this society, as the
changes required by their strict observance would have brought
much confusion. Only those who have to work with a great number
of varieties of fruit can know the chaotic conditions of our
pomological nomenclature. One of the aims of the work in hand is to
set straight in some degree the great confusion in plum names.
All synonyms of varieties have been given so far as they could be
determined but it did not seem worth while to give all of the
references to be found even in standard plum literature. Fewer of
these are listed for the leading varieties than in the books on apples
or grapes which have preceded, only such being given as have been
found of use by the writers or thought of possible use to future plum
students. On the other hand some references have been given for all
varieties, a task not attempted in The Grapes of New York.
As in the preceding books the color-plates have been given much
attention. Work and expense have not been spared to make the
plates the best possible with the present knowledge of color-
printing. Yet the illustrations are not exact reproductions. The colors
are, at best, only approximations; for it is impossible by mechanical
processes to reproduce Nature’s delicate tints and shades. The
camera does not take colors as the human eye sees them; and the
maker of the copper plate can not quite reproduce all that the
camera has taken. The colors then depend on the judgment of the
printer, who by selecting and mingling colored inks, reproduces as
nearly as his materials permit, the shades in his eye and mind; but
no two persons see exactly the same colors in any object; so his
conception may differ much from that of the horticulturist or artist
who saw the original plum, as do theirs from each other. Still it is
hoped that the color-plates will be of great service in illustrating the
text. All of the plums from which the plates were made came from
the Station grounds; the illustrations, with a few exceptions which
are noted, are of life size, as grown under the conditions existing at
this place, and as far as possible all are from specimens of average
size and color.
Acknowledgments are due in particular to the plum-growers of
New York who have furnished much information for The Plums of
New York; to numerous institutions in all parts of the United States
who have loaned botanical specimens; to Professor Charles Sprague
Sargent for advice, information and the use of the Arnold Arboretum
library and herbarium; to W. F. Wight of the United States
Department of Agriculture, who has given most valuable assistance
in describing the species of plums and in giving their range; to the
Station Editor, F. H. Hall, who has had charge of the proof-reading;
to Zeese-Wilkinson and Company, New York City, for their care and
skill in making the color-plates; and to the J. B. Lyon Company,
Albany, New York, for their careful work in the mechanical
construction of the book.
U. P. HEDRICK,
Horticulturist, New York Agricultural Experiment Station.
TABLE OF CONTENTS
PAGE
Preface v
Index to Illustrations ix
Chapter I.—Edible Plums 1
Chapter II.—Plum Culture 100
Chapter III.—Leading Varieties of Plums 136
Chapter IV.—Minor Varieties of Plums 391
Bibliography, References and Abbreviations 573
Index 581
INDEX TO ILLUSTRATIONS
Portrait of William Robert Prince Frontispiece
FACING PAGE
Abundance 136
Agen 138
America 142
Ames 144
Apple 146
Arch Duke 148
Arctic 150
Arkansas 152
Autumn Compote 154
Bavay 156
Belle 158
Black Bullace 162
Bradshaw 166
Burbank 170
Chabot 172
Cheney 176
Climax 178
De Caradeuc 188
De Soto 190
Diamond 192
Downing 194
Drap d’Or 194
Duane 196
Englebert 204
Field 208
Forest Garden 210
Forest Rose 210
Freestone 212
French 214
Georgeson 218
German Prune 220
Giant 222
Golden 224
Golden Beauty 226
Golden Drop 228
Goliath 232
Grand Duke 234
Gueii 236
Hale 238
Hammer 238
Hand 240
Hawkeye 242
Hudson 244
Hungarian 246
Ickworth 248
Imperial Gage 252
Italian Prune 254
Jefferson 256
Juicy 258
Late Orleans 266
Lombard 268
Maquoketa 272
Marianna 274
McLaughlin 276
Middleburg 278
Monarch 286
Newman 292
New Ulm 294
October 298
Oren 300
Oullins 304
Pacific 306
Pearl 310
Peters 312
Pond 314
Pottawattamie 316
Prunus americana, Blossoms of 56
Prunus americana, Bark of 6
Prunus cerasifera, Blossoms of 46
Prunus cerasifera, Bark of 6
Prunus domestica, Blossoms of 12
Prunus domestica, Bark of 6
Prunus hortulana, Blossoms of 64
Prunus hortulana, Bark of 6
Prunus hortulana mineri, Blossoms of 68
Prunus hortulana mineri, Bark of 6
Prunus insititia, Blossoms of 34
Prunus insititia, Bark of 6
Prunus munsoniana, Blossoms of 88
Prunus munsoniana, Bark of 6
Prunus nigra, Blossoms of 70
Prunus nigra, Bark of 6
Prunus triflora, Blossoms of 50
Prunus triflora, Bark of 6
Quackenboss 320
Robinson 330
Satsuma 338
Shipper 342
Shiro 344
Shropshire 344
Smith Orleans 348
Spaulding 350
Sugar 354
Surprise 356
Tennant 358
Tragedy 360
Victoria 364
Voronesh 366
Washington 368
Wayland 370
White Bullace 374
Wickson 376
Wild Goose 378
Wolf 380
Wood 382
World Beater 384
Yellow Egg 386
THE PLUMS OF NEW YORK
CHAPTER I
EDIBLE PLUMS

THE GENUS PRUNUS


The great genus Prunus includes plums, cherries, almonds,
apricots, peaches, and the evergreen cherries or cherry laurels. Its
widely distributed species number a hundred or more for the world,
nearly all of which belong north of the equator. The species of the
genus are widely distributed in both the eastern and western
hemispheres, the flora of eastern America and of western Asia being
especially rich in species and individuals. For most part the species
of Prunus belong to the Temperate Zone, but several of the
evergreen cherries, usually grouped in a section under Laurocerasus,
are found in the tropics and sub-tropics.
The species cultivated for their edible fruits are found only in the
Temperate Zone of the Northern Hemisphere. Of these the peach
and the almond are believed to have come from eastern and
southeastern Asia; the apricot is thought to be a native of northern
China; the wild forms of the cultivated cherries are Eurasian plants,
very generally distributed in the regions to the northward where the
two continents meet. The habitats of the cultivated plums are given
in detail in the text that follows, as Asia, Europe and America.
Presumably the genus had its origin in some of the above regions;
but where the center is from which the species radiated can never
be known. Indeed, with present knowledge it cannot be said in what
region Prunus has most species, is most productive of individuals, or
shows highest development and greatest variability,—facts which
might give some evidence as to the origin of the genus. It is
probable that the greatest number of combinations of the above
evidences can be shown for Asia and more especially for the
Eurasian region, where Europe and Asia meet; yet North America
has two score or more indigenous species about half of which are
arborescent.
The history of the genus Prunus is one of continual changes. Of
the botanists who have done most toward classifying plants, Ray,
Tournefort, Dillenius and Boerhaave, pre-Linnaean botanists, placed
only the plum in Prunus. Linnaeus adopted the name used by his
predecessors for the plum alone, for a genus in which he also placed
plums and cherries. Adanson and Jussieu returned to the pre-
Linnaean classification but Gaertner followed the grouping of
Linnaeus. Necker, DeCandolle, Roemer and Decaisne held that the
plum alone belongs in Prunus. Bentham & Hooker, Gray and his co-
workers in the several revisions of his botany, and Engler & Prantl,
great authorities of the Nineteenth Century, extend the genus to
include all of the stone-fruits. On the other hand, Britton and Brown,
in their recent flora of northern United States and of Canada restrict
the group to plums and cherries. Horticulturists have been less
divided in their opinions than the botanists and have very generally
placed all of the stone-fruits in one genus. The diversity of views as
to what plants belong in Prunus, indicated above, suggests that the
differences separating the several stone-fruits may not be many nor
very distinct. This is true, and makes necessary a discussion of the
characters which distinguish these fruits.
The flowers of true plums are borne on stems in fascicled umbels
and appear either before the leaves or with or after them. Flowers of
the cultivated cherries are similarly borne, though the fascicles are
corymbose rather than umbelliferous. But apricot, peach and almond
flowers are stemless or nearly so and solitary or borne in pairs
appearing before the leaves.
The fruits of plums and cherries are globular or oblong, fleshy,
very juicy, with smooth or slightly hairy skins. Peaches, apricots and
almonds are more sulcate or grooved than plums and cherries and
the first two have juicy flesh, but that of the almond is dry and hard
or skin-like, splitting at maturity thereby liberating the stone; these
last three fruits are distinguished from plums and cherries by having
very pubescent or velvety skins though rarely, as in the nectarine, a
botanical variety of the peach, and in a few cultivated apricots, the
skins are smooth.
The stone of the plum is usually compressed, longer than broad,
smooth or roughened, thickish and with an acute margin along the
ventral suture and thinnish or grooved on the dorsal suture. The
stone of the cherry is usually globular, always much thickened,
smooth or a very little roughened, ridged and grooved on the ventral
suture, with a thin, scarcely raised sharp margin on the dorsal
suture. The stone of the apricot is similar to that of the plum though
thicker walled, with a more conspicuous winged margin, and is
sometimes pitted. The stone of the peach is compressed, usually
with very thick walls, much roughened and deeply pitted. In the
almond the stone resembles in general characters the peach-stone,
but all almond shells are more or less porous and often fibrous on
the inner surfaces. The stone is the part for which the almond is
cultivated and is most variable, the chief differences being that some
have thick hard shells and others thin soft shells.
The leaves of plums are convolute, or rolled up, in the bud.
Cherry, peach and almond leaves are conduplicate, that is are folded
lengthwise along the midrib in bud while the leaves of the apricot,
like those of the plum, are convolute. The manner in which the
leaves are packed in the bud is a fine mark of distinction in stone-
fruits. In size and shape of leaves, as well as in the finer marks of
these organs, the botanist and pomologist find much to aid in
distinguishing species and varieties but little that holds in separating
the sub-genera. The last statement holds true with the floral organs
also.
The near affinity of the stone-fruits is further shown by the fact
that plums and apricots, plums and cherries, and the several species
of each of the distinct fruits inter-hybridize without much difficulty. It
is a fact well-known that hybrids often surpass their parents in vigor
of plant and in productiveness and this has proved true with most of
the hybrids in Prunus of which we have accounts, thereby giving
promise of improved forms of these plants through hybridizing. The
great variation in wild and cultivated native plums is possibly due to
more or less remote hybridity.
Prunus is a most variable genus. This is indicated by the several
sub-genera, the large number of species and the various
arrangements of these groups by different authors. At their extremes
sub-genera and species are very distinct, but outside of the normal
types, and sometimes in several directions, there are often
outstanding forms which establish well-graded connections with
neighboring groups. For example, among the American plums there
are but few species between which and some other there are not
intermediate forms that make the two species difficult to distinguish
under some conditions. There is also a wide range of variation within
the species. The modifications within the species are oftentimes
such as to change greatly the aspect of the plant; the trees may be
dwarf or luxuriant, smooth or pubescent; may differ in branching
habit, in leaf-form, in size and color of the flowers, in the time of
opening of leaf and flower-buds, in color, shape, size, flesh, flavor
and time of ripening of fruit, in the stone and in all such characters
as climate and soil environment would be liable to modify.
This inherent variability is one of the strong assets of the genus as
a cultivated group of plants, for it allows not only a great number of
kinds of fruits and of species but a great number of varieties.
Besides, it gives to the genus great adaptiveness to cultural
environment, in accordance with climate, location, soil and the
handling of the trees. The cultivator is able to modify, too, the
characters of members of the genus to a high degree in the
production of new forms, but few, if any, groups of plants having
produced as many cultivated varieties as Prunus.
The genus Prunus is preeminent in horticulture, furnishing all of
the so-called stone-fruits, fruits which for variety, delicious flavor and
beauty of appearance, probably surpass those of any other genus,
and which, fresh or dried, are most valuable human foods. The
seeds of one of the fruits belonging to Prunus, the almond, are
commercially important, both for direct consumption and for the oil
which is pressed from them; in India a similar oil is obtained from
the seeds of peaches and apricots, while in Europe an oil from the
seeds of the Mahaleb cherry is used in making perfumes. Various
cordials are made from the fruits of the several species, as
kirschwasser and maraschino from cherries, zwetschenwasser and
raki from plums, and peach brandy from the peach; while fruits and
seeds of the several species are soaked in spirits for food, drink and
medicinal purposes. The bitter astringent bark and leaves are more
or less used in medicine as is also the gum secreted from the trunks
of nearly all the species and which, known as cerisin, is used in
various trades. The wood of all of the arborescent species is more or
less valuable for lumber, for cabinet-making and other domestic
purposes.
Prunus is prolific also in ornamental plants, having in common to
recommend them, rapidity of growth, ease of culture, comparative
freedom from pests, and great adaptability to soils and climates. The
plants of this genus are valued as ornamentals both for their flowers
and for their foliage. Many cultivated forms of several of the species
have single or double flowers, or variegated, colored or otherwise
abnormal leaves, while the genus is enlivened by the evergreen
foliage of the cherry laurels. Nearly all of the plants of Prunus are
spring-flowering but most of them are attractive later on in the
foliage and many of them are very ornamental in fruit.

PLUMS.
Of all the stone-fruits plums furnish the greatest diversity of kinds.
Varieties to the number of two thousand, from fifteen species, are
now or have been under cultivation. These varieties give a greater
range of flavor, aroma, texture, color, form and size, the qualities
which gratify the senses and make fruits desirable, than any other of
our orchard fruits. The trees, too, are diverse in structure, some of
the plums being shrub-like plants with slender branches, while
others are true trees with stout trunks and sturdy branches; some
species have thin, delicate leaves and others coarse, heavy foliage.
In geographical distribution both the wild and the cultivated plum
encircle the globe in the North Temperate Zone, and the cultivated
varieties are common inhabitants of the southern temperate region,
the various plums being adapted to great differences in temperature,
moisture and soil in the two zones.
The great variety of plums and the variability of the kinds,
seemingly plastic in all characters, the general distribution of the
fruit throughout the zone in which is carried on the greatest part of
the world’s agriculture, and the adaptation of the several species and
the many varieties, to topographical, soil and climatic changes, make
this fruit not only one of much present importance but also one of
great capacity for further development. Of the plums of the Old
World the Domesticas, Insititias and probably the Trifloras have been
cultivated for two thousand years or more, while the work of
domesticating the wild species of America was only begun in the
middle of the last century. There are about fifteen hundred varieties
of the Old World plums listed in this work, and since the New World
plums are quite as variable, as great a variety or greater, since there
are more species, may be expected in America.
An attempt is made in The Plums of New York to review the plum
flora of this continent, but the species considered fall far short of
being all of the promising indigenous plums; not only are there more
to be described, but it is probable that species here described will in
some cases be sub-divided. The development of the pomological
plum-wealth of North America is but begun. Not nearly as much has
been done to develop the possibilities of the European plums in
America as in the case of the other tree-fruits. Probably a greater
percentage of the varieties of Old World plums commonly cultivated
came from across the sea, than of the varieties of any other of the
orchard-fruits which have been introduced. Much remains to be done
in securing greater adaptability of foreign plums to American
conditions. Native and foreign plums are also being hybridized with
very great advantage to pomology.
The Plums of New York is written largely with the aim of furthering
the development of plums in America, the possibilities of which are
indicated in the preceding paragraph. With this end in view the first
task is to name and discuss briefly the characters of plums whereby
species and varieties are distinguished, with a statement, so far as
present knowledge permits, of the variability of the different
characters. It is absolutely essential that the plum-grower have
knowledge, especially if he aspires to improve the fruit by breeding,
of the characters of the plants with which he is to work. These are in
the main as follows:
All species and some horticultural varieties have more or less
characteristic trees. Making due allowance for environment—food,
moisture and light—many plum groups can be readily distinguished
by the general aspect of the plant. Of the gross characters of trees,
size is usually most characteristic. A species, for example, is either
shrubby or tree-like. Yet under varying environment, size of plant
and of the parts of the plant, are probably the first to change. Habit
of growth is nearly as important as size and varies but little under
changing conditions. A species or variety may be upright, spreading,
drooping or round-topped in growth; head open or dense; the tree
rapid or slow-growing. Hardiness is a very important diagnostic
character, plums being either hardy, half-hardy or tender. Both
species and varieties respond in high degree to the test of hardiness,
the range for varieties, of course, falling within that of the species.
Productiveness, regularity of bearing, susceptibility to diseases and
insects, and longevity of tree are all characters having value for
species and varieties and with the exception of the first named, are
little subject to variation.
The thickness, smoothness, color and manner of exfoliation of the
outer bark and the color of the inner bark have considerable value in
determining species but are little used in determining horticultural
groups. It is well recognized that all plums have lighter colored bark
in the South than in the North. The branches are very characteristic
in several species. The length, thickness and rigidity of the branch
and the length of its internodes should be considered, while the
direction of the branch, whether straight or zigzag, are very valuable
determining characters and relatively stable ones, seeming to
change for most part only through long ranges of climatic conditions.
So, too, the arming of a branch with spines or spurs and the
structure of such organs are important. The color, smoothness,
amount of pubescence, direction, length, thickness and the
appearance of the lenticels, the presence of excrescences on the
branchlets of the first and second year’s growth and the branching
angle, are all worthy of consideration though quite too much has
been made of these characters, especially of pubescence, in
determining species, for they are all extremely variable.
1. P. HORTULANA MINERI 2. P. AMERICANA 3. P. CERASIFERA
4. P. DOMESTICA 5. P. INSITITIA 6. P. HORTULANA
7. P. MUNSONIANA 8. P. NIGRA 9. P. TRIFLORA
The size, shape and color of leaf-buds and of their outer and inner
scales and the margins of the scales differ in different species.
Possibly the most evident, and therefore readiest means of
identifying species, at least, is by the leaves. It is true that leaves
are very variable but always within limits, and either individually or
collectively in giving the general aspect to a tree they are
characteristic. Modifications of leaves most often occur in very young
plants, those growing in bright sunshine or deep shade and on
sprouts or suckers, but none of these are usually sufficient to
mislead as to species. Leaf-size and leaf-form are the first characters
to be noted in determining a plum but these are closely followed in
value by leaf-color, leaf-surface, leaf-thickness and leaf-margin. Leaf-
size is variable, depending much upon the conditions noted above
but leaf-form varies but little in the several species. So, too, the color
of leaves is very constant throughout a species, for both surfaces,
though impossible to describe accurately in words and very difficult
to reproduce in color-printing. There is a marked difference in
autumnal tints not only of species but of varieties but these are not
very constant in any one location and must vary greatly under
different environments. The thickness of the leaves of the several
species is a distinctive character. Species of plums have very
different leaf-surfaces as regards reticulation, rugoseness,
pubescence and coriaceousness, all of these characters being quite
constant, though it is to be noted that roughness of leaves and
pubescence are increased by exposure to the sun and by the
influence of some soils. There is, indeed, considerable variation in
the pubescence of the leaves of all species of plums in different
parts of the country and probably too much has been made of
pubescence as a determining character.
The margins of leaves are very characteristic of species and
scarcely vary under normal conditions if the teeth at the middle of
the sides be taken rather than those toward the base or apex, these
very often being crowded, reduced or wanting. The presence of
glands, their position, size, shape and color, help to characterize
several species and seem to be fairly constant guides. Some species
and a great number of varieties have the distinguishing marks of
gland-like prickles tipping the serrations in the leaf-margins. Length,
thickness, rigidity and pubescence of petiole have some taxonomic
value. Stipules usually offer no distinguishing marks other than those
mentioned under leaves.
The blossoms of plums are very characteristic, giving in flowering
time a distinctive aspect to all species and distinguishing some
horticultural varieties. The flowers of all the species are borne in
clusters, differing in number of individuals, according to the species;
so, too, the flowers in the different species vary in size, color, in
length of their peduncles, and in pubescence, especially of the calyx.
Flower-characters are constant, taking them as a whole, yet there
are some variations that must be noted. One of the most marked of
these is in the time of appearance of the flowers; in the South they
appear before the leaves but in the North with the leaves. On the
grounds of this Station there are notable exceptions to the latter
statement, with varieties of species showing considerable variation in
this regard. There are some remarkable variations within species as
regards size and color of the corolla and glands and pubescence of
the calyx, depending upon the environment of the plant; but on the
whole these characters are very constant. The fragrance of the
flowers of plums varies from a delicate, agreeable odor to one that is
quite disagreeable in some species as in Americana; the odor seems
to be a constant character.
Of all structures of the plum the fruit is most variable, yet fruits
are sufficiently distinct and constant, especially within species, to
make their characters very valuable in classification. Species,
whether wild or cultivated, may be distinguished in greater or less
degree by the period of ripening of the fruits, though in this regard
the cultivated varieties of the several species vary greatly and in the
wild state trees of native plums in the same locality, even in the
same clump, may vary in ripening as much as from two to four
weeks. Species are distinguished by size, shape, color, flesh, flavor
and pit among the grosser characters of the structure and by
amount of bloom, stem, cavity, apex, suture and skin among the
minor characters. The fruit is usually the first part of the plant to
respond to changed conditions.
Characters derived from seed structures are generally accounted
of much value by botanists in determining species. Such is the case
with plums. This Station has a collection of stones of over three
hundred cultivated varieties of plums and some specimens of nearly
all the different species. The stones illustrated in the color-plates in
this book show that this structure is quite variable in size, shape, in
the ends, surfaces, grooves and ridges, even within a species;
nevertheless in describing the several hundred forms of plums for
The Plums of New York the stone has been quite as satisfactory, if
not the most satisfactory, of any of the organs of this plant for
distinguishing the various species and varieties.
The reproductive organs of plums afford several characters and
would seem to offer means of distinguishing botanical and
horticultural groups, but they are so variable in both cultivated and
wild plants as to be very misleading. Not only do these organs differ
very often in structure but also in ability to perform their functions.
Bailey[1] has called attention to the remarkable self-sterility of some
varieties of the native species of plums, due to the impotency of the
pollen upon flowers of the same variety. C. W. H. Heideman[2] made
some very interesting observations on what he considers distinct
forms of the flowers of the Americana plums, describing for this
species all of the six possible variations of flowers enumerated by
Darwin in his Different Forms of Flowers in Plants of the Same
Species. Heideman thinks that other species of Prunus exhibit similar
variations. Waugh[3] made the pollination of plums a subject of
careful and extended study and found much variation in the pistils of
plants of the same species, insufficient pollen in some plants, pollen
impotent on the stigma of the same flower, and considerable
difference in the time of maturity of pollen and stigma in some
plums, especially the Americana plums. These variations, most
important to the plum-grower, are of more or less use in identifying
plums.
After the discussion of the characters of plums we may pass to a
detailed description and discussion of the species of plums which
now contribute or may contribute cultivated forms to the pomology
of the country either for their fruits or as stocks upon which to grow
other plums. The following conspectus shows as well as may be the
relations of the species of plums to each other.

CONSPECTUS OF SPECIES OF PLUMS.

A. Flowers in clusters of 1 or 2. (Three in


P. triflora.) Old World plums.
B. Leaves drooping.
C. Shoots and pedicels pubescent.
D. Flowers mostly in twos.
E. Fruits large, more than 1 inch
in diameter, variable in
shape, often compressed;
tree large; stamens about
30. 1. P. domestica.
E.E. Fruit small, less than 1 inch
in diameter, uniformly oval or
ovoid; stamens about 25;
tree small, compact. 2. P. insititia.
D.D. Flowers mostly single.
E. Leaves small, less than 2
inches in length; sometimes
a tree; very thorny 3. P. spinosa.
E.E. Leaves large, more than 2½
inches in length; a shrub;
thorns few 4. P. curdica.
C.C. Shoots glabrous or soon
becoming so, pedicels glabrous.
D. Pedicels shorter than the calyx- 5. P. cocomilia.
cup; leaves glabrous or
sparsely pubescent on the
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