Apply decorrelation stretch to multichannel image
S = decorrstretch(A)
S = decorrstretch(A,name,value...)
a decorrelation stretch to an
S = decorrstretch(
returns the result in
the same size and class as
A, and the mean and
variance in each band are the same as in
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 array
Image to be stretched, specified as a nonsparse, real, N-D array.
A is a multichannel image, such as,
an RGB image (
nBands = 3) or an image with any
number of spectral bands.
Specify optional comma-separated pairs of
Name is the argument
Value is the corresponding
Name must appear
inside single quotes (
You can specify several name and value pair
arguments in any order as
'Mode'— Decorrelation method
Decorrelation method, specified as the text string
the eigen decomposition of the band-to-band correlation matrix.
the eigen decomposition of the band-to-band covariance matrix.
'TargetMean'— Values that the band-means of the output image must match1-by-
nBandsvector containing the sample mean of each band (preserving the band-wise means) (default) | real scalar or vector of class
doubleand of length
Values that the band-means of the output image must match, specified
as a real scalar or vector of class
nBands. If values need to be clamped
to the standard range of the input/output image class, it can impact
targetmean must be of class
but uses the same values as the pixels in the input image. For example,
A is class
be reasonable value.
'TargetSigma'— Values that the standard deviations of the individual bands of the output image must match1-by-
nBandsvector containing the standard deviation of each band (preserving the band-wise variances) (default) | real, positive scalar or vector of class
doubleand of length
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
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)
targetsigma must be class
but uses the same values and the pixels in the input image. For example,
A is of class
and 50.0 would be reasonable value.
'Tol'— Linear contrast stretch to be applied following the decorrelation stretchone- or two-element real vector of class
Linear contrast stretch to be applied following the decorrelation
stretch, specified as a one- or two-element real vector of class
Overrides use of
the same meaning as in
= [LOW_FRACT HIGH_FRACT] specifies the fraction of the image
to saturate at low and high intensities. If you specify
a scalar value, then
LOW_FRACT = TOL and
= 1 - TOL, saturating equal fractions at low and high intensities.
If you do not specify a value for
the linear contrast stretch.
Small adjustments to
TOL can strongly affect
the visual appearance of the output.
'SampleSubs'— Subset of
Aused to compute the band-means, covariance, and correlationcell array containing two arrays of pixel subscripts
A used to compute the band-means,
covariance, and correlation, specified as a cell array containing
two arrays of pixel subscripts
vectors or matrices of matching size that contain row and column subscripts,
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
exclude areas of cloud cover. If not specified,
all the pixels in
The results of a straight decorrelation (without
the contrast stretch option) may include values that fall outside
the numerical range supported by the class
values, or values exceeding
2^8 - 1 or
- 1, respectively). In these cases,
its output to the supported range.
the output only when you provide a value for
specifying a linear contrast stretch followed by clamping to the interval
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
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
the value of a given pixel in each band of the input image
transformed into the corresponding pixel
b in output
B as follows:
b = T * (a - m) + m_target.
T is an
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
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
m), represented by matrix
A desired output standard deviation in each band.
This is conveniently represented by a diagonal matrix,
The default choice is
SIGMA_target = SIGMA, where
the diagonal matrix containing the sample standard deviation of each
SIGMA should be computed from the same pixels
that were used for
which means simply that:
SIGMA(k,k) = sqrt(Cov(k,k), k = 1,..., nBands).
as are the matrices
V, defined below.
The first step in computing
T is to perform
an eigen-decomposition of either the covariance matrix
the correlation matrix
Corr = inv(SIGMA) * Cov * inv(SIGMA).
In the correlation-based method,
Corr = V LAMBDA V'.
In the covariance-based method,
Cov = V LAMBDA V'.
LAMBDA is a diagonal matrix of eigenvalues
V is the orthogonal matrix that transforms
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
the stretch factors, such that:
S(k,k) = 1 / sqrt(LAMBDA(k,k)).
T is computed from either
T = SIGMA_target V S V' inv(SIGMA) (correlation-based
T = SIGMA_target V S V' (covariance-based
The two methods yield identical results if the band variances are uniform.
T into the expression for
b = m_target + SIGMA_target V S V' inv(SIGMA) * (a
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
Applies a stretch
S in the eigenspace,
leaving the image decorrelated and normalized in the eigenspace
Rotates back to the original band-space, where the bands remain decorrelated and normalized
Rescales each band according to
Restores a mean in each band.