Instant Access to (Ebook) Deep Learning for Remote Sensing Images with Open Source Software by Rémi Cresson ISBN 9780367858483, 9781000093599, 9781000093605, 9781000093612, 9781003020851, 0367858487, 100009359X, 1000093603, 1000093611 ebook Full Chapters
Instant Access to (Ebook) Deep Learning for Remote Sensing Images with Open Source Software by Rémi Cresson ISBN 9780367858483, 9781000093599, 9781000093605, 9781000093612, 9781003020851, 0367858487, 100009359X, 1000093603, 1000093611 ebook Full Chapters
Instant Access to (Ebook) Deep Learning for Remote Sensing Images with Open Source Software by Rémi Cresson ISBN 9780367858483, 9781000093599, 9781000093605, 9781000093612, 9781003020851, 0367858487, 100009359X, 1000093603, 1000093611 ebook Full Chapters
com
DOWLOAD EBOOK
ebooknice.com
ebooknice.com
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
ebooknice.com
(Ebook) Cambridge IGCSE and O Level History Workbook 2C -
Depth Study: the United States, 1919-41 2nd Edition by
Benjamin Harrison ISBN 9781398375147, 9781398375048,
1398375144, 1398375047
https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044
ebooknice.com
ebooknice.com
https://ebooknice.com/product/gimp-2-6-for-photographers-image-
editing-with-open-source-software-2223832
ebooknice.com
ebooknice.com
https://ebooknice.com/product/on-board-processing-for-satellite-
remote-sensing-images-49191128
ebooknice.com
Deep Learning for
Remote Sensing
Images with Open
Source Software
Signal and Image Processing of
Earth Observations Series
Series Editor
C.H. Chen
Published Titles
Deep Learning for Remote Sensing Images with Open Source Software
Rémi Cresson
Rémi Cresson
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Rea-
sonable efforts have been made to publish reliable data and information, but the author
and publisher cannot assume responsibility for the validity of all materials or the conse-
quences of their use. The authors and publishers have attempted to trace the copyright
holders of all material reproduced in this publication and apologize to copyright holders if
permission to publish in this form has not been obtained. If any copyright material has not
been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted,
reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other
means, now known or hereafter invented, including photocopying, microfilming, and record-
ing, or in any information storage or retrieval system, without written permission from the
publishers.
For permission to photocopy or use material electronically from this work, please access
www.copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Cen-
ter, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-
for-profit organization that provides licenses and registration for a variety of users. For
organizations that have been granted a photocopy license by the CCC, a separate system
of payment has been arranged.
Preface ix
Author xi
I Backgrounds 1
1 Deep learning background 3
1.1 What is deep learning? . . . . . . . . . . . . . . . . . . . . . 3
1.2 Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Pooling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4 Activation functions . . . . . . . . . . . . . . . . . . . . . . . 7
1.5 Challenges ahead for deep learning with remote sensing images 8
2 Software 9
2.1 Orfeo ToolBox . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Applications . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.2 Streaming mechanism . . . . . . . . . . . . . . . . . . 10
2.1.3 Remote modules . . . . . . . . . . . . . . . . . . . . . 10
2.1.4 The Python API . . . . . . . . . . . . . . . . . . . . . 10
2.2 TensorFlow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.2 Computations . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.3 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Orfeo ToolBox + TensorFlow = OTBTF . . . . . . . . . . . 12
2.3.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . 13
2.3.2 Featured applications . . . . . . . . . . . . . . . . . . 14
2.3.3 Principle . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3.4 Multiple input sources and outputs . . . . . . . . . . . 16
2.4 QGIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
II Patch-based classification 19
3 Introduction 21
v
vi Contents
9 Discussion 65
Contents vii
12 Mapping buildings 83
12.1 Input data pre-processing . . . . . . . . . . . . . . . . . . . . 83
12.1.1 Satellite image pansharpening . . . . . . . . . . . . . . 83
12.1.2 Image normalization . . . . . . . . . . . . . . . . . . . 84
12.1.3 Sample selection . . . . . . . . . . . . . . . . . . . . . 84
12.1.3.1 Patch position seeding . . . . . . . . . . . . . 84
12.1.3.2 Patch position selection . . . . . . . . . . . . 86
12.1.3.3 Patches split . . . . . . . . . . . . . . . . . . 87
12.1.4 Rasterization . . . . . . . . . . . . . . . . . . . . . . . 88
12.1.5 Patch extraction . . . . . . . . . . . . . . . . . . . . . 89
12.2 Building the model . . . . . . . . . . . . . . . . . . . . . . . 90
12.2.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . 91
12.2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . 92
12.2.2.1 Exact output . . . . . . . . . . . . . . . . . . 94
12.2.2.2 Expression field . . . . . . . . . . . . . . . . 95
12.2.3 Generate the SavedModel . . . . . . . . . . . . . . . . 95
12.3 Training the model . . . . . . . . . . . . . . . . . . . . . . . 96
12.4 Inference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
13 Discussion 99
16 Pre-processing 115
16.1 Sentinel images . . . . . . . . . . . . . . . . . . . . . . . . . 115
16.1.1 Optical images . . . . . . . . . . . . . . . . . . . . . . 115
16.1.2 SAR image . . . . . . . . . . . . . . . . . . . . . . . . 117
16.1.2.1 Calibration . . . . . . . . . . . . . . . . . . . 117
16.1.2.2 Filtering values . . . . . . . . . . . . . . . . . 118
16.1.2.3 Linear stretch . . . . . . . . . . . . . . . . . 118
16.1.2.4 Spatial resampling . . . . . . . . . . . . . . . 118
16.2 Patches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
16.2.1 Patch position seeding . . . . . . . . . . . . . . . . . . 119
16.2.1.1 Sentinel-2 image masks . . . . . . . . . . . . 119
16.2.1.2 Merge masks . . . . . . . . . . . . . . . . . . 122
16.2.1.3 Grid generation . . . . . . . . . . . . . . . . 123
16.2.1.4 Grid filtering . . . . . . . . . . . . . . . . . . 124
16.2.1.5 Patch centroids . . . . . . . . . . . . . . . . . 126
16.2.1.6 Training and validation datasets . . . . . . . 126
16.2.2 Extraction of patches . . . . . . . . . . . . . . . . . . 127
16.3 More: automate steps with the OTB Python API . . . . . . 128
16.3.1 Build the pipeline . . . . . . . . . . . . . . . . . . . . 129
16.3.2 Run the pipeline . . . . . . . . . . . . . . . . . . . . . 132
18 Inference 137
18.1 Inputs and outputs . . . . . . . . . . . . . . . . . . . . . . . 137
18.2 Generating the image . . . . . . . . . . . . . . . . . . . . . . 137
18.3 Postprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . 139
19 Discussion 143
Bibliography 145
Index 149
Preface
The volume of earth observation data has increased in recent years, and more
and more remote sensing imagery is available today. On one hand, the amount
of remote sensing data is constantly growing due to the rise of very-high-
resolution sensors and short repeat cycle satellites. Thanks to programs like
Landsat or Sentinel, many free imagery products are available. In addition,
community-based geographic information gathering systems are expanding
each in existing geospatial data bases: the OpenStreetMap initiative is a well-
known example. Regarding this amount of geospatial data, tackling complexity
in earth observation information extraction is rising as a major and exciting
challenge.
Deep learning is a growing trend in big data analysis, and had a break-
through impact in the last few years on such diverse domains as image analysis,
speech recognition, autonomous cars, or the arts. Convolutional Neural Net-
works are designed to extract features in images, enabling image recognition,
object detection, and semantic segmentation. Recurrent Neural Networks are
suited for sequential data analysis, such as speech recognition and action recog-
nition tasks. As for numerous fields, the deep learning revolution has impacted
the remote sensing sector. In recent years, a number of studies have shown
that remote sensing benefits strongly from these new approaches, thanks to the
availability of data and computing resources. Deep learning allows researchers
and engineers in remote sensing to move beyond usual approaches and tackle
a number of problems with solid results. Various remote sensing problems
have been successfully addressed with deep learning: classification, segmen-
tation, object detection, image restoration, image enhancement, etc. Deep
learning has proven to be pertinent in many kinds of remote sensing imagery:
synthetic aperture radar, hyperspectral imagery, very-high-resolution images,
time series, etc.
A lot of the literature explains deep learning theory, but this book rather
focuses on its technical application on satellite imagery. The core of this work
teaches how to apply deep learning techniques to real-world remote sensing
images using existing, open-source tools like QGIS, TensorFlow and Orfeo
ToolBox. The generation of land cover maps from large satellite images will
be the central topic. However, perspectives of applying deep learning to various
earth observation sensors for a number of purposes are open, and we will show
that deep learning applies not only to image classification, but also to image
restoration from multimodal imagery.
ix
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
x Preface
After a short summary of deep learning background, the book will intro-
duce the common steps to extract samples from remote sensing images, create
and train deep networks, and use them to generate output images, e.g. land
cover maps. Various approaches and deep network architectures will be intro-
duced in different parts of the book. For each of them, all steps enabling
the reader to perform the processing of data will be detailed. We provide an
online repository containing the ancillary data and sharing code snippets used
in the exercises. The software involved in this tutorial are open-source, and
instructions to install them are provided.
Author
xi
Part I
Backgrounds
1
Deep learning background
In this section, we provide the essential principles of deep learning. After read-
ing this chapter, one should have the required theoretical basis to understand
what is involved in processing geospatial data in the rest of the book.
3
4 Deep learning background
FIGURE 1.1
Example of a network of artificial neurons aggregated into layers. In the arti-
ficial neuron: xi is the input, y is the neuron output, ai are the values for the
gains, b is the offset value, and f is the activation function.
1.2 Convolution
Equation 1.2 shows how the result Y of a convolution with kernel K on input
X is computed in dimension two (x and y are pixel coordinates). In this
equation, Y and K are 2-dimensional matrices of real-valued numbers.
XX
Y (x, y) = (X ∗ K)(x, y) = X(x − i, y − j) × K(i, j) (1.2)
i j
XX
Y (x, y) = (X ∗ K)(x, y) = X(x × sx − i, y × sy − j) × K(i, j) (1.3)
i j
FIGURE 1.2
Left: no padding, stride=2, Center: padding, stride=2, Right: padding,
stride=1. The output is the upside, white matrix, and the input is the blue
matrix at the bottom. The output size depends on the following parameters of
the convolution: padding, kernel size, and stride. The output physical spac-
ing is changed accordingly to the stride in the convolution: n strides ensure
that physical spacing is scaled by n.
Important note
1.3 Pooling
Another important concept of CNNs is pooling, which is a form of non-linear
downsampling. Several non-linear functions can be implemented in pooling
operations, among which max pooling is the most common: it partitions the
input image and for each sub-region, outputs the maximum ref to figure 1.3.
The intuition is that the exact location of a feature is less important than
its rough location relative to other features. The pooling layer aims to pro-
gressively reduce the spatial size of the representation, to reduce the number
of parameters and amount of computation in the network, and hence to also
control overfitting. It is common to periodically insert a pooling layer between
successive convolutional layers in a CNN architecture. The pooling operation
Activation functions 7
FIGURE 1.3
2 × 2 max pooling with stride 2. Each 2 × 2 sub-region of the image, the
maximum value is kept.
Important note
Pooling, and convolutions with stride, can be viewed as a subsampling
process, which does modify the output size, and the output physical spac-
ing. Depending on the implementation, it can also keep partially sampled
items at borders.
3. Sigmoid:
1
f (x) =
1 + e−x
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
8 Deep learning background
ex − e−x
f (x) =
ex + e−x
Software is a crucial point in both remote sensing and deep learning. This
section introduces the open source software involved in the practice sessions
of the book.
FIGURE 2.1
The Orfeo ToolBox.
1 https://www.orfeo-toolbox.org/
2 https://itk.org/
3 https://gdal.org/
9
10 Software
2.1.1 Applications
The Orfeo ToolBox applications aim to provide users a number of implemented
algorithms. These applications can be used directly through multiple interfaces
like command line, graphical user interface, and third-party software like QGIS
for instance. For developers, applications can also be used from Python and
C++ APIs. Each OTB application comes with a set of parameters. Parameters
used in OTB applications are typed (images, vector data, file, folder, integer,
floating, etc.) and this formalism makes the OTB applications usable through
all interfaces and APIs.
We invite curious readers who want to exploit the full potential of the tool-
box using the Python API, to read the official documentation along with
the available tutorials online. Additional help can be obtained from the users
community on the dedicated forum from the Orfeo ToolBox website.4
2.2 TensorFlow
TensorFlow is the high-performance numerical computation library for train-
ing and inference on deep neural networks [17], initiated by Google. It has
become a popular open source deep learning framework, with a large world-
wide growing community of developers ref to figure 2.2.
FIGURE 2.2
The TensorFlow library.
2.2.1 APIs
TensorFlow has a powerful high-level Python API to build deep nets. Cur-
rently, TensorFlow uses Keras which allows you to build networks from a
higher implementation level. TensorFlow also has a simple yet powerful C++
API to integrate deep nets in C++ projects.
2.2.2 Computations
TensorFlow uses symbolic programming that distinguishes definitions of com-
putations from their proper execution. In TensorFlow, tensors are abstraction
objects of the operations and values in the memory, simplifying manipula-
tion regardless of the computing environment: for instance, Central Process-
ing Unit (CPU) or Graphical Processing Unit (GPU). In TensorFlow, the
so-called model consists of operations arranged into a graph of nodes. Each
node is an operation taking zero or more tensors as inputs, and producing one
or multiple tensors. This data flow graph defines the operations (e.g. linear
4 forum.orfeo-toolbox.org
12 Software
algebra operators), and the actual computations are performed in the Tensor-
Flow session.
2.2.3 Graphs
The Python API enables the construction of TensorFlow graphs, and the
session runs the graph, delegating calculations to low level, highly optimized
routines. Among tensors, we can distinguish concepts such as Placeholders,
Constants and Variables. A Placeholder is a symbol hosting input data, e.g.
a set of images. As its name indicates, Constants are tensors with constant
values, and Variables hold non-persistent values, e.g. parameters to estimate
during training. Variables must be explicitly initialized, and can be saved or
restored during a session along with the graph.
4. Deep learning experts can still use their coding skills to build/train
their models using their favorite API (e.g. Python) and use the
SavedModel in OTBTF to produce their resulting geospatial
images.
2.3.1 Installation
Still, the OTBTF remote module is not currently integrated in the official
OTB release. Currently, there are several ways to install it:
• Use the ready-to-use environment in the provided VirtualBox instance. The
only required software for this tutorial is the Oracle VirtualBox software,
that can be freely downloaded online.5 It is the easiest option if you want to
give a try. However, please note that this is not optimized for performance.
You can contact the author to request the download of the virtual machine.
• Download the official OTBTF Docker image on DockerHub.6 This option
is great for Linux and Mac users since Docker efficiently uses computer
resources. If you have an NVIDIA GPU you can choose the Docker image
supporting the NVIDIA runtime.
• Compile OTBTF from the source. For this, please follow the instructions
provided on the OTBTF GitHub repository. This is the difficult way, but
you will be able to build the software with the appropriate optimization
flags for your hardware.
If any problems are encountered during the installation, we refer the reader
to the up-to-date troubleshooting section of the OTBTF repository. Further
questions can also be asked on the Orfeo ToolBox forum7 and tickets opened
on the OTBTF GitHub repository.
Recommendations
We strongly advise Linux and Mac users to use Docker images for better
performance. Another important point is the hardware: Graphical Pro-
cessing Units (GPUs) drastically speed up the processes in deep learn-
ing. In particular, for chapter 14 we recommend using a GPU to run
the model training. The OTBTF Docker image supporting nvidia-Docker
provided in the OTBTF GitHub repository simplifies greatly the use of
5 www.virtualbox.org
6 https://hub.docker.com/u/mdl4eo
7 forum.orfeo-toolbox.org
14 Software
2.3.3 Principle
As explained in section 2.2, TensorFlow provides APIs to allow developers
to easily build deep nets. Once a deep net is built, it can be exported as a
SavedModel ,8 serialized as a Google Protobuf (language-neutral, platform-
neutral, extensible mechanism for serializing structured data). This Saved-
Model includes the processing graph, and the variables of the model. It can
then be used in the new OTB applications provided by the OTBTF remote
module. OTBTF implements mechanisms to convert images into tensors that
can feed the TensorFlow models, execute the model, and convert back the
resulting tensors of the model into output images. Thanks to the streaming
mechanism of OTB, there is no limitation on processed image size. A Tensor-
Flow model is associated with its following intrinsic parameters, that must be
given to OTBTF:
1. The receptive field: as explained in section 1, the receptive field
is the input volume that the model “sees” in the input space.
2. The expression field: it describes the volume that the model
“creates” in the output space.
3. Scale factor: the scale factor describes the physical spacing change
between one reference input (typically, the first input) and the out-
put space. For instance, we consider a CNN that transforms a single
8 www.tensorflow.org/guide/saved model
Orfeo ToolBox + TensorFlow = OTBTF 15
FIGURE 2.3
Deep net parameters. The figure shows the incidence of two deep net parame-
ters on region propagation and output image information. The two nets have
the same Expression Field and Receptive field, but a different Scale Factor
parameter (Fscale = 1 for the net on top, Fscale = 2 for the net on bottom).
The application computes regions of images that are aligned to the expres-
sion field, i.e. image regions which have a start index and a size that are a
multiple of the expression field. When a requested output region lies across
multiple aligned sub-regions, the TensorFlow model is run over the largest
aligned region, and only the requested part is then kept (figure 2.4). This
mechanism avoids blocking artifacts and ensures that the output is indepen-
dent of the tiling layout used by the streaming manager, i.e. (i) seamless, if
allowed by the model, and (ii) reproducible.
16 Software
FIGURE 2.4
Computed regions alignment. To guarantee that the output is seamless and
reproducible, the requested region is computed from the region which is
included in the larger region aligned to the grid formed by the expression
field of the net.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com