声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 889|回复: 0

谢谢各位兄弟帮个忙啊

[复制链接]
发表于 2006-5-23 20:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
<P>有那位兄弟帮助我下吗?运行下下面这个程序,随便帮我找副图,得到最后的三副图,我毕业设计用。万分感谢啊  ,或者酬谢,</P>
<P ><FONT face="Times New Roman">function[X,map]=im(in1,in2)%</FONT>将非索引图像转换成索引图像,<FONT face="Times New Roman">in1</FONT>为文件名,<FONT face="Times New Roman">in2</FONT>为文件格式。<FONT face="Times New Roman">%</FONT></P>
<P ><FONT face="Times New Roman">if nargin==2</FONT></P>
<P ><FONT face="Times New Roman">if errargn(m filename,nargin,[2],nargout,[0:2]),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">g=in1;type=in2;</FONT></P>
<P ><FONT face="Times New Roman">if errargt(m filename,g,‘str</FONT>′<FONT face="Times New Roman">),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">iferrargt(m filename,type,</FONT>′<FONT face="Times New Roman">str</FONT>′<FONT face="Times New Roman">),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">if=im read(g,type);</FONT></P>
<P ><FONT face="Times New Roman">if strcmp(type,</FONT>′<FONT face="Times New Roman">bmp</FONT>′<FONT face="Times New Roman">)</FONT>︱<FONT face="Times New Roman">strcmp(type,</FONT>′<FONT face="Times New Roman">jpg</FONT>′<FONT face="Times New Roman">),[X,map]=rgb2ind(f);end</FONT></P>
<P ><FONT face="Times New Roman">end</FONT></P>
<P >下面我们将介绍三种方法:强制消噪、默认阈值消噪和独立阈值消噪。为以后验证我们的消噪效果,我们人为的做一加噪函数<FONT face="Times New Roman">addnoise:</FONT></P>
<P ><FONT face="Times New Roman">function[g]=addnoise(in1,in2,in3)%</FONT>加噪声函数,<FONT face="Times New Roman">in1</FONT>为文件名,<FONT face="Times New Roman">in2</FONT>为文件格式,<FONT face="Times New Roman">in3</FONT>为一整数,<FONT face="Times New Roman">g</FONT>为含噪图像。</P>
<P ><FONT face="Times New Roman">if  nargin==3</FONT></P>
<P ><FONT face="Times New Roman">if errargn(m filename,nargin,[3],nargout,[0:1]),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">[X,map]=im(in1,in2);n=in3;</FONT></P>
<P ><FONT face="Times New Roman">if errargt(m filename,in1,’str’),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">if errargt(m filename,in2,’str’),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">if errargt(m filename,n,’int’),error(‘3’);end</FONT></P>
<P ><FONT face="Times New Roman">init=2055615866;randn(‘seed’,init);g=X+n*randn(size(X));end</FONT></P>
<P ><FONT face="Times New Roman">X,map]=im(‘a:\.cprod.bmp’, ‘bmp’);</FONT></P>
<P ><FONT face="Times New Roman">save f0 X map;</FONT></P>
<P ><FONT face="Times New Roman">%</FONT>加噪并画出含噪声图像</P>
<P ><FONT face="Times New Roman">[g]=addnoise(‘a:.\cprod.bmp’, ‘bmp’,15);</FONT></P>
<P ><FONT face="Times New Roman">figure(2)</FONT></P>
<P ><FONT face="Times New Roman">subplot(221);subimage(g,map);title(</FONT>′含噪声图像′<FONT face="Times New Roman">);</FONT></P>
<P ><FONT face="Times New Roman">%</FONT>强制消噪</P>
<P ><FONT face="Times New Roman">[c,s]=wavedec2(g,3,</FONT>′<FONT face="Times New Roman">sym4</FONT>′<FONT face="Times New Roman">); %</FONT>用小波函数<FONT face="Times New Roman">sym4</FONT>对图像进行<FONT face="Times New Roman">3</FONT>层小波分解</P>
<P ><FONT face="Times New Roman">a3=wrcoef2(</FONT>′<FONT face="Times New Roman">a</FONT>′<FONT face="Times New Roman">,c,s,</FONT>′<FONT face="Times New Roman">sym4</FONT>′<FONT face="Times New Roman">,3); </FONT></P>
<P ><FONT face="Times New Roman">save f1 a3;%</FONT>保存强制消噪后的结果<FONT face="Times New Roman">a3</FONT>到<FONT face="Times New Roman">f1</FONT>中</P>
<P ><FONT face="Times New Roman">%</FONT>默认阈值消噪</P>
<P ><FONT face="Times New Roman">%</FONT>用<FONT face="Times New Roman">ddencmp</FONT>获取在消噪过程中的默认阈值</P>
<P ><FONT face="Times New Roman">[thr,sorh,keepapp]=ddencmp(</FONT>′<FONT face="Times New Roman">den</FONT>′<FONT face="Times New Roman">,wv</FONT>′<FONT face="Times New Roman">, ,g);</FONT></P>
<P ><FONT face="Times New Roman">subplot(221);subimage(g,map;title(</FONT>′含噪声图像<FONT face="Times New Roman">)</FONT>′<FONT face="Times New Roman">);</FONT></P>
<P ><FONT face="Times New Roman">g0=wdencmp(</FONT>′<FONT face="Times New Roman">gb1</FONT>′<FONT face="Times New Roman">,g,</FONT>′<FONT face="Times New Roman">sym4</FONT>′<FONT face="Times New Roman">,3,thr,sorh,keepapp);</FONT></P>
<P ><FONT face="Times New Roman">subplot(222);subimage(g0,map);title(</FONT>′全阈值消噪后的图像′<FONT face="Times New Roman">);</FONT></P>
<P ><FONT face="Times New Roman">%</FONT>独立阈值消噪</P>
<P ><FONT face="Times New Roman">thrh=[122,124,145];thrv=[123,148,150];thrd=[108,134,160];</FONT></P>
<P ><FONT face="Times New Roman">thrh=[122,124,145];thrv=[123,148,150];thrd=[108,134,160];</FONT></P>
<P ><FONT face="Times New Roman">thr=[thr&shy;_h; thr&shy;_d; thr&shy;_v]; %</FONT>设置水平、垂直、斜线方向阈值</P>
<P ><FONT face="Times New Roman">g1=wdencmp(</FONT>′<FONT face="Times New Roman">lvd</FONT>′<FONT face="Times New Roman">,g,</FONT>′<FONT face="Times New Roman">sym4</FONT>′<FONT face="Times New Roman">,3,thr,</FONT>′<FONT face="Times New Roman">h</FONT>′<FONT face="Times New Roman">);%</FONT>采取每层不同阈值进行消噪</P>
<P ><FONT face="Times New Roman">subplot(223);subimage(g1,map);title(</FONT>′独立阈值消噪后的图像′<FONT face="Times New Roman">);</FONT></P>
<P ><FONT face="Times New Roman">save f2 g0 g1;%</FONT>保存默认阈值消噪后的结果<FONT face="Times New Roman">g0</FONT>和独立阈值消噪后的结果<FONT face="Times New Roman">g1</FONT>到<FONT face="Times New Roman">f2</FONT>中</P>
<P>我不胜感激哦   等你们的好消息 </P>
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-20 11:25 , Processed in 0.077570 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表