![]() |
图挖掘Matlab
我已经编写了一些用于图像分析的matlab代码,该代码在图像中搜索簇,并为这些簇建立邻接矩阵,从而说明哪些簇在图像中相互影响。
我可以使用此邻接矩阵来得出图。 为了完成算法,我现在必须为最大度为2的所有节点挖掘该图,其中节点索引高于其neigbor(当度为1时)或其两个邻居的索引之间。 基本上如此处的图片所示: [IMG]https://i.stack.imgur.com/e8hMS.png[/IMG] 我需要在matlab中这样做,重要的是要知道我的尝试可以作为邻接矩阵来使用,如下所示: 1 2 3 4 1 0 0 1 1 2 0 0 0 1 3 1 0 0 1 4 1 1 1 0 可能很简单,但我看不到解决方案... [B]回答:[/B] 这是我的尝试: %# adjacency matrix M = [0 0 1 1; 0 0 0 1; 1 0 0 1; 1 1 1 0]; %# degree == 1 N = find(sum(M,2) == 1); %# nodes with degree(N)==1 nodes1 = N(N>find(M(N,:))); %# nodes where its index is higher than that of its neigbor %# degree == 2 N = find(sum(M,2) == 2); %# nodes with degree(N)==2 Nb = zeros(numel(N),2); for i=1:numel(N) Nb(i,:) = find( M(N(i),:) ); %# two-neighbors of node N(i) end %#Nb = sort(Nb,2); nodes2 = N(Nb(:,1) |
所有时间均为北京时间。现在的时间是 22:20。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.