Apply decorrelation stretch to multichannel image

`S = decorrstretch(A)`

`S = decorrstretch(A,name,value...)`

example

applies
a decorrelation stretch to an `S`

= decorrstretch(`A`

)`m`

-by-`n`

-by-`nBands`

image `A`

and
returns the result in `S`

. `S`

has
the same size and class as `A`

, and the mean and
variance in each band are the same as in `A`

. `A`

can
be an RGB image (`nBands`

= 3) or can have any number
of spectral bands.

The primary purpose of decorrelation stretch is visual enhancement. Decorrelation stretching is a way to enhance the color differences in an image.

Use decorrelation stretching to highlight elements in a forest image by exaggerating the color differences.

[X, map] = imread('forest.tif'); S = decorrstretch(ind2rgb(X,map),'tol',0.01); figure subplot(1,2,1), imshow(X,map), title('Original Image') subplot(1,2,2), imshow(S), title('Enhanced Image')

`A`

— Image to be enhancednonsparse, real, N-D arrayImage to be stretched, specified as a nonsparse, real, N-D array.
The image `A`

is a multichannel image, such as,
an RGB image (`nBands`

= 3) or an image with any
number of spectral bands.

**Example: **

**Data Types: **`single`

| `double`

| `int16`

| `uint8`

| `uint16`

Specify optional comma-separated pairs of `Name,Value`

arguments.
`Name`

is the argument
name and `Value`

is the corresponding
value. `Name`

must appear
inside single quotes (`' '`

).
You can specify several name and value pair
arguments in any order as `Name1,Value1,...,NameN,ValueN`

.

`‘Mode','covariance'`

`'Mode'`

— Decorrelation method`‘correlation'`

(default) | `'correlation'`

or `'covariance'`

Decorrelation method, specified as the text string `‘correlation'`

or `‘covariance'`

. `‘correlation'`

uses
the eigen decomposition of the band-to-band correlation matrix. `‘covariance'`

uses
the eigen decomposition of the band-to-band covariance matrix.

**Data Types: **`char`

`'TargetMean'`

— Values that the band-means of the output image must match1-by-`nBands`

vector containing
the sample mean of each band (preserving the band-wise means) (default) | real scalar or vector of class `double`

and
of length `nBands`

. Values that the band-means of the output image must match, specified
as a real scalar or vector of class `double`

and
of length `nBands`

. If values need to be clamped
to the standard range of the input/output image class, it can impact
the results.

`targetmean`

must be of class `double`

,
but uses the same values as the pixels in the input image. For example,
if `A`

is class `uint8`

, then `127.5`

would
be reasonable value.

**Data Types: **`double`

`'TargetSigma'`

— Values that the standard deviations of the individual bands
of the output image must match1-by-`nBands`

vector containing
the standard deviation of each band (preserving the band-wise variances) (default) | real, positive scalar or vector of class `double`

and
of length `nBands`

Values that the standard deviations of the individual bands
of the output image must match, specified as a real, positive scalar
or vector of class `double`

and of length `nBands`

.
If values need to be clamped to the standard range of the input/output
image class, it can impact the results. Ignored for uniform (zero-variance)
bands.

`targetsigma`

must be class `double`

,
but uses the same values and the pixels in the input image. For example,
if `A`

is of class `uint8`

, then
and 50.0 would be reasonable value.

**Data Types: **`double`

`'Tol'`

— Linear contrast stretch to be applied following the decorrelation
stretchone- or two-element real vector of class `double`

Linear contrast stretch to be applied following the decorrelation
stretch, specified as a one- or two-element real vector of class `double`

.
Overrides use of `TargetMean`

or `TargetSigma`

. `TOL`

has
the same meaning as in `stretchlim`

, where ```
TOL
= [LOW_FRACT HIGH_FRACT]
```

specifies the fraction of the image
to saturate at low and high intensities. If you specify `TOL`

as
a scalar value, then `LOW_FRACT = TOL`

and ```
HIGH_FRACT
= 1 - TOL
```

, saturating equal fractions at low and high intensities.
If you do not specify a value for `TOL`

, `decorrstretch`

omits
the linear contrast stretch.

Small adjustments to `TOL`

can strongly affect
the visual appearance of the output.

**Data Types: **`double`

`'SampleSubs'`

— Subset of `A`

used to compute the band-means,
covariance, and correlationcell array containing two arrays of pixel subscripts ```
{rowsubs,
colsubs}
```

Subset of `A`

used to compute the band-means,
covariance, and correlation, specified as a cell array containing
two arrays of pixel subscripts `{rowsubs, colsubs}`

. `rowsubs`

and `colsubs`

are
vectors or matrices of matching size that contain row and column subscripts,
respectively.

Use this option to reduce the amount of computation, to keep
invalid or non-representative pixels from affecting the transformation,
or both. For example, you can use `rowsubs`

and `colsubs`

to
exclude areas of cloud cover. If not specified, `decorrstretch`

uses
all the pixels in `A`

.

**Data Types: **`double`

`S`

— Output imagenonsparse, real, N-D array`S`

has the same size and class as `A`

.
The mean and variance in each band in `S`

are the
same as in `A`

.

The results of a straight decorrelation (without the contrast stretch option) may include values that fall outside the numerical range supported by the class

`uint8`

or`uint16`

(negative values, or values exceeding`2^8 - 1`

or`2^16 - 1`

, respectively). In these cases,`decorrstretch`

clamps its output to the supported range.For class

`double`

,`decorrstretch`

clamps the output only when you provide a value for`TOL`

, specifying a linear contrast stretch followed by clamping to the interval`[0 1]`

.The optional parameters do not interact, except that a linear stretch usually alters both the band-wise means and band-wise standard deviations. Thus, while you can specify

`targetmean`

and`targetsigma`

along with`TOL`

, their effects will be modified.

A decorrelation stretch is a linear, pixel-wise operation in
which the specific parameters depend on the values of actual and desired
(target) image statistics. The vector `a`

containing
the value of a given pixel in each band of the input image `A`

is
transformed into the corresponding pixel `b`

in output
image `B`

as follows:

`b = T * (a - m) + m_target`

.

`a`

and `b`

are `nBands`

-by-1
vectors, `T`

is an `nBands`

-by-`nBands`

matrix,
and `m`

and `m_target`

are `nBands`

-by-1
vectors such that

`m`

contains the mean of each band in the image, or in a subset of image pixels that you specify`m_target`

contains the desired output mean in each band. The default choice is`m_target = m`

.

The linear transformation matrix `T`

depends
on the following:

The band-to-band sample covariance of the image, or of a subset of the image that you specify (the same subset as used for

`m`

), represented by matrix`Cov`

A desired output standard deviation in each band. This is conveniently represented by a diagonal matrix,

`SIGMA_target`

. The default choice is`SIGMA_target = SIGMA`

, where`SIGMA`

is the diagonal matrix containing the sample standard deviation of each band.`SIGMA`

should be computed from the same pixels that were used for`m`

and`Cov`

, which means simply that:`SIGMA(k,k) = sqrt(Cov(k,k), k = 1,..., nBands)`

.

`Cov`

, `SIGMA`

, and `SIGMA_target`

are `nBands`

-by-`nBands`

,
as are the matrices `Corr`

, `LAMBDA`

,
and `V`

, defined below.

The first step in computing `T`

is to perform
an eigen-decomposition of either the covariance matrix `Cov`

or
the correlation matrix

`Corr = inv(SIGMA) * Cov * inv(SIGMA)`

.

In the correlation-based method,

`Corr`

is decomposed:`Corr = V LAMBDA V'`

.In the covariance-based method,

`Cov`

is decomposed:`Cov = V LAMBDA V'`

.

`LAMBDA`

is a diagonal matrix of eigenvalues
and `V`

is the orthogonal matrix that transforms
either `Corr`

or `Cov`

to `LAMBDA`

.

The next step is to compute a stretch factor for each band,
which is the inverse square root of the corresponding eigenvalue.
It is convenient to define a diagonal matrix `S`

containing
the stretch factors, such that:

`S(k,k) = 1 / sqrt(LAMBDA(k,k))`

.

Finally, matrix `T`

is computed from either

`T = SIGMA_target V S V' inv(SIGMA) `

(correlation-based
method)

or

`T = SIGMA_target V S V'`

(covariance-based
method).

The two methods yield identical results if the band variances are uniform.

Substituting `T`

into the expression for `b`

:

```
b = m_target + SIGMA_target V S V' inv(SIGMA) * (a
- m)
```

or

`b = m_target + SIGMA_target V S V' * (a - m)`

and reading from right to left, you can see that the decorrelation stretch:

Removes a mean from each band

Normalizes each band by its standard deviation (correlation-based method only)

Rotates the bands into the eigenspace of

`Corr`

or`Cov`

Applies a stretch

`S`

in the eigenspace, leaving the image decorrelated and normalized in the eigenspaceRotates back to the original band-space, where the bands remain decorrelated and normalized

Rescales each band according to

`SIGMA_target`

Restores a mean in each band.

Was this topic helpful?