lowhigh = stretchlim(I)
computes the lower and upper limits that can be used for contrast stretching
grayscale or RGB image I. The limits are returned in
lowhigh. By default, the limits specify the bottom 1% and
the top 1% of all pixel values.
lowhigh = stretchlim(I,Tol)
specifies the fraction, Tol, of the image to saturate at low and
high pixel values.
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%.
lowhigh — Lower and upper limits for contrast stretching 2-element numeric vector | 2-by-3 numeric matrix
Lower and upper limits for contrast stretching, returned as one of the following.
A 2-element numeric vector when I is a
grayscale image.
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.
Data Types: double
Tips
Use the imadjust function to adjust the
contrast of image I using the limits,
lowhigh.
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
stretchlim supports the generation of C
code (requires MATLAB®
Coder™). Note that if you choose the generic MATLAB Host Computer
target platform, 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 Code Generation Using a Shared Library.
GPU Code Generation Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
GPU Arrays Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.