%% This code generates examples for different levels of noise
clc;
clear;
level_all=[0.01 0.05 0.1 0.15 0.2]; %noise levels

for l=1:length(level_all)
ct=1;
%generate 10,000 examples of circle and squares
    for i=1:10000
        c1=randperm(25)+4; c2=randperm(25)+4; % choose center of square and circle randomly
        [I1,I2]=test([c1(1) c2(1)],level_all(l)); %generate circle and square
        data(l).I(:,:,ct)=single(I1);
        data(l).I(:,:,ct+1)=single(I2);
        
        data(l).label(:,:,ct)=1; %circle is label 1
        data(l).label(:,:,ct+1)=0; %square is label 0
        
        ct=ct+2;
    end
    disp('Done');
end

% normalizing data for deep learning

for l=1:length(level_all)
    mu_img=mean(data(l).I,3);
    sd_img=mean(mean(mean(data(l).I,3),2),1);
    data(l).I=(data(l).I-repmat(mu_img,[1 1 20000]))/sd_img;
    disp('Done');
end


    