本文介绍了在MATLAB环境下对灰度图像进行拉伸处理的方法与技巧,旨在改善图像对比度和视觉效果。
I = imread(chez.jpg);
J = rgb2gray(I); % 将输入图像转换为灰度图像;如果输入的图像是灰度图像,则不需要此步骤
subplot(2, 2, 1), imshow(J)
title(原始灰度图)
subplot(2, 2, 2), imhist(J)
title(原始灰度直方图)
K = imadjust(J); % 使用函数imadjust进行灰度拉伸
% K=imadjust(I,[low_in high_in],[low_out high_out])
subplot(2, 2, 3), imshow(K)
title(灰度拉伸效果图)
subplot(2, 2, 4), imhist(K)
title(灰度拉伸后图像直方图)