FUNCTION REFERENCE
stretchlim
Contrast-stretching limits of an image.
Contrast-stretching limits of an image.
Syntax
lowhigh = stretchlim(I)Syntax
lowhigh = stretchlim(I, tol)Returns [low; high] as fractions of the class range that saturate the fraction tol(1) of the pixels at the bottom and 1 - tol(2) at the top. tol defaults to [0.01 0.99]; a scalar t means [t 1-t]; tol = 0 gives the smallest and largest values. The limits come from the histogram of the image (256 bins for uint8, logical and floating-point images, 65536 for 16-bit and wider integer images): low is the first bin whose cumulative fraction exceeds tol(1), high the first that reaches tol(2), each as (bin - 1)/(bins - 1). When both are the same bin (a constant image) the result is [0; 1]. For an M-by-N-by-3 RGB image the result is 2-by-3, one column per channel.
Example
stretchlim(uint8(0:255)) % [2/255; 253/255]Example
stretchlim(uint8([7 7 7])) % [0; 1]Example
stretchlim(uint8([0 10 20 30]), 0) % [0; 30/255]Differences from MATLAB: none known.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.