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)