Normalized Cuts and Image Segmentation

本文介绍了一种使用Matlab实现的N-Cut图像分割算法。该算法通过构建图模型来分割图像,其中节点代表像素,边的权重反映像素间的相似度。通过最小化N-Cut准则来确定最优分割,最终实现图像的有效分割。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


    上图中每两个节点之间都有个权值,权值的值在代码中有给出。
%2014-9-23
%writed by Tianliang
%Ncut test
M = [6.1 3.5 5 6.3 3.7 3.6 2.6];
D = diag(M);
disp(D);
W = [0 1 1.5 3 0.5 0.1 0;
    1 0 1.5 1 0 0 0;
    1.5 1.5 0 2 0 0 0;
    3 1 2 0 0.2 0 0.1;
    0.5 0 0 0.2 0 2 1;
    0.1 0 0 0 2 0 1.5;
    0 0 0 0.1 1 1.5 0];
disp(W);
a=round(2*rand(10000,7)-1);
for i = 1:10000
    for j = 1:7
        if a(i,j)>0 
            a(i,j)=1;
        else
            a(i,j)=-1;
        end
    end
end
disp(D-W);
%x = [1 1 1 1 -1 -1 -1]';
%disp('1+x'),disp(1+x);
term = zeros(1,10000);
for i = 1:10000
    x=a(i,:)';
    D_sum = 0;
    for j = 1:7
        if x(j,1)==1
            D_sum = D_sum + D(j,j);
        end
    end
    k = D_sum/sum(sum(D));
    %disp('k = '),disp(k);
    term1 =((1+x)'*(D-W)*(1+x))/(k*ones(7,1)'*D*ones(7,1));
    term2 =((1-x)'*(D-W)*(1-x))/((1-k)*ones(7,1)'*D*ones(7,1));
    term(1,i) = term1 + term2;
    %disp('term = '),disp(term(i));
end
[term_min,term_coord]=min(term);
disp('rouping at minimum cut:'),disp(a(term_coord,:));
[V,D]=eig(D^(-(1/2))*(D-W)*(D^(-1/2)));
nbSegments = 2;
V=V(:,1:nbSegments);
[EigenvectorsDiscrete,EigenVectors]=discretisation(V);
EigenvectorsDiscrete=full(EigenvectorsDiscrete);
disp('EigenvectorsDiscrete = '),disp(EigenvectorsDiscrete');




 ABsum
Aassoc(A,A)cut(A,B)assoc(A,V)
Bcut(B,A)assoc(B,B)assoc(B,V)
sumassoc(A,V)assoc(B,V) 

论文中的matlab代码:http://download.youkuaiyun.com/detail/tianliangjay/7976791



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值