【数字图像处理matlab】(区域生长影像分割算法)

【数字图像处理matlab】(区域生长影像分割算法)

一个效果不是很好的区域生长影像分割算法,需要自己设置一个阈值,分割的结果好坏也与阈值有关系,仅供参考啦。

function F=grow_seg(image)
%调用代码--------------------------------------
%image=rgb2gray(imread('eye.jpg'));
%grow_seg(image);
%---------------------------------------------

X=imhist(image);
[row,column]=size(image);
X=X';
[~,index]=max(X);
seed=index-1;flag=0;
T=5;     %根据自己的影像特点设置一个阈值
for i=1:row
    for j=1:column
        if image(i,j)==seed
            flag=1;
            break;
        end   
    end
    if flag==1;
     break;
    end
end
image1=zeros(row,column);
image1(i,j)=1;
for i=1:row
    for j=1:column
        m=abs(image(i,j)-seed);
        if m<=T
            image1(i,j)=1;
        end
    end
end
subplot(1,2,1);imshow(image);
title('原图像');
subplot(1,2,2);imshow(image1);
title('生长算法区域分割后的影像');
end

测试:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/gsgs1234/article/details/124144957