数字图像处理-图像平滑和锐化变换处理

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图像平滑和锐化变换处理

一、实验内容和要求

1、灰度变换:灰度拉伸、直方图均衡、伽马校正、log变换等。

2、空域平滑:box、gauss模板卷积。

3、频域平滑:低通滤波器平滑。

4、空域锐化:锐化模板锐化。

5、频域锐化:高通滤波器锐化。

二、实验软硬件环境

PC机一台、MATLAB软件

三实验编程及调试

1、灰度变换:灰度拉伸、直方图均衡、伽马校正、log变换等。

①灰度拉伸程序如下:

I=imread('');

J=imadjust(I,[,],[]);

subplot(2,2,1),imshow(I);

subplot(2,2,2),imshow(J);

subplot(2,2,3),imhist(I);

subplot(2,2,4),imhist(J);

②直方图均衡程序如下:

I=imread('');

J=histeq(I);

Subplot(2,2,1);

Imshow(I);

Title('原图像');

Subplot(2,2,2);

Imshow(J);

Title('直方图均衡化后的图像') ; Subplot(2,2,3) ;

Imhist(I,64);

Title('原图像直方图') ;

Subplot(2,2,4);

Imhist(J,64) ; Title('均衡变换后的直方图') ;

③伽马校正程序如下:

A=imread('');

x=0:255;

a=80,b=,c=;

B=b.^(c.*(double(A)-a))-1;

y=b.^(c.*(x-a))-1;

subplot(3,2,1);

imshow(A);

subplot(3,2,2);

imhist(A);

subplot(3,2,3);

imshow(B);

subplot(3,2,4);

imhist(B);

subplot(3,2,6);

plot(x,y);

④log变换程序如下:

Image=imread('');

subplot(1,2,1);imshow(Image);

Image=log(1+double(Image));

subplot(1,2,2);imshow(Image,[]);

2、空域平滑:box、gauss模板卷积。A=imread('');

B=rgb2gray(A);

figure,subplot(3,2,1);imshow(B);

title('原始图象');

H=imnoise(B,'gaussian');

subplot(3,2,2);imshow(H);

title('高斯噪声');

Q=imnoise(B,'salt & pepper');

subplot(3,2,3);imshow(Q);

title('椒盐噪声');

M=fspecial('average',3*3);

E=imfilter(Q,M);

subplot(3,2,4);imshow(E);

title('3*3平均模板');

N=fspecial('average',5*5);

K=imfilter(Q,N);

subplot(3,2,5);imshow(K);

title('5*5平均模板');

Z=fspecial('average',7*7);

J=imfilter(Q,Z);

subplot(3,2,6);imshow(J);

title('7*7平均模板');

3、频域平滑:低通滤波器平滑。

频域低通滤波处理噪声的程序如下:[f1,f2]=freqspace(25,'meshgrid');

Hd=zeros(25,25);

d=sqrt(f1.^2+f2.^2)<;%为截止半径大小Hd(d)=1;

h=fsamp2(Hd);

figure(1),freqz2(h,[64,64]);

RGB=imread('');

I=rgb2gray(RGB);

I1=imnoise(I,'gaussian');

I2=imnoise(I,'salt & pepper',;

I3=imnoise(I,'speckle');

J=imfilter(I,h,'replicate');

J1=imfilter(I1,h,'replicate');

J2=imfilter(I2,h,'replicate');

J3=imfilter(I3,h,'replicate');

figure(2),subplot(221),imshow(J);

title('原图像滤波后');

subplot(222),imshow(J1);

title('高斯污染图像滤波后');

subplot(223),imshow(J2);

title('椒盐污染图像污染后');

subplot(224),imshow(J3);

title('乘法污染图像滤波后');

4、空域锐化:锐化模板锐化。

I=imread('');

A=RGB2gray(I);

figure,subplot(2,3,1);

imshow(A);

title('原图');

hs=fspecial('sobel');

S=imfilter(A,hs);

hp=fspecial('prewitt');

P=imfilter(A,hs);

A=double(A);%双精度型

H=[0,1,0;1,-4,1;0,1,0];%拉普拉斯算子J=conv2(A,H,'same');

K=A-J;

subplot(2,3,2),imshow(K);

title('拉普拉斯锐化图像');

B=edge(A,'roberts',;

subplot(2,3,3),imshow(B);

title('罗伯特锐化图像');

subplot(2,3,4),imshow(S);

title('sobel算子锐化图像');

subplot(2,3,5),imshow(P);

title('prewitt算子锐化图像');

5、频域锐化:高通滤波器锐化。A=imread('');

B=rgb2gray(A);

相关文档
最新文档