Dimension reduction is a statistical process, which concentrates the amount of information in multivariate
data into a fewer number of variables (or dimensions). An interesting review of the domain has been done
by Fodor [?].

Though there are plenty of non-linear methods in the litterature, OTB provides only linear dimension
reduction techniques applied to images for now.

Usually, linear dimension-reduction algorithms try to find a set of linear combinations of the input image
bands that maximise a given criterion, often chosen so that image information concentrates on the first
components. Algorithms differs by the criterion to optimise and also by their handling of the signal or
image noise.

In remote-sensing images processing, dimension reduction algorithms are of great interest for denoising, or
as a preliminary processing for classification of feature images or unmixing of hyperspectral images. In
addition to the denoising effect, the advantage of dimension reduction in the two latter is that it lowers the
size of the data to be analysed, and as such, speeds up the processing time without too much loss of
accuracy.

The source code for this example can be found in the fileExamples/DimensionReduction/PCAExample.cxx.

This example illustrates the use of the otb::PCAImageFilter . This filter computes a Principal
Component Analysis using an efficient method based on the inner product in order to compute the
covariance matrix.

The first step required to use this filter is to include its header file.

#include"otbPCAImageFilter.h"

We start by defining the types for the images and the reader and the writer. We choose to work with a
otb::VectorImage , since we will produce a multi-channel image (the principal components) from a
multi-channel input image.

We define the type for the filter. It is templated over the input and the output image types and also the
transformation direction. The internal structure of this filter is a filter-to-filter like structure. We can now the
instantiate the filter.

The only parameter needed for the PCA is the number of principal components required as output. Principal
components are linear combination of input components (here the input image bands), which are selected
using Singular Value Decomposition eigen vectors sorted by eigen value. We can choose to get less
Principal Components than the number of input bands.

Figure 18.1 shows the result of applying forward and reverse PCA transformation to a 8 bands Worldview2
image.

Figure 18.1: Result of applying the otb::PCAImageFilterto an image. From left to right: original image,color composition with first three principal components and output of the inverse mode (the input RGB image).

The source code for this example can be found in the fileExamples/DimensionReduction/NAPCAExample.cxx.

This example illustrates the use of the otb::NAPCAImageFilter . This filter computes a Noise-Adjusted
Principal Component Analysis transform [?] using an efficient method based on the inner product in order
to compute the covariance matrix.

The Noise-Adjusted Principal Component Analysis transform is a sequence of two Principal Component
Analysis transforms. The first transform is based on an estimated covariance matrix of the noise,
and intends to whiten the input image (noise with unit variance and no correlation between
bands).

The second Principal Component Analysis is then applied to the noise-whitened image, giving the
Maximum Noise Fraction transform. Applying PCA on noise-whitened image consists in ranking Principal
Components according to signal to noise ratio.

It is basically a reformulation of the Maximum Noise Fraction algorithm.

The first step required to use this filter is to include its header file.

#include"otbNAPCAImageFilter.h"

We also need to include the header of the noise filter.

#include"otbLocalActivityVectorImageFilter.h"

We start by defining the types for the images, the reader and the writer. We choose to work with a
otb::VectorImage , since we will produce a multi-channel image (the principal components) from a
multi-channel input image.

In contrast with standard Principal Component Analysis, NA-PCA needs an estimation of the noise
correlation matrix in the dataset prior to transformation.

A classical approach is to use spatial gradient images and infer the noise correlation matrix from it. The
method of noise estimation can be customized by templating the otb::NAPCAImageFilter with the
desired noise estimation method.

In this implementation, noise is estimated from a local window. We define the type of the noise
filter.

We define the type for the filter. It is templated over the input and the output image types, the noise
estimation filter type, and also the transformation direction. The internal structure of this filter is a
filter-to-filter like structure. We can now the instantiate the filter.

otb::NAPCAImageFilter allows also to compute inverse transformation from NA-PCA coefficients. In
reverse mode, the covariance matrix or the transformation matrix (which may not be square) has to be
given.

Figure 18.2 shows the result of applying forward and reverse NA-PCA transformation to a 8 bands
Worldview2 image.

Figure 18.2: Result of applying the otb::NAPCAImageFilterto an image. From left to right: original image,color composition with first three principal components and output of the inverse mode (the input RGB image).

The source code for this example can be found in the fileExamples/DimensionReduction/MNFExample.cxx.

This example illustrates the use of the otb::MNFImageFilter . This filter computes a Maximum Noise
Fraction transform [?] using an efficient method based on the inner product in order to compute the
covariance matrix.

The Maximum Noise Fraction transform is a sequence of two Principal Component Analysis transforms.
The first transform is based on an estimated covariance matrix of the noise, and intends to whiten the input
image (noise with unit variance and no correlation between bands).

The second Principal Component Analysis is then applied to the noise-whitened image, giving the
Maximum Noise Fraction transform.

In this implementation, noise is estimated from a local window.

The first step required to use this filter is to include its header file.

#include"otbMNFImageFilter.h"

We also need to include the header of the noise filter.

#include"otbLocalActivityVectorImageFilter.h"

We start by defining the types for the images, the reader, and the writer. We choose to work with a
otb::VectorImage , since we will produce a multi-channel image (the principal components) from a
multi-channel input image.

In contrast with standard Principal Component Analysis, MNF needs an estimation of the noise correlation
matrix in the dataset prior to transformation.

A classical approach is to use spatial gradient images and infer the noise correlation matrix from it. The
method of noise estimation can be customized by templating the otb::MNFImageFilter with the desired
noise estimation method.

In this implementation, noise is estimated from a local window. We define the type of the noise
filter.

We define the type for the filter. It is templated over the input and the output image types and also the
transformation direction. The internal structure of this filter is a filter-to-filter like structure. We can now the
instantiate the filter.

Figure 18.3 shows the result of applying forward and reverse MNF transformation to a 8 bands Worldview2
image.

Figure 18.3: Result of applying the otb::MNFImageFilterto an image. From left to right: original image,color composition with first three principal components and output of the inverse mode (the input RGB image).

The source code for this example can be found in the fileExamples/DimensionReduction/ICAExample.cxx.

This example illustrates the use of the otb::FastICAImageFilter . This filter computes a Fast
Independent Components Analysis transform.

Like Principal Components Analysis, Independent Component Analysis [?] computes a set of orthogonal
linear combinations, but the criterion of Fast ICA is different: instead of maximizing variance, it tries to
maximize statistical independence between components.

In the Fast ICA algorithm [?], statistical independence is measured by evaluating non-Gaussianity of the
components, and the maximization is done in an iterative way.

The first step required to use this filter is to include its header file.

#include"otbFastICAImageFilter.h"

We start by defining the types for the images, the reader, and the writer. We choose to work with a
otb::VectorImage , since we will produce a multi-channel image (the independent components) from a
multi-channel input image.

We define the type for the filter. It is templated over the input and the output image types and also the
transformation direction. The internal structure of this filter is a filter-to-filter like structure. We can now the
instantiate the filter.

otb::FastICAImageFilter allows also to compute inverse transformation from ICA coefficients. In
reverse mode, the covariance matrix or the transformation matrix (which may not be square) has to be
given.

Figure 18.4 shows the result of applying forward and reverse FastICA transformation to a 8 bands
Worldview2 image.

Figure 18.4: Result of applying the otb::FastICAImageFilterto an image. From left to right: originalimage, color composition with first three independent components and output of the inverse mode (the inputRGB image).

The source code for this example can be found in the fileExamples/DimensionReduction/MaximumAutocorrelationFactor.cxx.

This example illustrates the class otb::MaximumAutocorrelationFactorImageFilter , which
performs a Maximum Autocorrelation Factor transform [?]. Like PCA, MAF tries to find a set of
orthogonal linear transform, but the criterion to maximize is the spatial auto-correlation rather than the
variance.

Auto-correlation is the correlation between the component and a unitary shifted version of the
component.

We can now declare the types for the reader. Since the images can be very large, we will force the pipeline
to use streaming. For this purpose, the file writer will be streamed. This is achieved by using the
otb::ImageFileWriter class.