MHT代碼閱讀(3)
3. updateClusters
3.1 論文內容
聚類的程序是將通過共同觀察鏈接起來的所有軌跡的集合,共享觀測的軌跡被定義為不兼容的,并且每次掃描都保留不兼容軌跡的記錄,當軌跡被洗掉以及根據當前掃描的觀察結果形成新軌跡時,該記錄會更新,

一個集群可以包括不直接共享觀測但都與第三個跟蹤共享觀測的軌跡,因此,如果軌道 1 與軌道 2 共享一個觀測值,而軌道 2 與軌道 3 共享另一個觀測值,則所有三個軌道都在同一個集群中,標準演算法可用于聚類,
具有大量軌道的集群的形成可能導致假設形成所需的時間量無法接受,因此,為了維護包含不超過數百個軌道的集群,采用了稍后討論的幾種技術,
聚類的結果是相互作用的軌跡串列(通過共同觀察鏈接),這些軌跡按 LLR(前面討論的評分函式)的順序排列,下一步是形成兼容軌道的假設,
3.2 代碼閱讀
-
每個樹節點都可以通過它的 familyID 和 trackID 訪問
- 初始化 familyNo 和 other_param.currentTrackNo
- 利用cell函式初始化 clusterFamilyList 和 clusterFamilyIndex
- %cell陣列一般被叫做元胞陣列,它的每個單元可以儲存不同的資料型別,可以是數值,字符或矩陣或元胞陣列等,類似于學過的c語言里的結構體
- %利用函式cell() 可以創建一個元胞陣列,還可以規定其大小,cell(familyNo,1)表示 行數=familyNo,列數=1
- 利用zeros函式初始化familyClusters
-
進入回圈,得到 ICL_sel 和 clusterFamilyList{i}
- %sel為select的簡寫?
- %unique篩除向量中的重復值,產生的結果按升序排列
-
進入回圈得到 clusterFamilyIndex{i}
-
進入while回圈,得到 familyClusters(clusterFamilyIndex{i})=w
-
ICL_clusters=cell(w,1); clusters=cell(w,1);
-
-
進入回圈,更新 ICL_sel 、ICL_clusters{k} 、clusters{k}
- %cellfun將函式用于元胞陣列中的每個cell,isempty(A) ;判斷A是否為空,如果為空,結果為1,否則為0.
-
計算每個簇中的軌道數
3.3 代碼附錄
function [clusters,ICL_clusters,other_param]=updateClusters...
(incompabilityListTreeSet, incompabilityListTreeNodeIDSet, ...
activeTreeSet, other_param)
%%
% Each tree node can be accessed by its familyID and trackID
familyNo=length(incompabilityListTreeSet);
other_param.currentTrackNo=0;
if familyNo == 0
clusters=[];
ICL_clusters=[];
return
end
%cell陣列一般被叫做元胞陣列,它的每個單元可以儲存不同的資料型別,可以是數值,字符或矩陣或元胞陣列等,類似于學過的c語言里的結構體
clusterFamilyList=cell(familyNo,1);%利用函式cell() 可以創建一個元胞陣列,還可以規定其大小,行數=familyNo,列數=1
clusterFamilyIndex=cell(familyNo,1);
%回傳一個familyNo*1的0矩陣
familyClusters=zeros(familyNo,1);
for i=1:familyNo
treeInd=findleaves(incompabilityListTreeSet(i));
%sel為select的簡寫?
ICL_sel=[];
for j=treeInd
if activeTreeSet(i).get(j) ~= 1
continue;
end
ICL_sel_tmp=incompabilityListTreeNodeIDSet(i).get(j);
ICL_sel=[ICL_sel; ICL_sel_tmp(:,1)];
end
%unique篩除向量中的重復值,產生的結果按升序排列
ICL_sel=unique(ICL_sel);
clusterFamilyList{i}=ICL_sel;
end
for i=1:length(clusterFamilyList)
ICL_sel=clusterFamilyList{i};
clusterFamilyIndex{i}=i;
if i ~= length(clusterFamilyList)
for j=i+1:length(clusterFamilyList)
ICL_sel2=clusterFamilyList{j};
for k=1:length(ICL_sel2)
if sum(ICL_sel == ICL_sel2(k)) ~= 0
clusterFamilyIndex{i}=[clusterFamilyIndex{i}; j];
break;
end
end
end
end
end
w=0;
todolist=1:familyNo;
%~isempty(A) ;表示將 isempty(A) 的結果取反,也就是說如果A為空,結果為0,否則為1,
while ~isempty(todolist)
w=w+1;
i=todolist(1);
cl_index=clusterFamilyIndex{i};
cl_index=cl_index';
for j=cl_index
if i == j
continue;
end
clusterFamilyIndex{i}=[clusterFamilyIndex{i}; clusterFamilyIndex{j}];
clusterFamilyIndex{j}=[];
end
clusterFamilyIndex{i}=unique(clusterFamilyIndex{i});
todolist=setdiff(todolist,cl_index');
if sum(familyClusters(clusterFamilyIndex{i})) == 0
familyClusters(clusterFamilyIndex{i})=w;
else
cl_parent=find(familyClusters(clusterFamilyIndex{i})~=0);
clusterNums=unique(familyClusters(clusterFamilyIndex{i}(cl_parent)));
for k=1:length(clusterNums)
indSel=find(familyClusters==clusterNums(k));
familyClusters(indSel)=w;
end
familyClusters(clusterFamilyIndex{i})=w;
end
end
ICL_clusters=cell(w,1);
clusters=cell(w,1);
for k=1:max(familyClusters)
ICL_sel=[];
ICL_Ind_sel=[];
indSel=find(familyClusters == k);
indSel=indSel';
for i=indSel
treeInd=findleaves(incompabilityListTreeSet(i));
for j=treeInd
if activeTreeSet(i).get(j) ~= 1
continue;
end
ICL_sel_tmp=incompabilityListTreeSet(i).get(j);
ICL_sel=[ICL_sel; ICL_sel_tmp(:,2)];
ICL_Ind_sel=[ICL_Ind_sel; [i j]];
end
end
ICL_sel=unique(ICL_sel);
ICL_clusters{k}=ICL_sel;
clusters{k}=ICL_Ind_sel;
end
%cellfun將函式用于元胞陣列中的每個cell,isempty(A) ;判斷A是否為空,如果為空,結果為1,否則為0.
ICL_clusters(cellfun('isempty',ICL_clusters))=[];
clusters(cellfun('isempty',clusters))=[];
% count the number of tracks in each cluster
other_param.currentTrackNo=zeros(length(clusters),1);
for i=1:length(clusters)
%其中r=size(A,1)該陳述句回傳的是矩陣A的行數, c=size(A,2) 該陳述句回傳的是矩陣A的列數
other_param.currentTrackNo(i)=size(clusters{i},1);
if size(clusters{i},1) ~= size(ICL_clusters{i},1)
error('error');
end
end
end
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/302161.html
標籤:AI
下一篇:論文解讀 - An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
