Home > vis > vis_velocity_4.m

vis_velocity_4

PURPOSE ^

SYNOPSIS ^

function report = vis_velocity_4(SS)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function report = vis_velocity_4(SS)
0002 report = zeros(length(SS)+1,13);
0003 ROLLING_VELOCITY = 2;
0004 FLOWING_VELOCITY = 10;
0005 for se = 1: length(SS)
0006     % Calculate the velocity both manual and automatic
0007     auVelocities = calc_velocity(SS(se).Rich.tracks);
0008     gtVelocities = calc_velocity(SS(se).GT.tracks);
0009 
0010         
0011     
0012     gtRolling = gtVelocities(gtVelocities(:,2)>=ROLLING_VELOCITY & gtVelocities(:,2)<=FLOWING_VELOCITY,:);
0013     gtRollingVelocity = mean(gtRolling(:,2));
0014     gtRollingFraction = size(gtRolling,1)/size(gtVelocities,1);
0015     
0016     gtAdhering = gtVelocities(gtVelocities(:,2)<ROLLING_VELOCITY,:);
0017     gtAdheringVelocity = mean(gtAdhering(:,2));
0018     gtAdheringFraction = size(gtAdhering,1)/size(gtVelocities,1);
0019     
0020     auRolling = auVelocities(auVelocities(:,2)>=ROLLING_VELOCITY & auVelocities(:,2)<=FLOWING_VELOCITY,:);
0021     auRollingVelocity = mean(auRolling(:,2));
0022     auRollingFraction = size(auRolling,1)/size(auVelocities,1);
0023     
0024     auAdhering = auVelocities(auVelocities(:,2)<ROLLING_VELOCITY,:);
0025     auAdheringVelocity = mean(auAdhering(:,2));
0026     auAdheringFraction = size(auAdhering,1)/size(auVelocities,1);
0027     
0028     % Add the errors
0029     eRollingVelocity = abs(gtRollingVelocity - auRollingVelocity);
0030     eRollingFraction = abs(gtRollingFraction - auRollingFraction);
0031     eAdheringVelocity= abs(gtAdheringVelocity- auAdheringVelocity);
0032     eAdheringFraction= abs(gtAdheringFraction- auAdheringFraction);
0033     
0034     report(se,:) = [se gtRollingVelocity auRollingVelocity eRollingVelocity...
0035                        gtRollingFraction auRollingFraction eRollingFraction...
0036                        gtAdheringVelocity auAdheringVelocity eAdheringVelocity...
0037                        gtAdheringFraction auAdheringFraction eAdheringFraction];
0038                    
0039 end
0040 
0041     % Average row
0042     ave = mean(report);
0043     report(end,:) = ave;
0044 
0045 %--------------------------------------------------------------------------
0046     
0047     
0048     function velocity = calc_velocity(tracks)
0049     trIds = unique(tracks(:,1));
0050     velocity = zeros(length(trIds),2);
0051     for tr = 1:  length(trIds)
0052         trId = trIds(tr);
0053         track = tracks(tracks(:,1)==trId,:);
0054         frIds = unique(track(:,2));
0055 
0056         firstFr = min(frIds);
0057         lastFr  = max(frIds);
0058 
0059             totalDist = calc_dist(track(track(:,2)==firstFr,3:4),...
0060                 track(track(:,2)==lastFr, 3:4) );
0061 
0062         
0063         velocity(tr,:) = [trId totalDist/length(frIds)];
0064     end
0065     end
0066 
0067     function dist = calc_dist(p,q)
0068         dist = sqrt( (p(1)-q(1))^2 + (p(2)-q(2))^2);
0069     end
0070 %--------------------------------------------------------------------------
0071 end

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