Home > track > corTable.m

corTable

PURPOSE ^

SYNOPSIS ^

function [H idTable feaTab] = corTable(tracks,frame,mergeCells,splitCells_,splitCells,P)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [H idTable feaTab] = corTable(tracks,frame,mergeCells,splitCells_,splitCells,P)
0002 l = length(tracks);
0003 m = size(mergeCells,1);
0004 
0005 H = Inf(l+m+size(splitCells_,1),frame.nCells+size(splitCells,1));
0006 idTable = struct([]);
0007 feaTab = struct([]);
0008 collideSet = [];
0009 for tr=1: l + m +size(splitCells_,1)
0010 
0011 
0012     if tr<=length(tracks)
0013         % COLLIDE - COLLIDE
0014         if (strcmp(tracks(tr).Type,'COLLIDE')==1)
0015             if ~ismember(tracks(tr).Id ,collideSet)
0016                 indx = searchTrack(tracks,tracks(tr).CoId);
0017                 if indx==0
0018                     indx =tr;
0019                 end
0020                 collideSet = [collideSet indx];                
0021                 x_ = [tracks(tr).x_(1:2) ; tracks(tr).CoRec(3).Area;];
0022 %                 LineP1 = tracks(tr).x_(1:2);
0023 %                 LineP2 = LineP1 + tracks(tr).Cells(1).Type';
0024 
0025                 for ce = 1: frame.nCells
0026                     % Position
0027                     cc = frame.Cells(ce).Col;
0028                     cr = frame.Cells(ce).Row;
0029                     area = frame.Cells(ce).Area;
0030                     x = [cc cr area]';
0031 
0032 % %                     wi = [1/15 1/15 1/250]'; % weight
0033                     H(tr,ce) = sum(P.wi_22'.*(abs(x - x_)));                                                             
0034                     idTable{tr,ce} = [tracks(tr).Id frame.Cells(ce).Id];
0035                     feaTab{tr,ce} = x - x_;
0036                     
0037                     H(indx,ce) = P.tCollision_CorrespondenceCode;
0038                     idTable{indx,ce} = [tracks(indx).Id frame.Cells(ce).Id];
0039                     feaTab{indx,ce} = [];
0040                 end
0041             end
0042         else
0043             % NORMAL - NORMAL
0044             x_= [tracks(tr).x_(1:2); tracks(tr).Cells(end).Area; 0];
0045             LineP1 = tracks(tr).x_(1:2);
0046             LineP2 = LineP1 + tracks(tr).Cells(1).Type';
0047             for ce = 1: frame.nCells
0048                 % Position
0049                 cc = frame.Cells(ce).Col;
0050                 cr = frame.Cells(ce).Row;
0051                 area = frame.Cells(ce).Area;
0052 
0053                 %-----------------------FLOW CONSTRAINTS ATTEMPT---------------------------
0054                
0055                 P0 = [cc cr];
0056                 % add the flow constraint
0057                 
0058                 FC = d_pt2line(P0,LineP1,LineP2);
0059                
0060                 %--------------------------------------------------------------------------
0061 
0062                 %----------------------RESCALE ATTEMPT-------------------------------------
0063                 %                 v_PC1 = [cc - tracks(tr).x(1), cr - tracks(tr).x(2)];
0064                 %                 % Blood flow direction
0065                 %                 v_BFD = frame.Cells(ce).Type;
0066                 %                 cos_a = dot(v_PC1,v_BFD)/(norm(v_PC1)*norm(v_BFD));
0067                 %                 w = (1/3)*(cos_a +2);
0068                 %--------------------------------------------------------------------------
0069                 x = [cc cr area FC]';
0070 
0071 %                 wi = [1/25 1/25 1/200 1/15]'; % weight
0072                 H(tr,ce) = sum(P.wi_11'.*(abs(x - x_)));
0073                 idTable{tr,ce} = [tracks(tr).Id frame.Cells(ce).Id];
0074                 feaTab{tr,ce} = x - x_;
0075             end
0076         end
0077 
0078     elseif tr <= (l+m)
0079 
0080         % MERGE - NORMAL
0081 
0082         % MergeCell
0083         cc = mergeCells(tr-l).Col;
0084         cr = mergeCells(tr-l).Row;
0085         area = mergeCells(tr-l).Area;
0086 
0087 
0088         x_ = [cc cr area]';
0089         for ce = 1: frame.nCells
0090             % Normal
0091             % Position
0092             cc = frame.Cells(ce).Col;
0093             cr = frame.Cells(ce).Row;
0094             area = frame.Cells(ce).Area;
0095 
0096 
0097 
0098             x = [cc cr area]';
0099 
0100             diff = x - x_;
0101 
0102             if (diff(3)> 0)
0103                 diff(3)=0;
0104             end
0105 
0106 %                 wi = [1/15 1/15 1/300]'; % weight
0107 
0108             
0109             H(tr,ce) = sum(P.wi_21'.*(abs(diff)));
0110             idTable{tr,ce} = [mergeCells(tr-l).Id frame.Cells(ce).Id];
0111             feaTab{tr,ce} = x - x_;
0112         end
0113 
0114 
0115         % SPLIT_ - SPLIT
0116     else
0117 
0118         %split_
0119         splitCell_ = splitCells_(tr-l-m);
0120         cc1 = splitCell_.Status(1).Col;
0121         cr1 = splitCell_.Status(1).Row;
0122         cc2 = splitCell_.Status(2).Col;
0123         cr2 = splitCell_.Status(2).Row;
0124         area1= splitCell_.Status(1).Area;
0125         area2= splitCell_.Status(2).Area;
0126 
0127 
0128         x_ = [cc1 cr1 area1 cc2 cr2 area2]';
0129         for ce = frame.nCells+1 : frame.nCells+ length(splitCells)
0130             % splits
0131             splitCell = splitCells(ce-frame.nCells);
0132             cc1 = splitCell.Status(1).Col;
0133             cr1 = splitCell.Status(1).Row;
0134             cc2 = splitCell.Status(2).Col;
0135             cr2 = splitCell.Status(2).Row;
0136             area1= splitCell.Status(1).Area;
0137             area2= splitCell.Status(2).Area;
0138 
0139 
0140 
0141 
0142             x = [cc1 cr1 area1 cc2 cr2 area2]';
0143 
0144 %             wi = [1/40 1/40 1/300 1/40 1/40 1/300]'; % weight
0145             H(tr,ce) = sum(P.wi_12'.*(abs(x - x_)));
0146             idTable{tr,ce} = [splitCell_.Id splitCell.Id];
0147             feaTab{tr,ce} = x - x_;
0148         end
0149 
0150     end
0151 
0152 end
0153 % figure; plot(deltaArr);

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005