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


%% list directory
nameOfDir = '../imgMerged/operator/'
nameOfDirAlg = '../imgMerged/imgResBestPlaces/'



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

procs = [];




for (index = 1:size(filenames,2))
    

clear measured_dists
clear dists

measured_dists = [];
dists = [];

name = filenames{index}


fullName = strcat(nameOfDir,name)
fullNameAlg = strcat(nameOfDirAlg, name)


try
load(fullName, '-mat');
catch
end
try
load(fullNameAlg, '-mat');
catch
end


measured_dists;
dists;


val = [trimmean(measured_dists, 20) + 0.6, trimmean(dists,20)];
proc = 100*(max(val)-min(val))/max(val);
diff = (max(val)-min(val));
std1 = std(measured_dists);
std2 = std(dists);




procs = [procs, [proc; diff; val'; std1; std2]];



%pause;



end


% histogram of errors
p = procs(2,:);
p = p(p < 6)

f = figure;
hist(p,10)
xlabel('mean error [px]')
ylabel('frequency of occurance [-]')
print(f,'-depsc','01_hist.eps')



display('error is ')
mean(p) 
std(p)

mean(p*0.78) 
std(p*0.78)

return;

% statistical values in whole set
f1 = figure;
boxplot(p)
xlabel('')
set(gca,'TickLength',[ 0 0 ])
set(gca,'XTickLabel','')
ylabel('box plot of mean errors [px]')
print(f1,'-depsc','02_boxPlotErrors.eps')

% statistical values in whole set
f1 = figure;
a = procs(3:4,:)'
boxplot(a)
xlabel('')
set(gca,'XTickLabel', {'by proposed algorithm ',' by human operator '})
ylabel('box plot of mean values [px]')
print(f1,'-depsc','03_boxPlotMeans.eps')


% variability calculation
f1 = figure;
a = procs(5:6,:)'
boxplot(a)
xlabel('')
set(gca,'XTickLabel', {'by proposed algorithm ',' by human operator '})
ylabel('box plot of standart deviation [px]')
print(f1,'-depsc','04_boxPlotStd.eps')





procs
p = procs(1,:);
p = p(p>0 & p < 50);
mp = mean(p)

p = procs(2,:);
p = p(p>0 & p < 5);
mp = mean(p)