图像处理

  • 格式:docx
  • 大小:337.39 KB
  • 文档页数:5

下载文档原格式

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

图像变换

(1)熟悉并掌握MATLAB图像处理工具箱的使用;

(2)理解并掌握常用的图像的变换增强技术。

【实验要求】

(1)邻域平均法、中值滤波实现平滑运算,并观察模板大小对平滑效果的影响;

(2)使用拉普拉斯算子、sobel算子等实现锐化运算,并观察模板大小对平滑效果的影响。【实验内容】

1、实验步骤:

I=imread('D:\xk\9.gif');

J1=imnoise(I,'gaussian',0,0.03);

subplot(3,3,1),imshow(I),title('原图像');

subplot(3,3,2),imshow(J1),title('加高斯噪声');

K1=filter2(fspecial('average',5),J1)/255;

K2=filter2(fspecial('average',7),J1)/255;

K3=filter2(fspecial('average',9),J1)/255;

K11=medfilt2(J1,[5,5]);

K22=medfilt2(J1,[7,7]);

K33=medfilt2(J1,[9,9]);

subplot(334),imshow(K1);title('5*5均值滤波');

subplot(335),imshow(K2);title('7*7均值滤波');

subplot(336),imshow(K3);title('9*9均值滤波');

subplot(337),imshow(K11);title('5*5中值滤波');

subplot(338),imshow(K22);title('7*7中值滤波');

subplot(339),imshow(K33);title('9*9中值滤波');

实验结果:

图1 邻域平均法、中值滤波实现平滑运算的结果

2、实验步骤:

I=imread('D:\xk\9.gif');

I=im2double(I);

figure;

subplot(3,3,1);imshow(I);title('原图像');

H1=fspecial('sobel');

H1=filter2(H1,I);

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

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

h=[0 1 0,1 -4 1,0 1 0];

H2=conv2(I,h,'same');

subplot(3,3,3),imshow(H2);

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

K1=filter2(fspecial('average',5),H1)/255;

K2=filter2(fspecial('average',7),H1)/255;

K3=filter2(fspecial('average',9),H1)/255;

K11=medfilt2(H2,[5,5]);

K22=medfilt2(H2,[7,7]);

K33=medfilt2(H2,[9,9]);

subplot(334),imshow(K1);title('5*5均值滤波');

subplot(335),imshow(K2);title('7*7均值滤波');

subplot(336),imshow(K3);title('9*9均值滤波');

subplot(337),imshow(K11);title('5*5中值滤波');

实验结果:

图2 拉普拉斯算子、sobel算子等实现锐化运算的结果3.实验步骤:

I=imread('D:\images\t15.bmp');

imshow(I);

subplot(2,4,1);

imshow(I);

title('原始图像');

%灰度图

J=rgb2gray(I);

subplot(2,4,2)

imshow(J);

title('灰度图像')

fft_J=fft2(J);

%2-D快速傅立叶变换

A=abs(fft_J);

%将频谱矩阵元素归一化到0~255

A=(A-min(min(A)))/(max(max(A))-min(min(A)))*255;

subplot(2,4,3)

imshow(A);

title('傅立叶频谱图像')

sfft_J=fftshift(fft_J);

%傅立叶频谱平面中心移至窗口中心

A=abs(sfft_J);

%将频谱矩阵元素归一化到0~255

A=(A-min(min(A)))/(max(max(A))-min(min(A)))*255;

subplot(2,4,4)

imshow(A);

title('原点移到中心的傅立叶频谱图像' );

%对图像DCT变换

J1=dct2(J);

subplot(2,4,5);imshow(log(abs(J1)),[]);

title('DCT变换灰度图像');

colormap(gray(4));colorbar;

%对灰度矩阵进行量化

J1(abs(J1)<0.1)=0;

%DCT逆变换

B=idct2(J1)/255;

subplot(2,4,6);imshow(B);title('经过DCT变换,然后逆变换的灰度图像'); %对比变换傅里叶变换前后的图像

subplot(2,4,7);imshow(J);title('原灰度图像');

subplot(2,4,8);imshow(B);title('DCT逆变换图像');

实验结果: