图像处理采用最大熵方法进行图像分割.docx
- 文档编号:235736
- 上传时间:2022-10-07
- 格式:DOCX
- 页数:8
- 大小:167.92KB
图像处理采用最大熵方法进行图像分割.docx
《图像处理采用最大熵方法进行图像分割.docx》由会员分享,可在线阅读,更多相关《图像处理采用最大熵方法进行图像分割.docx(8页珍藏版)》请在冰豆网上搜索。
数字图象处理课程设计
题目:
采用最大熵方法进行图像分割
班级:
电信121
学号:
3120412014
姓名:
吴向荣
指导老师:
王栋
起止时间:
2016.1.4~2016.1.8
西安理工大学
源代码:
clear,clc
image=imread('C:
\Users\Administrator\Desktop\图像课设\3.jpg');
subplot(2,2,1);imshow(image);title('原始彩图')
%%%灰度图
imagegray=rgb2gray(image);%彩色图转换为灰度图
subplot(2,2,2);imshow(imagegray);title('灰度图')
%计算灰度直方图分布counts和x分别为返回直方图数据向量和相应的彩色向量
count=imhist(imagegray);
subplot(2,2,3);imhist(imagegray);title('灰度直方图')
[m,n]=size(imagegray);
imagegray=fun_maxgray(count,imagegray,m,n);
subplot(2,2,4);imshow(imagegray);title('最大熵处理后的图')
%%彩色图
%r=image(:
:
1);countr=imhist(r);r=fun_maxgray(countr,r,m,n);
%subplot(2,2,1);imshow(r);
%g=image(:
:
2);countg=imhist(g);g=fun_maxgray(countg,g,m,n);
%subplot(2,2,2);imshow(g);
%b=image(:
:
3);countb=imhist(b);b=fun_maxgray(countb,b,m,n);
%subplot(2,2,3);imshow(b);
b=0;
forz=1:
3
figure
titleName=strcat('第',num2str(z),'通道灰度直方图');
titleName1=strcat('第',num2str(z),'通道最大熵处理后图');
a=image(:
:
z);subplot(1,2,1);imhist(a);title(titleName)
countr=imhist(a);a=fun_maxgray(countr,a,m,n);
subplot(1,2,2);imshow(a);title(titleName1)
b=b+a;
end
figure,imshow(b);title('彩色各通道处理后叠加图')
最大熵方法进行图像分割的子函数:
functionsample=fun_maxgray(count,sample,m,n)
countp=count/(m*n);%每一个像素的分布概率
E=[];
E1=0;
E2=0;
L=256;
forth=2:
L-1%循环阈值
pth=sum(countp(1:
th+1));%计算对应阈值概率
ifcountp(th)==0%当阈值概率为0跳出当前循环
continue;
end
fori=1:
th
ifcountp(i)==0%当前像素概率为0,跳出当前循环
continue;
end
E1=E1-countp(i)/pth*log(countp(i)/pth);
end
fori=th-1:
L
ifcountp(i)==0
continue;
end
E2=E2-countp(i)/(1-pth)*log(countp(i)/(1-pth));
end
e=E1+E2;
E=[Ee];
end
th=find(E==(max(E)));%找数组中最大值的阈值
%[ma,index]=max(E);
fori=1:
m%对图像二值化
forj=1:
n
ifsample(i,j)>th
sample(i,j)=255;
else
sample(i,j)=0;
e
运行结果:
其他图片比较:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 图像 处理 采用 最大 方法 进行 分割