图像增强是增强图像中的有用信息,它可以是一个失真的过程,其目的是要改善图像的视觉效果,针对给定图像的应用场合。有目的地强调图像的整体或局部特性,将原来不清晰的图像变得清晰或强调某些感兴趣的特征,扩大图像中不同物体特征之间的差别,抑制不感兴趣的特征,使之改善图像质量、丰富信息量,加强图像判读和识别效果,满足某些特殊分析的需要。
1 图像增强--灰度
//灰度
P=imread('66.jpg');
I=rgb2gray(P);
subplot(231);imshow(I,[]);title('原始图像');
subplot(234);imhist(I);title('由原始图像得到的直方图');
J=imadjust(I,[0.15 0.9],[0 1]);
subplot(232);imshow(J);title('由新直方图得到的新图像');
subplot(235);imhist(J);title('利用imadjust调节后的新直方图');
K=histeq(I);
subplot(233);imshow(K);title('由均衡化后的直方图得到的均衡后的图像');
subplot(236);imhist(K);title('均衡化后的直方图');
实验结果
2 图像增强--平滑
//平滑
P=imread('66.jpg');
I=rgb2gray(P);
subplot(221);imshow(I);title('原始图像');
I1=imnoise(I,'salt & pepper');
subplot(222);imshow(I1);title('加入椒盐噪声后的图像');
h1=ones(3,3)/9;
h2=ones(5,5)/25;
K1=imfilter(I1,h1);
K2=imfilter(I1,h2);
%subplot(334),imshow(I),title('原始图像');
%subplot(337),imshow(I),title('原始图像');
subplot(223),imshow(K1,[]),title('加入椒盐噪声后3*3平均滤波');
subplot(224),imshow(K2,[]),title('加入椒盐噪声后5*5平均滤波');
I2=imnoise(I,'gaussian',0,0.005);
figure;
subplot(221);imshow(I);title('原始图像');
subplot(222);imshow(I2);title('加入高斯噪声后的图像');
h1=ones(3,3)/9;
h2=ones(5,5)/25;
K1=imfilter(I2,h1);
K2=imfilter(I2,h2);
subplot(223),imshow(K1,[]),title('加入高斯噪声后3*3平均滤波');
subplot(224),imshow(K2,[]),title('加入高斯噪声后5*5平均滤波');
figure;
subplot(321);imshow(I1);title('加入椒盐噪声后的图像');
subplot(322);imshow(I2);title('加入高斯噪声后的图像');
J1=medfilt2(I1);
J3=medfilt2(I2);
J2=medfilt2(I1,[5 5]);
J4=medfilt2(I2,[5 5]);
subplot(323),imshow(J1),title('加入椒盐噪声后3*3窗口中值滤波');
subplot(324),imshow(J3),title('加入椒盐噪声后5*5窗口中值滤波');
subplot(325),imshow(J2),title('加入高斯噪声后3*3窗口中值滤波');
subplot(326),imshow(J4),title('加入高斯噪声后5*5窗口中值平均滤波');
实验结果
加入高斯噪声
加入椒盐噪声
平滑中值
3 图像处理--锐化
//锐化
P=imread('66.jpg');
I=rgb2gray(P);
subplot(221);imshow(I,[]);title('原始图像');
K=histeq(I);
subplot(222);imshow(K);title('由均衡化后的直方图得到的均衡后的图像');
BW=edge(K,'roberts',0.1);
subplot(223);imshow(BW);title('均衡后的图像罗伯茨梯度锐化');
h=[0 -1 0;-1 4 -1;0 -1 0];
J=imfilter(I,h);
subplot(224);imshow(J);title('均衡后的图像拉普拉斯锐化');
实验结果
下一篇 数字图像处理--图像的压缩