设为首页 加入收藏

TOP

Matlab实现图像分割
2015-11-21 02:04:39 来源: 作者: 【 】 浏览:6
Tags:Matlab 实现 图像 分割

下面使用极小值点阈值选取方法,编写MATLAB程序实现图像分割的功能。

极小值点阈值选取法即从原图像的直方图的包络线中选取出极小值点,

并以极小值点为阈值将图像转为二值图像


clear all;
close all ;
G=imread('rabbit.png');
figure();
subplot(2,2,1);
imshow(G);
subplot(2,2,2);
imhist(G);
subplot(2,2,3);
imhist(G);
[h,x]=imhist(G);
h=smooth(h,7);
plot(x,h)
%求出阈值T
df1=diff(h);%一阶差分
df2=diff(df1);%二阶差分
[m,n]=size(df2);
T=0;
for i=1:m
if(abs(df1(i+1))<=0.15 && df2(i)>0)
    T=x(i+2)%确定阈值
    break;
end
end
G=im2bw(G,T/255);%转为二值图像
subplot(2,2,4);
imshow(G);


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇最小生成树 下一篇NYOJ 1058 部分和问题 [DFS]

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: