数字图像处理上机作业.doc

上传人:s****u 文档编号:12782066 上传时间:2020-05-24 格式:DOC 页数:15 大小:1.32MB
返回 下载 相关 举报
数字图像处理上机作业.doc_第1页
第1页 / 共15页
数字图像处理上机作业.doc_第2页
第2页 / 共15页
数字图像处理上机作业.doc_第3页
第3页 / 共15页
点击查看更多>>
资源描述
数 字 图 像 处 理上机作业 教 师 : 刘清华学 院 : 电子工程学院班 级 : 021141专 业 : 探测制导与控制技术姓 名 : 苏二鹏学 号 : 02114030(1) (2)f1与f2的幅度谱相同,因为f1与f2振幅的绝对值是相同的。(3)f3的幅度谱与f2的幅度谱按顺时针旋转90度后相同(4)f4的幅度谱与f1的幅度谱按顺时针旋转90度后相同(5)f5的幅度谱是f1与f4的幅度谱相加,f6的幅度谱是f2与f3的幅度谱相加程序:f1=zeros(256,256);f1(65:192,113:144)=100;figuresubplot(121)imshow(f1)title(原图f1)F=fft2(f1);subplot(122)imshow(abs(F)title(f1幅度谱图)for m=(1:256); for n=(1:256);f2(m,n)=power(-1,m+n)*f1(m,n); endendfiguresubplot(121)imshow(f2)title(f2图)F1=fft2(f2);subplot(122)imshow(abs(F1)title(f2幅度谱图)f3=imrotate(f2,-90);figuresubplot(121)imshow(f3)title(f3图)F2=fft2(f3);subplot(122)imshow(abs(F2)title(f3幅度谱图)f4=imrotate(f1,-90);figuresubplot(121)imshow(f4)title(f4图)F5=fft2(f4);subplot(122)imshow(abs(F5)title(f4幅度谱图)f5=f1+f4;figuresubplot(121)imshow(f5)title(f5图)F3=fft2(f5)subplot(122)imshow(abs(F3)title(f5幅度谱图)f6=f2+f3;figuresubplot(121)imshow(f6)title(f6图)F4=fft2(f6)subplot(122)imshow(abs(F4)title(f6幅度谱图)256*256图像如下: 从中值滤波和均值滤波后的图像可以看出,中值滤波把黑色方快完全完全隔离开,而白色方块则通过边角的两个多出来的像素点相连,而均值滤波则把图像变模糊了,边缘模糊的比较厉害。中值滤波后图像的直方图没有变化,而均值滤波后的直方图变化了。 程序:A=zeros(256,256);for i=(1:64:256); for j=(1:64:256); A(j:j+32,i:i+32)=1;endendfor m=(32:64:256); for n=(32:64:256); A(n:n+32,m:m+32)=1; endendfigureimshow(A)title(原图像)figureK=medfilt2(A,3,3)subplot(121)imshow(K)title(3*3中值滤波)M=filter2(fspecial(average,3),A)subplot(122)imshow(M)title(3*3均值值滤波) figuresubplot(131)imhist(A)axis(0 2 0 2)title(原图直方图)subplot(132)imhist(K)axis(0 2 0 2)title(中值滤波后的直方图)subplot(133)imhist(M)axis(0 2 0 2)title(均值滤波后的直方图) 整体而言中值滤波的结果比均值滤波的结果要好,均值滤波模糊了轮廓边缘,但是中值滤波对椒盐噪声的滤波破坏了轮廓边缘。中值滤波对高斯噪声的水平滤波不是很好。程序:I=zeros(256,256);for i=(32:24:224); I(23:233,i:i+7)=1;endfigureimshow(I)title(原图像)A=imnoise(I,gaussian,0,0.025);figuresubplot(121)imshow(A)title(高斯白噪声)B=imnoise(I,salt & pepper,0.025);subplot(122)imshow(B)title(椒盐噪声)h=1 1 1;1 1 1;1 1 1;%领域平均法消除噪声模板为1/91 1 1;1 1 1;1 1 1h=9./h;Ja=conv2(A,h);figuresubplot(121)imshow(Ja,)title(对高斯白噪声的均值滤波)Jb=conv2(B,h);subplot(122)imshow(Jb,)title(对椒盐噪声的均值滤波)Ka=medfilt2(A,3,3)figuresubplot(121)imshow(Ka,)title(对高斯白噪声的中值滤波)Kb=medfilt2(B,3,3);subplot(122)imshow(Kb,)title(对椒盐噪声的中值波)roberts自动选择的阈值为: 0.1305sobel自动选择的阈值为: 0.1162prewitt自动选择的阈值为: 0.1138程序:I=imread(rice.png);figureimshow(I)title(原始图像)BW1,thresh1=edge(I,roberts);disp(roberts自动选择的阈值为:)disp(thresh1)figuresubplot(131)imshow(BW1)title(roberts算子)BW2,thresh2=edge(I,sobel);disp(sobel自动选择的阈值为:)disp(thresh2)subplot(132)imshow(BW2)title(sobel算子)BW3,thresh3=edge(I,prewitt);disp(prewitt自动选择的阈值为:)disp(thresh3)subplot(133)imshow(BW3)title(prwitte算子) BW4=filter2(fspecial(Prewitt),I);BW5=filter2(fspecial(Prewitt),I);BW6=filter2(fspecial(Sobel),I); figuresubplot(2,2,1);imshow(I);title(灰度图像);subplot(2,2,2);imshow(BW4); title(Roberts的锐化结果); subplot(2,2,3);imshow(BW5);title(Prewitt的锐化结果);subplot(2,2,4);imshow(BW6);title(Sobel的锐化结果);迭代后的阈值:131程序:clear all;I=imread(rice.png);ZMAX=max(max(I);ZMIN=min(min(I);TK=(ZMAX+ZMIN)/2;bcal=1;ISIZE=size(I);while(bcal) ifground=0; ibground=0; FgroundS=0; BgroundS=0; for i=1:ISIZE(1) for j=1:ISIZE(2) tmp=I(i,j); if(tmp=TK) ifground=ifground+1; FgroundS= FgroundS+double(tmp); else ibground=ibground+1; BgroundS= BgroundS+double(tmp); end endend ZO=FgroundS/ifground;ZB=BgroundS/ibground;TKTmp=uint8(ZO+ZB)/2);if(TKTmp=TK) bcal=0;else TK=TKTmp;endend disp(strcat(迭代后的阈值:,num2str(TK);newI=im2bw(I,double(TK)/255);subplot(121)imshow(I)title(原始图像)subplot(122)imshow(newI)title(迭代法分割得到的二值图像)
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!