clear
clc
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%% list directory
nameOfDir = '../imgss/img/'
nameOfOutDir = '../imgss/operator/'

list=dir(nameOfDir); 
filenames={list(~[list.isdir]).name}




for (index = 1:size(filenames,2))
name = filenames{index}

I = imread(strcat(nameOfDir,name));
%imageOriginal = rgb2gray(I);
imageOriginal = I;

figure(1);
imshow(imageOriginal);
set(gcf,'Position', get(0,'Screensize'));

button = 1;

dists = [];
last = [];
counter = 0;
while (button == 1)
[x,y, button] = ginput(1)

counter = counter+1;
if (mod(counter, 2) == 0)
    dist = sqrt(((x-last(1,1))^2 ) + ((y-last(2,1))^2 ))
    dists = [dists, dist]
end
last(1,1) = x;
last(2,1) = y;



if (button == 1)
try
imageOriginal(round(y),round(x)) = 255;
catch
end

figure(1);
imshow(imageOriginal);
set(gcf,'Position', get(0,'Screensize'));
end

end


distMean = mean(dists);


if (length(dists) >= 1)
    outName = strcat(nameOfOutDir, name, '.txt')
    save(outName, 'dists','distMean');
end


end








