% 读入图像 img = imread('pout.tif');

% 三段线性变换 img1 = img; img1(img1>=0 & img1<85) = img1(img1>=0 & img1<85) * 0.5; img1(img1>=85 & img1<170) = img1(img1>=85 & img1<170) * 1.5 - 64; img1(img1>=170 & img1<=255) = img1(img1>=170 & img1<=255) * 0.5 + 128;

% 高低端灰度保持 img2 = imadjust(img,[0.2 0.8],[0 1]);

% 截取式灰度变换 img3 = imadjust(img,[],[],2);

% 设定不同的区间端点 img4 = imadjust(img,[0 0.4],[0 1]); img5 = imadjust(img,[0.6 1],[0 1]); img6 = imadjust(img,[0.3 0.7],[0 1]);

% 显示原图像和各种变换后的图像及直方图 figure;

subplot(2,4,1);imshow(img);title('原图像'); subplot(2,4,5);imhist(img);title('原图像直方图');

subplot(2,4,2);imshow(img1);title('三段线性变换'); subplot(2,4,6);imhist(img1);title('三段线性变换直方图');

subplot(2,4,3);imshow(img2);title('高低端灰度保持'); subplot(2,4,7);imhist(img2);title('高低端灰度保持直方图');

subplot(2,4,4);imshow(img3);title('截取式灰度变换'); subplot(2,4,8);imhist(img3);title('截取式灰度变换直方图');

figure;

subplot(2,3,1);imshow(img);title('原图像'); subplot(2,3,4);imhist(img);title('原图像直方图');

subplot(2,3,2);imshow(img4);title('区间端点[0,0.4]'); subplot(2,3,5);imhist(img4);title('区间端点[0,0.4]直方图');

subplot(2,3,3);imshow(img5);title('区间端点[0.6,1]'); subplot(2,3,6);imhist(img5);title('区间端点[0.6,1]直方图');

figure;

subplot(2,2,1);imshow(img);title('原图像'); subplot(2,2,2);imshow(img3);title('截取式灰度变换'); subplot(2,2,3);imshow(img6);title('区间端点[0.3,0.7]'); subplot(2,2,4);imhist(img6);title('区间端点[0.3,0.7]直方图');

MATLAB图像处理:灰度变换示例及直方图展示

原文地址: https://www.cveoy.top/t/topic/nGoa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录