网站大量收购独家精品文档,联系QQ:2885784924

MATLAB图像分析程序大禁律法迭代法.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MATLAB图像分析程序大禁律法迭代法

MATLAB图像分析程序 (2009-04-07 08:59:25)  HYPERLINK javascript:; 转载 标签:  HYPERLINK /c.php?t=blogk=matlabts=bpoststype=tag \t _blank matlab  HYPERLINK /c.php?t=blogk=%D4%D3%CC%B8ts=bpoststype=tag \t _blank 杂谈1.迭代法 I=imread(rice.png); ZMax=max(max(I)); ZMin=min(min(I)); TK=(ZMax+ZMin)/2; bCal=1; iSize=size(I); while(bCal) iForeground=0; iBackground=0; ForegroundSum=0; BackgroundSum=0; for i=1:iSize(1) for j=1:iSize(2) tmp=I(i,j); if(tmp=TK) iForeground=iForeground+1; ForegroundSum=ForegroundSum+double(tmp); else iBackground=iBackground+1; BackgroundSum=BackgroundSum+double(tmp); end end end ZO=ForegroundSum/iForeground; ZB=BackgroundSum/iBackground; TKTmp=uint8((ZO+ZB)/2); if(TKTmp==TK) bCal=0; else TK=TKTmp; end end disp(strcat(迭代后的域值:,num2str(TK))); newI=im2bw(I,double(TK)/255); subplot(121),imshow(I) subplot(122),imshow(newI) 运行结果:迭代后的域值:131 2.大津法 %大津法 I=imread(coins.png); subplot(131),imshow(I); title(原始图像) level=graythresh(I); BW=im2bw(I,level); subplot(132),imshow(BW) title(graythresh计算阈值) disp(strcat(graythresh计算灰度阈值:,num2str(uint8(level*255)))) iMax=max(max(I)); iMin=min(min(I)); T=double(iMin:iMax); iSize=size(I); muxSize=iSize(1)*iSize(2); for i=1:length(T) TK=T(1,i); iForeground=0; iBzckground=0; ForegroundSum=0; BzckgroundSum=0; for j=1:iSize(1) for k=1:iSize(2) tmpData=I(j,k); if(tmpData=TK) iForeground=iForeground+1; ForegroundSum=ForegroundSum+double(tmpData); else iBackground=iBackground+1; BackgroundSum=BackgroundSum+double(tmpData); end end end w0=iForeground/muxSize; w1=iBackground/muxSize; u0=ForegroundSum/iForeground; u1=BackgroundSum/iBackground; T(2,i)=w0*w1*(u0-u1)*(u0-u1); end oMax=max(T(2,:); idx=find(T(2,:)=oMax); T=uint8(T(1,idx)); disp(strcat(简化大津法计算灰度阈值:,num2str(T))) BW=im2bw(I,double(T)/255); subplot(133),imshow(BW) title(简化大津法计算灰度阈值)运行结果: graythresh计算灰度阈值:126

文档评论(0)

cgtk187 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档