% Hassan Nahas
%This script finds and plots the datapoints for the repeatability vs noise
%for a random corner detector 

possibleSTDS = [0:5:25, 30:10:50];
[dataset,warps] = readDataset(mydirName);

noises = zeros(size(possibleSTDS));
repeatabilityOfCorners = noises;
% [~,cornerStrength_dt,~,~] = classifyDataSetAccordingToTree(dataset,Tree, 255,[]);
i = 1;
allT = ones(length(dataset),1)*30;
% possibleTrees = [9,12];
dataForThisExperiment = cell(length(possibleTrees),1);
j = 1;
legendlabels = [];
hold on;
%     numberOfCornersReal = zeros(size(possibleCorners));
% repeatabilityOfCorners = zeros(size(possibleSTDS));
for std = possibleSTDS
    tic;
    sprintf('Now doing std = %.3f',std)
    

    cornerMap_dt_nms = cell(length(dataset),1);
    for randomindex = 1:length(dataset)
        cornerMap_dt_nms{randomindex} = imnoise(zeros(size(dataset{randomindex})),'salt & pepper',500/numel(dataset{randomindex}));
    end
    repeatabilityOfCorners(i) = evaluateDataset(cornerMap_dt_nms,warps,5);
%     numberOfCorners(i) = averageNumberOfCorners(cornerMap_dt_nms)
    
    i = i + 1;
    
    timeForCycle = toc;
    sprintf('Cycle took  %.3f seconds',timeForCycle)
end
%     dataForThisExperiment{j,1} = numberOfCornersReal;
%     dataForThisExperiment{j,1} = repeatabilityOfCorners;
%     j = j + 1;
%     legendlabels = [legendlabels, sprintf('N = %d', treeIndex)];
plot(possibleSTDS,repeatabilityOfCorners,'o-');
    

% legend(legendlabels)
xlabel('Noise Standard Deviation')
ylabel('Repeatability')
