资源简介

基于区域生长的图像分割,可以自己设置区域生长点。区域生长是一种串行区域分割的图像分割方法。区域生长是指从某个像素出发,按照一定的准则,逐步加入邻近像素,当满足一定的条件时,区域生长终止。

资源截图

代码片段和文件信息

clc;
clear all;
close all;
% path=input(‘Enter path of the image :‘‘s‘);
rgb=imread(‘2.jpg‘);
grimg=rgb2gray(rgb);
siz=size(grimg);
row=siz(1);
col=siz(2);
fin=zeros(size(grimg));
dup=fin;
imshow(grimg);
impixelinfo;
grimg=double(grimg);
for a=1:2
stx=input(‘Enter Row no :‘);
sty=input(‘Enter column no :‘);
th=input(‘Enter thershold :‘);
count=0;
while length(stx)~=0
count=count+1;
display([‘Pixels added :‘num2str(count)]);
ls=length(stx);
sr=stx(ls);
sc=sty(ls);
svalue=grimg(srsc);
stx=stx(1:ls-1);
sty=sty(1:ls-1);
if ls==1
stx=[];
sty=[];
end
for i=sr-1:sr+1
    if i==0 || i==row+1
        continue
    end
    for j=sc-1:sc+1;
        if j==0 || j==col+1
            continue
        end
        dif=grimg(ij)- svalue;
        if abs(dif)<=th
            if dup(ij)~=1
            stx=[stx i];
            sty=[sty j];
            fin(ij)=grimg(ij);
            dup(ij)=1;
            end
        end
    end
end
end
figure;
subplot(121);
imshow(uint8(grimg));title(‘Original image‘);
impixelinfo;
subplot(122);
imshow(uint8(fin));hold on;
title(‘Grown image‘);
impixelinfo;
end
imhist(uint8(fin));

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        6525  2014-12-16 20:55  ins_seg\1.jpg
     文件        3730  2014-12-16 16:21  ins_seg\2.jpg
     文件        1179  2014-12-25 11:41  ins_seg\ins_seg.m
     文件        1533  2014-11-05 03:22  ins_seg\license.txt
     目录           0  2014-12-25 11:15  ins_seg\

评论

共有 条评论