Quantcast

Documentation Center

  • Trial Software
  • Product Updates

stretchlim

Find limits to contrast stretch image

Syntax

Low_High = stretchlim(I)
Low_High = stretchlim(I,Tol)
Low_High = stretchlim(RGB,Tol)
Low_High = stretchlim(gpuarrayI,___)

Description

Low_High = stretchlim(I) returns Low_High, a two-element vector of pixel values that specify lower and upper limits that can be used for contrast stretching image I. By default, values in Low_High specify the bottom 1% and the top 1% of all pixel values. The gray values returned can be used by the imadjust function to increase the contrast of an image.

Low_High = stretchlim(I,Tol) where Tol is a two-element vector [Low_Fract High_Fract] that specifies the fraction of the image to saturate at low and high pixel values.

  • If Tol is a scalar, Low_Fract = Tol, and High_Fract = 1 - Low_Fract, which saturates equal fractions at low and high pixel values.

  • If Tol = 0, Low_High = [min(I(:)); max(I(:))].

  • If you omit the Tol argument, [Low_Fract High_Fract] defaults to [0.01 0.99], saturating 2%.

If Tol is too big, such that no pixels would be left after saturating low and high pixel values, stretchlim returns [0 1].

Low_High = stretchlim(RGB,Tol) returns a 2-by-3 matrix of intensity pairs to saturate each plane of the RGB image. Tol specifies the same fractions of saturation for each plane.

Low_High = stretchlim(gpuarrayI,___) find limits to contrast stretch a gpuArray image, gpuarrayI. This syntax requires the Parallel Computing Toolbox™.

Class Support

The input images I or RGB can be of class uint8, uint16, int16, double, or single. The output limits returned, Low_High, are of class double and have values between 0 and 1.

The input gpuArray images can have the underlying class uint8, uint16, int16, double, or single. The output limits returned, Low_High, is a gpuArray with the underlying class double and have values between 0 and 1.

Examples

Find limits to contrast stretch grayscale image

I = imread('pout.tif');
J = imadjust(I,stretchlim(I),[]);
imshow(I), figure, imshow(J)

Find limits to contrast stretch grayscale image on a GPU

I = gpuArray(imread('pout.tif'));
J = imadjust(I,stretchlim(I),[]);
figure, imshow(I), figure, imshow(J)

See Also

| |

Was this topic helpful?