Find limits to contrast stretch image
Read grayscale image into the workspace and display it.
I = imread('pout.tif'); figure imshow(I)
Adjust the contrast in the image using
stretchlim to set the limits, and display the result. The example uses the default limits
[0.01 0.99], saturating the upper 1% and the lower 1%.
J = imadjust(I,stretchlim(I),); figure imshow(J)
I— Image to be contrast stretched
Image to be contrast stretched, specified as a 2-D grayscale image or 2-D RGB image.
Tol— Fraction of image to saturate
[0.01 0.99](default) | numeric scalar | 2-element numeric vector
Fraction of the image to saturate, specified as a numeric scalar or
[Low_Fract High_Fract] in the range [0,
|Default||If you omit the |
|Too big||If |
lowhigh— Lower and upper limits for contrast stretching
Lower and upper limits for contrast stretching, returned as one of the following.
A 2-element numeric vector when
I is a
A 2-by-3 numeric matrix when
I is an RGB
image. The columns indicate the lower and upper limit for each
of the three color channels.
Usage notes and limitations:
stretchlim supports the generation of C
code (requires MATLAB®
Coder™). Note that if you choose the generic
MATLAB Host Computer
stretchlim generates code that 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 Types of Code Generation Support in Image Processing Toolbox.
This function fully supports GPU arrays. For more information, see Image Processing on a GPU.