wolffd@0: % Let the user draw a square with the mouse, wolffd@0: % and then click on the corners to do a manual segmentation wolffd@0: wolffd@0: ss = 6; wolffd@0: Q1 = 1; Q2 = 2; Q3 = 3; obsvel = 6; wolffd@0: CLOCKWISE = 1; ANTICLOCK = 2; wolffd@0: LR = 1; UD = 2; RL = 3; DU = 4; wolffd@0: wolffd@0: % repeat this block manually incrementing the sequence number wolffd@0: % and setting ori. wolffd@0: % (since I don't know how to call getmouse as a call-return function). wolffd@0: seq = 4; wolffd@0: %ori = CLOCKWISE wolffd@0: ori = ANTICLOCK; wolffd@0: clear xpos ypos wolffd@0: getmouse wolffd@0: % end block wolffd@0: wolffd@0: % manual segmentation with the mouse wolffd@0: startseg(1) = 1; wolffd@0: for i=2:4 wolffd@0: fprintf('click on start of segment %d\n', i); wolffd@0: [x,y] = ginput(1); wolffd@0: plot(x,y,'ro') wolffd@0: d = dist2([xpos; ypos]', [x y]); wolffd@0: startseg(i) = argmin(d); wolffd@0: end wolffd@0: wolffd@0: % plot corners in green wolffd@0: %ti = first point in (i+1)st segment wolffd@0: t1 = startseg(1); t2 = startseg(2); t3 = startseg(3); t4 = startseg(4); wolffd@0: plot(xpos(t2), ypos(t2), 'g*') wolffd@0: plot(xpos(t3), ypos(t3), 'g*') wolffd@0: plot(xpos(t4), ypos(t4), 'g*') wolffd@0: wolffd@0: wolffd@0: xvel = xpos(2:end) - xpos(1:end-1); wolffd@0: yvel = ypos(2:end) - ypos(1:end-1); wolffd@0: speed = [xvel(:)'; yvel(:)']; wolffd@0: pos_data{seq} = [xpos(:)'; ypos(:)']; wolffd@0: vel_data{seq} = [xvel(:)'; yvel(:)']; wolffd@0: T = length(xvel); wolffd@0: Q1label{seq} = num2cell(repmat(ori, 1, T)); wolffd@0: Q2label{seq} = zeros(1, T); wolffd@0: if ori == CLOCKWISE wolffd@0: Q2label{seq}(t1:t2) = LR; wolffd@0: Q2label{seq}(t2+1:t3) = UD; wolffd@0: Q2label{seq}(t3+1:t4) = RL; wolffd@0: Q2label{seq}(t4+1:T) = DU; wolffd@0: else wolffd@0: Q2label{seq}(t1:t2) = RL; wolffd@0: Q2label{seq}(t2+1:t3) = UD; wolffd@0: Q2label{seq}(t3+1:t4) = LR; wolffd@0: Q2label{seq}(t4+1:T) = DU; wolffd@0: end wolffd@0: wolffd@0: % pos_data{seq}(:,t), vel_data{seq}(:,t) Q1label{seq}(t) Q2label{seq}(t) wolffd@0: save 'square4' pos_data vel_data Q1label Q2label wolffd@0: wolffd@0: nseq = 4; wolffd@0: cases = cell(1,nseq); wolffd@0: for seq=1:nseq wolffd@0: T = size(vel_data{seq},2); wolffd@0: ev = cell(ss,T); wolffd@0: ev(obsvel,:) = num2cell(vel_data{seq},1); wolffd@0: ev(Q1,:) = Q1label{seq}; wolffd@0: ev(Q2,:) = num2cell(Q2label{seq}); wolffd@0: cases{seq} = ev; wolffd@0: end wolffd@0: save 'square4_cases' cases