MATLAB: Do I obtain only ones when I use STRETCHLIM function on an image in the Image Processing Toolbox 5.3 (R2006b)

imadjust()Image Processing Toolboxstretch

I obtain only ones when I use STRETCHLIM in the Image Processing Toolbox 5.3 (R2006b). This happens when I run the following code:
load img
LOW_HIGH = stretchlim(img)
img2 = imadjust(img,LOW_HIGH,[]);
imshow(img), figure, imshow(img2);
The value 'LOW_HIGH' returned by STRETCHLIM is [0;1]

Best Answer

This occurs when the image is not normalized. In order to have STRETCHLIM work, normalize the input image as shown in the following example:
load img
img2 = img/max(img(:));
LOW_HIGH = stretchlim(img2);
img3 = imadjust(img2,LOW_HIGH);
figure(1); clf;
subplot(211)
imshow(img2)
subplot(212)
xlabel('Adjusted image')
imshow(img3)
Related Question