您的位置:首页 > 编程语言 > MATLAB

灰度直方图、直方图均衡化及图像滤波

2017-03-27 14:38 113 查看
1、灰度直方图

I=imread('guilin.jpg');

I=rgb2gray(I);

subplot(121),imshow(I)

subplot(122),imhist(I)



I=imread('pubu.jpg');

subplot(141),imshow(I);

subplot(221),imshow(I);

%R分量的灰度直方图

subplot(222),imhist(I(:,:,1));

%G分量的灰度直方图

subplot(223),imhist(I(:,:,2));

%B分量的灰度直方图

subplot(224),imhist(I(:,:,3));



2、直方图均衡化

%读入待转换的彩色图像,并将其转换成灰度图像

I=imread('diaosu.jpg');

I=rgb2gray(I);

%进行直方图均衡化处理

J=histeq(I);

%显示输入图像预处理后的结果

subplot(211),imshow(I)

subplot(212),imshow(J)



3、图像滤波

%读入原始图像,添加椒盐噪声

I=imread('lena.jpg');

I=rgb2gray(I);

J=imnoise(I,'salt & pepper',0.04);

%进行中值滤波

K=medfilt2(J,[3,3]);

subplot(121),imshow(J)

subplot(122),imshow(K)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  matlab