[target background segmentation] Graph Cut based Object Segmentation target segmentation, MATLAB simulation of target contour extraction algorithm

clc;
clear;
close all;
warning off;
addpath 'func\'

%%
%参数初始化
%初始图像名称
I             = double(imread('Test_Image\hand.jpg'));
%迭代次数
iter          = 400;         
       
%初始模板,模板在初始的时候只要定义一个较大的矩阵即可
S1                       = size(I,1);
E1                       = size(I,2);
Es                       = 20;
MASK0                    = zeros(S1,E1);
MASK0(Es:S1-Es,Es:E1-Es) = 1;

%转换为二维图
if size(I,3) > 1
   Is = (I(:,:,1)+I(:,:,2)+I(:,:,3))/3;
else
   Is =  I;
end

[Result,Result2,Object] = func_Active_Contour_Flow(Is,I,MASK0,iter);




figure;
subplot(131);
imshow(uint8(I),[]);
hold on
contour(Result,[0,0],'r','linewidth',2); 
subplot(132);
imshow(Result2,[]);
subplot(133);
imshow(uint8(Object));



        

 D208

 

Guess you like

Origin blog.csdn.net/ccsss22/article/details/123977321