二维最大熵阈值分割法

上传人:mg****85 文档编号:35853677 上传时间:2018-03-21 格式:DOC 页数:3 大小:18.50KB
返回 下载 相关 举报
二维最大熵阈值分割法_第1页
第1页 / 共3页
二维最大熵阈值分割法_第2页
第2页 / 共3页
二维最大熵阈值分割法_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《二维最大熵阈值分割法》由会员分享,可在线阅读,更多相关《二维最大熵阈值分割法(3页珍藏版)》请在金锄头文库上搜索。

1、% 二维最大熵阈值分割法 % filename,pathname=uigetfile; img=imread(strcat(pathname,filename); figure(1); subplot(221); imshow(img); subplot(222); imhist(img(:,1); subplot(223); imhist(img(:,2); subplot(224); imhist(img(:,3); % 这个地方出现了一个问题就是为什么 MidValue=img(i,j-1,1) +img(i-1,j,1)+img(i % +1,j,1)+img(i,j+1,1)最大值为

2、 256,难道是默认的一个 BYTE 类型 吗? p=zeros(256,256); m,n,k=size(img); for i=2:m-1for j=2:n-1MidValue=img(i,j-1,1)/4+img(i-1,j,1)/4+img(i+1,j,1)/4+img(i,j+1,1)/4;MidValue=round(MidValue);p(img(i,j,1)+1,MidValue+1)=p(img(i,j,1)+1,MidValue+1)+1;end; end; %图像的四个角,只有 2 领域的点儿 p(img(1,1,1)+1,round(img(1,2,1)/2+img(2

3、,1,1)/2)+1)=p(img(1,1,1)+1,round(img(1,2,1)/2+img( 2,1,1)/2)+1)+1; p(img(1,n,1)+1,round(img(1,n-1,1)/2+img(2,n,1)/2)+1)=p(img(1,n,1)+1,round(img(1,n- 1,1)/2+img(2,n,1)/2)+1)+1; p(img(m,1,1)+1,round(img(m-1,1,1)/2+img(m,2,1)/2)+1)=p(img(m,1,1)+1,round(img(m- 1,1,1)/2+img(m,2,1)/2)+1)+1; p(img(m,n,1)+

4、1,round(img(m,n-1,1)/2+img(m-1,n,1)/2)+1)=p(img(m,n,1)+1,round(img(m,n- 1,1)/2+img(m-1,n,1)/2)+1)+1; %图像周围的一圈,只有 3 领域的点儿 for j=2:n-1MidValue=img(1,j-1,1)/3+img(1,j+1,1)/3+img(2,j,1)/3;MidValue=round(MidValue);p(img(1,j,1)+1,MidValue+1)= p(img(1,j,1)+1,MidValue+1,1)+1; end; for j=2:n-1MidValue=img(m,

5、j-1,1)/3+img(m,j+1,1)/3+img(m-1,j,1)/3;MidValue=round(MidValue);p(img(m,j,1)+1,MidValue+1)= p(img(m,j,1)+1,MidValue+1)+1; end; for i=2:m-1MidValue=img(i-1,1,1)/3+img(i+1,1,1)/3+img(i,2,1)/3;MidValue=round(MidValue);p(img(i,1,1)+1,MidValue+1)= p(img(i,1,1)+1,MidValue+1)+1; end; for i=2:m-1MidValue=im

6、g(i-1,n,1)/3+img(i+1,n,1)/3+img(i,n-1,1)/3;MidValue=round(MidValue);p(img(i,n,1)+1,MidValue+1)= p(img(i,n,1)+1,MidValue+1)+1; end; p=p/(m*n);% 忽略噪音的影响 % pa=0; ha=0; hn=0; s=10; t=10; Qst=0; temp_t=10; temp_s=10; for i=1:256for j=1:256if(p(i,j)0)hn=hn+log2(p(i,j)*p(i,j)*(-1);end;end; end;for t=10:256

7、for s=10:256ha=0;pa=0;for i=1:tfor j=1:spa=pa+p(i,j);end;end;for i=1:tfor j=1:sif(p(i,j)0)ha=ha+log2(p(i,j)*p(i,j)*(-1);end;end;end;if(pa0temp_t=t;temp_s=s;end; end;end; end;for i=1:mfor j=1:nif(img(i,j,1)temp_s)img(i,j,1)=255;img(i,j,2)=255;img(i,j,3)=255;elseimg(i,j,1)=0;img(i,j,2)=0;img(i,j,3)=0;end;end; end; figure(2); imshow(img);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号