PCA
Description
Perform a principal component analysis and optionally a whitening transform or decorrelation stretch.
Ignores DQ and uncertainty
Standard recipe for decorrelation stretch:
- Mode = decorrelation stretch
- Stretch/whitening = stretch
- Clip outliers to around 2%
- Set both RGB normalisation and histogram equalisation
See below for what this actually does!
Details
This node first performs a Principle Component Analysis (PCA) on all bands of an image. The output image consists of the principal components, with the most significant first. The RGB output - also shown in the canvas - is selected from these bands by the Component RGB Mapping, and some further processing can take place on this (see below).
On the PCA image we optionally perform a whitening transform or a stretch.
- A whitening transform will divide each PC by its standard deviation (so that the resulting data has an identity covariance matrix).
- A stretch will apply a stretch factor to the PCs, (mean of eigenvalues / eigenvalue)
We then either leave the result in the PCA space, so that channel 0 holds the component with the most variation, channel 1 holds the next most varying component etc., or we transform the image back into the original colour space, so the node performs a decorrelation stretch.
Then a contrast stretch is done in which all outliers above and below a certain percentile of the entire image are set to 0 or 1, and remaining values are stretched to fill the gaps.
The resulting image is sent to the PCA output before further processing.
The remaining steps only take place on the RGB representation of the image, whose bands are selected by the "Component RGB mapping" boxes.
- Normalize RGB will normalise the RGB bands separately to the [0,1] range. This is usually required because the PCA image bands have very different amplitudes.
- Histogram equalisation can be applied to the RGB image. This redistributes the intensity values of an image so that they occupy the available dynamic range more evenly. It works by computing the image’s histogram, converting it into a cumulative distribution function (CDF), and then remapping each pixe according to this CDF.
The standard deviations of the original input image and the eigenvalues (i.e. magnitudes) of the principal components are also shown and output.
Connections
Inputs
| Index | Name | Type | Desc |
|---|---|---|---|
| 0 | (none) | img | input image |
Outputs
| Index | Name | Type | Desc |
|---|---|---|---|
| 0 | rgb | img | RGB image selected by component mapping |
| 1 | PCA | img | PCA image |
| 2 | eigs | number | eigenvalues of principal components |
| 3 | sds | number | standard deviations of original image bands |
Parameters
| PCA | rgbmapping: list of integer (default [0, 1, 2]) | rgb mapping |
| mode: string (pca, decorr) (default 'pca') | PCA or decorr stretch mode | |
| stretch: string (none, whiten, stretch) (default 'none') | Stretch/decorr mode | |
| clip: float (default 5.0) | percentile outliers to clip in postprocessing | |
| normalize: boolean (default True) | normalise RGB output | |
| histequal: boolean (default False) | apply histogram equalization to RGB output |
Automatically generated by generate_autodocs.py
Date: 2026-07-03T14:16:39.921215