




免费预览已结束,剩余11页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数字图像处理上机实验题一、产生右图所示图像 f1(m,n),其中图像大小为256256,中间亮条为12832,暗处=0,亮处=100。对其进行 FFT:1、 屏显示原图 f1(m,n)和FFT(f1)的幅度谱图; 2、令f2(m,n)=(-1)(m+n)*f1(m,n),重复以上过程,比较二者幅度谱的异同,简述理由;3、若将f2(m,n)顺时针旋转 90 度得到f3(m,n),试显示 FFT(f3)的幅度谱,并与 FFT(f2)的幅度谱进行比较;4、若将f1(m,n) 顺时针旋转 90 度得到f4(m,n),令f5(m,n)=f1(m,n)+f4(m,n),试显示 FFT(f5)的幅度谱,并指出其与 FFT(f1)和FFT(f4)的关系;5、若令f6(m,n)=f2(m,n)+f3(m,n),试显示 FFT(f6)的幅度谱,并指出其与 FFT(f 2)和FFT(f3)的关系,比较 FFT(f6)和FFT(f5)的幅度谱。代码f1=zeros(256,256); for i =64:1:191 for j = 112:1:143 f1(i,j) = 100; end end f2 = fft2(f1); %f2(m,n) = f3 f3 = (-1)(i+j)*f1; f4 = fft2(f3); %f3(m,n) = f5 f5 = imrotate(f3,90,bilinear); f6 = fft2(f5); %f4(m,n) = f7 f7 = imrotate(f1,90,bilinear); f8 = fft2(f7); %f5(m,n) = f8 f9 = f1 + f7; f10 = fft2 (f9); %f6(m,n) = f2(m,n)+f3(m,n) f11 = f3 + f5; f12 = fft2(f11); figure(1)subplot(1,2,1);imshow(abs(f1);title(原图f1);subplot(1,2,2);imshow(abs(f2);title(幅度谱fft2(f1);figure(2)subplot(2,2,1)imshow(abs(f1);title(原图f1)subplot(2,2,2)imshow(abs(f2);title(幅度谱fft2(f1);subplot(2,2,3);imshow(abs(f3)title(变换谱f2);subplot(2,2,4);imshow(abs(f4);title(幅度谱fft2(f2);figure(3)subplot(2,2,1)imshow(abs(f3)title(变换谱f2);subplot(2,2,2);imshow(abs(f4);title(幅度谱fft2(f2);subplot(2,2,3);imshow(abs(f5)title(变换谱f3);subplot(2,2,4);imshow(abs(f6);title(幅度谱fft2(f3);figure(4)subplot(3,2,1);imshow(f7);title(f1旋转图f4);subplot(3,2,2);imshow(abs(f8);title(幅度谱fft2(f4); subplot(3,2,3);imshow(f9);title(f5(m,n)=f1+f4);subplot(3,2,4);imshow(abs(f10);title(幅度谱fft2(f5);subplot(3,2,5)imshow(abs(f1);title(原图f1);subplot(3,2,6);imshow(abs(f2);title(幅度谱fft2(f1);figure(5)subplot(3,2,1)imshow(abs(f3)title(变换谱f2);subplot(3,2,2);imshow(abs(f4);title(幅度谱fft2(f2);subplot(3,2,3);imshow(abs(f5)title(变换谱f3);subplot(3,2,4);imshow(abs(f6);title(幅度谱fft2(f3);subplot(3,2,5)imshow(abs(f11)title(变换谱f6=f2+f3);subplot(3,2,6);imshow(abs(f12);title(幅度谱fft2(f6); figure(6)subplot(2,2,1);imshow(f9);title(f5(m,n)=f1+f4);subplot(2,2,2);imshow(abs(f10);title(幅度谱fft2(f5);subplot(2,2,3)imshow(abs(f11)title(变换谱f6(m,n)=f2+f3);subplot(2,2,4);imshow(abs(f12);title(幅度谱fft2(f6);结果分析2、 F2(m,n)与F1(m,n)幅度值相同,f2(m,n)=(-1)(m+n)*f1(m,n)中,并未改变幅值。3、 FFT(f2) 比FFT(f3)幅值大。4、 f5=f1+f4,即幅值相加。5、 f6=f2+f3,即幅值相加。二、产生教材 104 页题图 4.18 (右图)所示的二值图像(白为1,黑为0),编程实现习题4.18 所要求的处理(3*3 的平均滤波和中值滤波)功能(图像四周边界不考虑,处理结果按四舍五入仍取(0或1),显示处理前后的图像,比较其异同。代码I= 1,0,1,0,1,0,1,0; 0,1,0,1,0,1,0,1; 1,0,1,0,1,0,1,0; 0,1,0,1,0,1,0,1; 1,0,1,0,1,0,1,0; 0,1,0,1,0,1,0,1; 1,0,1,0,1,0,1,0; 0,1,0,1,0,1,0,1;J=imhist(I,2);K=filter2(fspecial(average,3),I);K1=round(K);J1=imhist(K1,2);K2=medfilt2(I);J2=imhist(K2,2); figure(1)subplot(2,2,1)imshow(I);title(原图像);subplot(2,2,2)imshow(J);title(原图像直方图);subplot(2,2,3)imshow(K1);title(3*3领域平均);subplot(2,2,4)imshow(J1);title(领域平均图像直方图)figure(2)subplot(2,2,1)imshow(I);title(原图像);subplot(2,2,2)imshow(J);title(原图像直方图);subplot(2,2,3)imshow(K2);title(中值滤波);subplot(2,2,4)imshow(J2);title(中值滤波图像直方图)结果三、产生教材 104 页题图 4.16 所示的灰度图像(白为255 ,黑为0),分别加入高斯白噪声和椒盐噪声,再分别进行 3 3 的平均滤波和中值滤波,显示原图像、加噪图像和滤波结果图像,并比较四种滤波结果。代码f=zeros(256,256); for i =23:1:233 for j=28:1:35 f(i,j)=255; end for j=52:1:59 f(i,j)=255; end for j=76:1:83 f(i,j)=255; end for j=100:1:107 f(i,j)=255; end for j=124:1:131 f(i,j)=255; end for j=148:1:155 f(i,j)=255; end for j=172:1:179 f(i,j)=255; end for j=196:1:203 f(i,j)=255; end for j=220:1:227 f(i,j)=255; end endg=imnoise(f,gaussian,0.2);s=imnoise(f,salt & pepper,0.2);k1=filter2(fspecial(average,3),g);G1=round(k1);G2=medfilt2(g);k2=filter2(fspecial(average,3),s);S1=round(k2);S2=medfilt2(s); figure(1)imshow(f)title();figure(2)subplot(3,2,1)imshow(g)title();subplot(3,2,2)imshow(s)title();subplot(3,2,3)imshow(G1)title();subplot(3,2,5)imshow(G2)title();subplot(3,2,4)imshow(S1)title();subplot(3,2,6)imshow(S2)title();结果四、对某一灰度图像,进行如下处理: (1)分别利用 Roberts、Prewitt和Sobel 边缘检测算子进行边缘检测; (2)将Roberts、Prewitt和Sobel 边缘检测算子修改为锐化算子,对原图像进行锐化,同屏显示原图像、边缘检测结果和锐化后图像,说明三者之间的关系。代码f1=imread(C:UsershpPictures1.jpg);f2=rgb2gray(f1);k1=edge(f2,Roberts);k2=edge(f2,Prewitt);k3=edge(f2,Sobel);k4=filter2(fspecial(Prewitt),f2);k5=filter2(fspecial(Prewitt),f2);k6=filter2(fspecial(Sobel),f2); figure(1)subplot(4,2,1)imshow(f1);title(yuanshi);subplot(4,2,2)imshow(f2);title(huidu);subplot(4,2,3)imshow(k1);title(Roberts);subplot(4,2,5)imshow(k2);title(Prewitt);subplot(4,2,7)imshow(k3);title(Sobel);subplot(4,2,4)imshow(k4);title(log);subplot(4,2,6)imshow(k5);title(Prewitt);subplot(4,2,8)imshow(k6);title(Sobel); 结果 五、编程实现教材 214 页所给图像门限化分割的迭代阈值算法,实现对某一灰度图像的二值化。代码f1=imread(C:UsershpPictures11.jpg);f2=rgb2gray(f1);f3=f2;zm=max(f2(:);zi=min(f2(:);k=2;T(k)=(zm+zi)/2;while T(k)=T(k-1); r1=find(f2T(k); k=k+1; T(k)=(mean(f2(r1)+mean(f2(r2)/2; endr3=find(f3T(k);f3(r3)=0;f3(r4)=255; figure(1) subplot(221)imshow(f1)title(原始图像);subplot(222)imshow(f2)title(灰度图像);subplot(223)imshow(f3)title(迭代阈值算法二值化);
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论