Find limits to contrast stretch image
Low_High = stretchlim(I)
Low_High = stretchlim(I,Tol)
Low_High = stretchlim(RGB,Tol)
Low_High = stretchlim(gpuarrayI,___)
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.
This function supports code generation (see Tips).
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].
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.
I = imread('pout.tif'); J = imadjust(I,stretchlim(I),); imshow(I), figure, imshow(J)
I = gpuArray(imread('pout.tif')); J = imadjust(I,stretchlim(I),); figure, imshow(I), figure, imshow(J)
This function supports the generation of C code using MATLAB® Coder™. The code generated for this function uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Code Generation Using a Shared Library.