clc;
clear;
close all;

% RGB features extraction and saving in mat file
pathname='Dastaset/';
imagespath=imageSet(pathname,'recursive');

imagecount=1;

allfoldernames = struct2table(dir(pathname));
        for i=3:height(allfoldernames)
            new(i-2)=allfoldernames.name(i);
        end
       
%size of image folder
s = size(imagespath,2); 

for i=1 : size(imagespath,2)
   
    %count number of images in each folder
    m=size(imagespath(i).ImageLocation,2);
   
    % find the addresses of the images locations
    temp=imagespath(i).ImageLocation;
     for j=1 :  m
        v{imagecount,1}=temp{j};
            if(~isempty(strfind(temp{j},'camA')))
                v{imagecount,2}='a';
            elseif (~isempty(strfind(temp{j},'camB')))
                v{imagecount,2}='b';
            end
           
            path = v{imagecount,1};
            % % read image
            I = imread(v{imagecount,1});
            imshow(I);
            % Spliting Channel of the image
            R = I(:,:,1);
            G = I(:,:,2);
            B = I(:,:,3);
            % Color ratio is computed for each channel
            r = R./R + G + B;
            g = G./R + G + B;
            b = B./R + G + B;
            imshow([R G B]);
           
            r_v = std(double(r));
            r_m = mean(r);
            name = v{imagecount,2};
            imagecount=imagecount+1;
           
            % Fused Features according to label of camera's
            if(name == 'a')
                fused1{j,1} = [r_v r_m];
                fused1{j,2} =path;
                save('Features_CamA.mat','fused1');
            else
                fused2{j,1} = [r_v r_m];
                fused2{j,2} = path;
                save('Features_CamB.mat','fused2');
            end
     end
end


%  Calculating Eclidean distance


clc;
clear;
close all;


pathname='Dastaset/';
imagespath=imageSet(pathname,'recursive');

imagecount=1;

allfoldernames = struct2table(dir(pathname));
        for i=3:height(allfoldernames)
            new(i-2)=allfoldernames.name(i);
        end
       
%size of image folder
s = size(imagespath,2); 

for i=1 : size(imagespath,2)
   
    %count number of images in each folder
    m=size(imagespath(i).ImageLocation,2);
   
    % find the addresses of the images locations
    temp=imagespath(i).ImageLocation;
     for j=1 :  m
        v{imagecount,1}=temp{j};
            if(~isempty(strfind(temp{j},'camA')))
                v{imagecount,2}='a';
            elseif (~isempty(strfind(temp{j},'camB')))
                v{imagecount,2}='b';
            end
           
            path = v{imagecount,1};
            % % read image
            I = imread(v{imagecount,1});
            imshow(I);
            % Spliting Channel of the image
            R = I(:,:,1);
            G = I(:,:,2);
            B = I(:,:,3);
            % Color ratio is computed for each channel
            r = R./R + G + B;
            g = G./R + G + B;
            b = B./R + G + B;
            imshow([R G B]);
           
            r_v = std(double(r));
            r_m = mean(r);
            name = v{imagecount,2};
            imagecount=imagecount+1;
           
            % Fused Features according to label of camera's
            if(name == 'a')
                fused1{j,1} = [r_v r_m];
                fused1{j,2} =path;
                save('Features_CamA.mat','fused1');
            else
                fused2{j,1} = [r_v r_m];
                fused2{j,2} = path;
                save('Features_CamB.mat','fused2');
            end
     end
end