https://www.mathworks.com/help/images/ref/stretchlim.html
stretchlim - Find limits to contrast stretch image - MATLAB
This MATLAB function computes the lower and upper limits that can be used for contrast stretching grayscale or RGB image I.
stretch imagefindlimitscontrastmatlab