0001 classdef WBCTrack < hgsetget
0002 properties
0003 Id
0004 Type
0005 Cells
0006 x_
0007 P_
0008 P
0009 x
0010 nCells=0;
0011 nKfCells=0;
0012 Phi
0013 CoId
0014 CoRec
0015 svec=[]
0016
0017 end
0018
0019
0020 methods
0021 function track = WBCTrack(firstCell,id,P)
0022
0023 if nargin > 1
0024 track.Cells = firstCell;
0025 end
0026 track.Id = id;
0027 if ~isempty(firstCell.Type)
0028 if ~isempty(firstCell.Status)
0029 p = firstCell.Status/10;
0030 else
0031 p=.5;
0032 end
0033 if p>1
0034 p=1;
0035 end
0036 try
0037 xx = firstCell.Type(1);
0038 catch
0039 pause();
0040 end
0041 yy = firstCell.Type(2);
0042 theta = atan2(yy,xx);
0043 dx = (1-p)*P.tSpeed*cos(theta);
0044 dy = (1-p)*P.tSpeed*sin(theta);
0045 track.x = [firstCell.Col firstCell.Row dx dy]';
0046 else
0047 track.x = [firstCell.Col firstCell.Row 0 0]';
0048 end
0049 track.P = 5*eye(4);
0050 track.nCells = 1;
0051 track.Phi = 0;
0052 track.Type = 'NEW';
0053 end
0054
0055 function add(track, cell)
0056
0057 track.Cells(end).Next = cell.Id;
0058 cell.Prev = track.Cells(end).Id;
0059
0060 track.Cells = [track.Cells cell];
0061 track.nCells = track.nCells + 1;
0062
0063 end
0064
0065
0066
0067 function cell = removeLast(track)
0068
0069 cell = track.Cells(end);
0070 cell.Prev= [];
0071
0072 track.Cells = track.Cells(1:end-1);
0073 track.Cells(end).Next= [];
0074 track.nCells = track.nCells -1;
0075 end
0076
0077 function cell= first(track)
0078
0079 cell = track.Cells(1);
0080 end
0081
0082 function cell= last(track)
0083 cell = track.Cells(end);
0084 end
0085
0086 function show(track)
0087 str= [];
0088 for i = 1: track.nCells
0089 str = [str,' ', num2str(track.Cells(i).Frame) ,...
0090 '(',num2str(floor(track.Cells(i).Row)),...
0091 ',',num2str(floor(track.Cells(i).Col)),...
0092 ') -->'];
0093 end
0094 disp(str);
0095 end
0096
0097 function plotPredict(track,color,P)
0098
0099 if strcmp(track.Type,'COLLIDE') ==1
0100 try
0101 area_pre1 = round(sqrt(track.CoRec(1).Area/pi))*P.tRatio_PlotArea+1;
0102 catch
0103 pause();
0104 end
0105 plot(track.Cells(end).Col+track.svec(1),track.Cells(end).Row+track.svec(2),'o', ...
0106 'MarkerEdgeColor',color,'MarkerSize',area_pre1);
0107 line([track.Cells(end).Col, track.Cells(end).Col+track.svec(1)], ...
0108 [track.Cells(end).Row, track.Cells(end).Row+ track.svec(2)],...
0109 'LineWidth',1,'Color',color);
0110
0111
0112 else
0113
0114 area = round(sqrt(track.Cells(end).Area/pi))*P.tRatio_PlotArea + 1;
0115 plot(track.x_(1),track.x_(2),'o','MarkerEdgeColor',color,'MarkerSize',area);
0116 line([track.Cells(end).Col, track.x_(1)], [track.Cells(end).Row, track.x_(2)],'LineWidth',1,'Color',color);
0117 end
0118 end
0119
0120 function plot(track,color,P)
0121 if nargin == 3
0122
0123
0124
0125
0126 startCell = max(1,track.nCells-2);
0127 for ce = startCell: track.nCells-1
0128 hold on;
0129 plot (track.Cells(ce).Col,track.Cells(ce).Row,'o','MarkerEdgeColor',color,'MarkerSize',4);
0130 hold on;
0131 line([track.Cells(ce).Col, track.Cells(ce+1).Col], [track.Cells(ce).Row, track.Cells(ce+1).Row],'LineWidth',1,'Color',color);
0132 end
0133
0134
0135 area = round(sqrt(track.Cells(end).Area/pi))*P.tRatio_PlotArea+1;
0136 plot(track.Cells(end).Col,track.Cells(end).Row,'o','MarkerFaceColor','b','MarkerEdgeColor',color,'MarkerSize',area);
0137 if strcmp(track.Type,'COLLIDE')==1
0138
0139 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','r','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0140 else
0141 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','y','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0142 end
0143 end
0144
0145 if nargin == 2
0146
0147 framemap = jet(track.Cells(track.nCells).Frame);
0148 for ce = startCell: track.nCells-1
0149
0150 color = framemap(track.Cells(ce).Frame,:);
0151 hold on;
0152 plot (track.Cells(ce).Col,track.Cells(ce).Row,'o','MarkerEdgeColor',color,'MarkerSize',4);
0153 hold on;
0154 line([track.Cells(ce).Col, track.Cells(ce+1).Col], [track.Cells(ce).Row, track.Cells(ce+1).Row],'LineWidth',1,'Color',color);
0155 end
0156 color = framemap(track.Cells(end).Frame,:);
0157 area = round(sqrt(track.Cells(end).Area/pi))*P.tRatio_PlotArea+1;
0158 plot(track.Cells(end).Col,track.Cells(end).Row,'o','MarkerFaceColor','b','MarkerEdgeColor',color,'MarkerSize',area);
0159 if strcmp(track.Type,'COLLIDE')==1
0160
0161 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','r','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0162 else
0163 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','y','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0164 end
0165 end
0166 end
0167
0168 function plotAll2D(track,P)
0169 framemap = jet(track.Cells(end).Frame - track.Cells(1).Frame+2);
0170 for ce = 1: track.nCells-1
0171 area = round(sqrt(track.Cells(ce).Area/pi))+1;
0172 try
0173 color = framemap(track.Cells(ce).Frame - track.Cells(1).Frame+1,:);
0174 catch
0175 color = 'g';
0176 end
0177 hold on;
0178 plot (track.Cells(ce).Col,track.Cells(ce).Row,'o','MarkerEdgeColor',color,'MarkerSize',4);
0179 hold on;
0180 line([track.Cells(ce).Col, track.Cells(ce+1).Col], [track.Cells(ce).Row, track.Cells(ce+1).Row],'LineWidth',1,'Color',color);
0181 end
0182 color = framemap(track.Cells(end).Frame - track.Cells(1).Frame,:);
0183 area = round(sqrt(track.Cells(end).Area/pi))*P.tRatio_PlotArea+1;
0184 plot(track.Cells(end).Col,track.Cells(end).Row,'o','MarkerFaceColor','b','MarkerEdgeColor',color,'MarkerSize',area);
0185 if strcmp(track.Type,'COLLIDE')==1
0186
0187 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','r','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0188
0189 else
0190 text(track.Cells(end).Col,track.Cells(end).Row-10,num2str(track.Id),'color','y','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0191 end
0192 end
0193
0194 function plotAll3D(track,color,P)
0195 for ce = 1: track.nCells-1
0196 line([track.Cells(ce).Col, track.Cells(ce+1).Col], [track.Cells(ce).Row, track.Cells(ce+1).Row],[track.Cells(ce).Frame, track.Cells(ce+1).Frame],'LineWidth',1,'Color',color);
0197 end
0198 if strcmp(track.Type,'COLLIDE')==1
0199
0200 text(track.Cells(end).Col,track.Cells(end).Row-10,track.Cells(end).Frame,num2str(track.Id),'color','r','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0201 else
0202 text(track.Cells(end).Col,track.Cells(end).Row-10,track.Cells(end).Frame,num2str(track.Id),'color','b','Fontsize',P.tSize_Text,'HorizontalAlignment','center','VerticalAlignment','middle');
0203 end
0204 end
0205
0206
0207 end
0208 end