function[] = replay_annotation(movie,x,y)
% Replay_annotation - Replays annotation of a movie
global Npts S M_button I matfilename txtfilename
% Open figure
figure
% Creates axes where to draw
ha(1) = subplot(5,4,[1 2 3 5 6 7 9 10 11 13 14 15]);
ha(2) = subplot(5,4,[4 8 12 16]);
ha(3) = subplot(5,4,17:19);
ha(4) = subplot(5,4,20);
N = size(x,1);
for i = 1:N
axes(ha(1));cla
imagesc(movie(i).cdata)
axis image
title(sprintf('Image : %d / %d ',i,N))
hold on
for j = 1:Npts
color = ['bgrcmyw'];
if M_button(i,j) == 1
s = 1;
elseif M_button(i,j) == 2
s = 2;
elseif M_button(i,j) == 3
s = 3;
end
plot(x(i,j),y(i,j),sprintf('%s %s',S(s),color(j)))
end
axes(ha(2));cla
plot(x(1:i,:),repmat([1:i]',[1,size(y,2)]))
set(ha(2),'Ylim',[0 N],'YDir','reverse')
axes(ha(3));cla
plot(y(1:i,:))
set(ha(3),'Xlim',[0 N],'YDir','reverse')
axes(ha(4));cla
plot(x(1:i,:),y(1:i,:))
set(ha(4),'YDir','reverse','YTick',[])
drawnow
pause(.2)
end
% Adapt M_button:
% 1 ==> 1 3 ==> 2 2 ==> 3
for p = 1:size(I,1)
for q = 1:Npts
if M_button(p,q) == 2
M_button(p,q) = 9;
else
M_button = M_button;
end
if M_button(p,q) == 3
M_button(p,q) = 2;
else
M_button = M_button;
end
if M_button(p,q) == 9
M_button(p,q) = 3;
else
M_button = M_button;
end
end
end
% Save data
data = [];
for pts = 1:Npts
data = [data M_button(:,pts) x(:,pts) y(:,pts)];
end
Idata = [I data]
save(matfilename,'Idata')
% Also in text format
save(txtfilename,'Idata','-ASCII')
choice = menu('Choose an option:','Next portrayal','Exit')
switch choice
case 1
annotation
case 2
close all
clear all
clc
end