clear all; close all; clc

% umelo vytvorený obraz pre segmentáciu z obrazov 2 rôznych gélov

%% načítanie sád obrazov
% load('databaza_obr_oct_agaroza_gel_log_10.mat');
% load('databaza_obr_oct_agaroza_gel_surove.mat')

% load('databaza_obr_oct_intralipid_gel_log10_bez_priemeru.mat')
% load('databaza_obr_oct_intralipid_gel_log10_priemer.mat');
% load('databaza_obr_oct_intralipid_gel_surove_bez_priemeru.mat')
load('databaza_obr_oct_intralipid_gel_surove_priemer.mat')

% load('databaza_obr_oct_intralipid_voda_log10_bez_priemeru.mat')
% load('databaza_obr_oct_intralipid_voda_log10_priemer.mat')
% load('databaza_obr_oct_intralipid_voda_surove_bez_priemeru.mat')
% load('databaza_obr_oct_intralipid_voda_surove_priemer.mat')

% velkost databazy
sd = size(data);

poradie = 20;
% for poradie = 1:sd(1)
    % výber obrazov z databázy
    gel_1 = data{poradie, 1};
    s = size(gel_1);
    gel_2 = data{poradie, 2};
    gel_3 = data{poradie, 3};
    gel_4 = data{poradie, 4};
    gel_5 = data{poradie, 5};
    gel_6 = data{poradie, 6};
    gel_7 = data{poradie, 7};
    gel_8 = data{poradie, 8};


c = [255, 90]; % súradnice stredu
r = 70; % polomer kruhu
mask = bsxfun(@plus, ((1:s(2)) - c(1)).^2, (transpose(1:s(1)) - c(2)).^2) < r^2;

v_poloha_kruhu = 180;


z = zeros(s);
a = gel_1.*mask;

z(v_poloha_kruhu-r:v_poloha_kruhu+r,:) = a(c(2)-r:c(2)+r,:);
mask = z;
mask(mask>0)=1;

i_m = ones(s);
i_mask = abs(i_m-mask);

b = gel_7.*i_mask;
c = z+b;
d = mask;


obraz = c(40:339,:);
segmenty = d(40:339,:);

imshow(obraz, [])
% end

% save('obr_na_segmentaciu_oct_gi_p_s_1_2.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_1_3.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_1_4.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_1_5.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_1_6.mat','obraz', 'segmenty')
save('obr_na_segmentaciu_oct_gi_p_s_1_7.mat','obraz', 'segmenty')

% save('obr_na_segmentaciu_oct_gi_p_s_2_1.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_3_1.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_4_1.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_5_1.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_6_1.mat','obraz', 'segmenty')
% save('obr_na_segmentaciu_oct_gi_p_s_7_1.mat','obraz', 'segmenty')