收藏 分享(赏)

一维最大熵法对图片进行分割.doc

上传人:11xg27ws 文档编号:9297687 上传时间:2019-08-01 格式:DOC 页数:2 大小:13.50KB
下载 相关 举报
一维最大熵法对图片进行分割.doc_第1页
第1页 / 共2页
一维最大熵法对图片进行分割.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

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);m n k=size(img);p=zeros(256,1);for i=1:mfor j=1:np(img(i,j,1)+1)=p(img(i,j,1)+1)+1;end;end;p=p/(m

2、*n);temp=10;ht=0;Qt=0;for t=12:255ht=0;hn=0;pt=sum(p(1:t);pn=sum(p); for i=1:tif(p(i)0)ht=ht+log2(p(i)*p(i)*(-1);end;end;for i=1:256if(p(i)0)hn=hn+log2(p(i)*p(i)*(-1);end;end;if(pt0)if(ht/pt+(hn-ht)/(1-pt)+log2(pt*(1-pt)Qt)Qt=ht/pt+(hn-ht)/(1-pt)+log2(pt*(1-pt);temp=t;end; end;end;for i=1:mfor j=1:nif(img(i,j,1)temp)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);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报