folname = 'C:\Users\Petru\Documents\Uni\Yr4Sem1\Thesis\Images';
folnameg = 'C:\Users\Petru\Documents\Uni\Yr4Sem1\Thesis\Groundtruth';
fils = dir(fullfile(folname,'*.png'));
filsg = dir(fullfile(folnameg,'*.png'));
Io = imread(fullfile(fils(1).folder,fils(1).name));
Ig = imread(fullfile(filsg(1).folder,filsg(1).name));
N1 = bh*ones(floor(size(Io,1)/bh),1);
N1g = bh*ones(floor(size(Ig,1)/bh),1);
N2 = bw*ones(floor(size(Io,2)/bw),1);
N2g = bw*ones(floor(size(Ig,2)/bw),1);
Lg = cell(numel(filsg),1);
I = imread(fullfile(fils(ii).folder,fils(ii).name));
b = mat2cell(I(1:bh*numel(N1),1:bw*numel(N2),:),N1,N2,3);
Ig = imread(fullfile(filsg(ii).folder,filsg(ii).name));
bg = mat2cell(Ig(1:bh*numel(N1g),1:bw*numel(N2g),:),N1g,N2g);