MATLAB的图像灰度线性变换

下面重点介绍一下如何用MATLAB对图像进行灰度线性变换,具体如下:

1、打开MATLAB主界面,在其中的编辑器中写入下列代码,其中I=imread('G:\MATLAB练习\bm.bmp');此代码是读入图片的语句,也就是我们想要处理的图片,这里我是存放在G盘的MATLAB练习文件夹中,名称叫bm的bmp图像,格式因存放位置而不同

 I=imread('G:\MATLAB练习\bm.bmp');
subplot(2,2,1),imshow(I);
title('原始图像');
axis([50,250,50,200]);
axis on;                  %显示坐标系
I1=rgb2gray(I);
subplot(2,2,2),imshow(I1);
title('灰度图像');
axis([50,250,50,200]);
axis on;                  %显示坐标系
J=imadjust(I1,[0.1 0.5],[]); %局部拉伸,把[0.1 0.5]内的灰度拉伸为[0 1]
subplot(2,2,3),imshow(J);
title('线性变换图像[0.1 0.5]');
axis([50,250,50,200]);
grid on;                  %显示网格线
axis on;                  %显示坐标系
K=imadjust(I1,[0.3 0.7],[]); %局部拉伸,把[0.3 0.7]内的灰度拉伸为[0 1]
subplot(2,2,4),imshow(K);
title('线性变换图像[0.3 0.7]');
axis([50,250,50,200]);
grid on;                  %显示网格线
axis on;                  %显示坐标系

2、点击运行按钮,会出现下图的结果

至此,灰度线性变换的介绍就到此结束,请大家继续后续关注,谢谢!!

猜你喜欢

转载自blog.csdn.net/dyq1995/article/details/84230394