% Hlavni (spousteci) program k bakalarske praci "NELINEARITY V PROCESU 
% AKVIZICE DAT U OPTICKE KOHERENTNI TOMOGRAFIE". Po spusteni si program sam
% zavola potrebne funkce (ke svemu behu vyzaduje funkce fwhm.m, grs2rgb,
% mygaussfit.m, nazorne_fwhm.m, nulovani.m, posun.m).

clear all
close all
clc
%%      PRVNI CAST PROGRAMU
%
% NAHRAVANI SNIMKU, JEJICH ORIZNUTI/UPRAVENU A VYKRESLENI VYREZU, VE 
% KTERYCH BUDE PROBIHAT ODHAD VELIKOSTI CASTICE
 
% pro kazdou pozici matice vytvarim bunku, abych do ni mohl ukladat
% porizene snimky v dane pozici
A_11 = {};
A_12 = {};
A_13 = {};
A_14 = {};
A_15 = {};
A_21 = {};
A_22 = {};
A_23 = {};
A_24 = {};
A_25 = {};
A_31 = {};
A_32 = {};
A_33 = {};
A_34 = {};
A_35 = {};
A_41 = {}; 
A_42 = {};
A_43 = {};
A_44 = {};
A_45 = {};

% nahravani obrazku do bunek vytvorenych v predchazejicim kroku, kazda 
% bunka osahuje 7 sekci pro prave 7 rovin ve kterych probihalo mereni
    for k = 1:7
        cesta_11 = ['Mereni_absolutni\A_11\A_11_0',int2str(k-1),'.BMP'];
        cesta_12 = ['Mereni_absolutni\A_12\A_12_0',int2str(k-1),'.BMP'];
        cesta_13 = ['Mereni_absolutni\A_13\A_13_0',int2str(k-1),'.BMP'];
        cesta_14 = ['Mereni_absolutni\A_14\A_14_0',int2str(k-1),'.BMP'];
        cesta_15 = ['Mereni_absolutni\A_15\A_15_0',int2str(k-1),'.BMP'];
        cesta_21 = ['Mereni_absolutni\A_21\A_21_0',int2str(k-1),'.BMP'];
        cesta_22 = ['Mereni_absolutni\A_22\A_22_0',int2str(k-1),'.BMP'];
        cesta_23 = ['Mereni_absolutni\A_23\A_23_0',int2str(k-1),'.BMP'];
        cesta_24 = ['Mereni_absolutni\A_24\A_24_0',int2str(k-1),'.BMP'];
        cesta_25 = ['Mereni_absolutni\A_25\A_25_0',int2str(k-1),'.BMP'];
        cesta_31 = ['Mereni_absolutni\A_31\A_31_0',int2str(k-1),'.BMP'];
        cesta_32 = ['Mereni_absolutni\A_32\A_32_0',int2str(k-1),'.BMP'];
        cesta_33 = ['Mereni_absolutni\A_33\A_33_0',int2str(k-1),'.BMP'];
        cesta_34 = ['Mereni_absolutni\A_34\A_34_0',int2str(k-1),'.BMP'];
        cesta_35 = ['Mereni_absolutni\A_35\A_35_0',int2str(k-1),'.BMP'];
        cesta_41 = ['Mereni_absolutni\A_41\A_41_0',int2str(k-1),'.BMP'];
        cesta_42 = ['Mereni_absolutni\A_42\A_42_0',int2str(k-1),'.BMP'];
        cesta_43 = ['Mereni_absolutni\A_43\A_43_0',int2str(k-1),'.BMP'];
        cesta_44 = ['Mereni_absolutni\A_44\A_44_0',int2str(k-1),'.BMP'];
        cesta_45 = ['Mereni_absolutni\A_45\A_45_0',int2str(k-1),'.BMP'];                
        A_11{k} = im2double(rgb2gray(imread(cesta_11)));
        A_12{k} = im2double(rgb2gray(imread(cesta_12)));
        A_13{k} = im2double(rgb2gray(imread(cesta_13)));
        A_14{k} = im2double(rgb2gray(imread(cesta_14)));
        A_15{k} = im2double(rgb2gray(imread(cesta_15)));
        A_21{k} = im2double(rgb2gray(imread(cesta_21)));
        A_22{k} = im2double(rgb2gray(imread(cesta_22)));
        A_23{k} = im2double(rgb2gray(imread(cesta_23)));
        A_24{k} = im2double(rgb2gray(imread(cesta_24)));
        A_25{k} = im2double(rgb2gray(imread(cesta_25)));
        A_31{k} = im2double(rgb2gray(imread(cesta_31)));
        A_32{k} = im2double(rgb2gray(imread(cesta_32)));
        A_33{k} = im2double(rgb2gray(imread(cesta_33)));
        A_34{k} = im2double(rgb2gray(imread(cesta_34)));
        A_35{k} = im2double(rgb2gray(imread(cesta_35)));
        A_41{k} = im2double(rgb2gray(imread(cesta_41)));
        A_42{k} = im2double(rgb2gray(imread(cesta_42)));
        A_43{k} = im2double(rgb2gray(imread(cesta_43)));
        A_44{k} = im2double(rgb2gray(imread(cesta_44)));
        A_45{k} = im2double(rgb2gray(imread(cesta_45)));  
    end

% oriznuti obrazku, u kazdeho tak budu moci dale pracovat pouze s malou 
% oblasti kde se vyskytuje zvolena castice; oriznuti jsem provedl tak aby
% bylo zachovano konstantni rozlišeni pro vsechny oriznute snimky
for l = 1:7
  A_11{l} = A_11{l}(31:66,36:71);
  A_12{l} = A_12{l}(33:68,136:171);
  A_13{l} = A_13{l}(36:71,236:271);
  A_14{l} = A_14{l}(36:71,346:381);
  A_15{l} = A_15{l}(36:71,456:491);    
  A_21{l} = A_21{l}(136:171,39:74);
  A_22{l} = A_22{l}(136:171,139:174);
  A_23{l} = A_23{l}(136:171,239:274);
  A_24{l} = A_24{l}(136:171,346:381);
  A_25{l} = A_25{l}(136:171,451:486); 
  A_31{l} = A_31{l}(236:271,36:71);
  A_32{l} = A_32{l}(236:271,136:171);
  A_33{l} = A_33{l}(235:270,238:273);
  A_34{l} = A_34{l}(236:271,350:385);
  A_35{l} = A_35{l}(236:271,455:490);
  A_41{l} = A_41{l}(334:369,36:71);
  A_42{l} = A_42{l}(336:371,136:171);
  A_43{l} = A_43{l}(331:366,235:270);
  A_44{l} = A_44{l}(336:371,343:378);
  A_45{l} = A_45{l}(336:371,448:483);
end

% prevedeni vsech obrazku do binarnich hodnot kvuli pozdejsimu zpracovani
% (funkce regionprops, kterou pozdeji pouziji, totiz vyzaduje vtupni 
% promenne v binarni podobe)
for b = 1:7
A_11{b}(A_11{b}>0.01)=1;
A_11{b}(A_11{b}<=0.01)=0;
A_12{b}(A_12{b}>0.01)=1;
A_12{b}(A_12{b}<=0.01)=0;
A_13{b}(A_13{b}>0.01)=1;
A_13{b}(A_13{b}<=0.01)=0;
A_14{b}(A_14{b}>0.01)=1;
A_14{b}(A_14{b}<=0.01)=0;
A_15{b}(A_15{b}>0.01)=1;
A_15{b}(A_15{b}<=0.01)=0;
A_21{b}(A_21{b}>0.01)=1;
A_21{b}(A_21{b}<=0.01)=0;
A_22{b}(A_22{b}>0.01)=1;
A_22{b}(A_22{b}<=0.01)=0;
A_23{b}(A_23{b}>0.01)=1;
A_23{b}(A_23{b}<=0.01)=0;
A_24{b}(A_24{b}>0.01)=1;
A_24{b}(A_24{b}<=0.01)=0;
A_25{b}(A_25{b}>0.01)=1;
A_25{b}(A_25{b}<=0.01)=0;
A_31{b}(A_31{b}>0.01)=1;
A_31{b}(A_31{b}<=0.01)=0;
A_32{b}(A_32{b}>0.01)=1;
A_32{b}(A_32{b}<=0.01)=0;
A_33{b}(A_33{b}>0.01)=1;
A_33{b}(A_33{b}<=0.01)=0;
A_34{b}(A_34{b}>0.01)=1;
A_34{b}(A_34{b}<=0.01)=0;
A_35{b}(A_35{b}>0.01)=1;
A_35{b}(A_35{b}<=0.01)=0;
A_41{b}(A_41{b}>0.01)=1;
A_41{b}(A_41{b}<=0.01)=0;
A_42{b}(A_42{b}>0.01)=1;
A_42{b}(A_42{b}<=0.01)=0;
A_43{b}(A_43{b}>0.01)=1;
A_43{b}(A_43{b}<=0.01)=0;
A_44{b}(A_44{b}>0.01)=1;
A_44{b}(A_44{b}<=0.01)=0;
A_45{b}(A_45{b}>0.01)=1;
A_45{b}(A_45{b}<=0.01)=0;
end

% korekce pro zobrazeni opravdu pouze sledovane castice - odebiram z
% vyriznutych obrazku vse ostatni, co nereprezentuje pozadovanou castici
A_11{6}(:,1:7) = 0;
A_11{7}(:,1:7) = 0;
A_11{7}(1:7,:) = 0;
A_12{6}(:,1:4) = 0;
A_12{7}(:,1:5) = 0;
A_12{7}(1:12,:) = 0;
A_13{4}((end-3):end,:) = 0;
A_13{5}((end-3):end,:) = 0;
A_13{6}(:,1:6) = 0;
A_13{6}((end-4):end,:) = 0;
A_13{7}(:,1:7) = 0;
A_13{7}(1:5,:) = 0;
A_14{5}((end-3):end,:) = 0;
A_14{5}(1:3,:) = 0;
A_14{6}(1:4,:) = 0;
A_14{6}((end-3):end,:) = 0;
A_15{2}((end-3):end,:) = 0;
A_15{5}(:,(end-4):end) = 0;
A_15{6}(:,(end-5):end) = 0;
A_15{7}(:,(end-5):end) = 0;
A_15{7}(:,1:8) = 0;
A_11{6}(:,8:14) = 0;
A_11{7}(:,11:16) = 0;
A_12{7}(:,14:17) = 0;
A_13{6}(:,10:15) = 0;

A_41{1}(:,1:4) = 0;
A_41{5}(:,(end-3):end) = 0;
A_41{6}(:,1:2) = 0;
A_41{6}(:,(end-7):end) = 0;
A_41{7}(:,:) = 0;
A_42{7}(:,:) = 0;
A_43{7}(:,:) = 0;
A_44{7}(:,:) = 0;
A_44{1}(:,:) = 0;
A_45{7}(:,:) = 0;
A_42{1}(:,2:7) = 0;
A_42{6}(:,1:5) = 0;
A_42{6}(:,(end-4):end) = 0;
A_43{6}(:,1:8) = 0;
A_44{4}(:,(end-4):end) = 0;
A_44{5}(:,(end-4):end) = 0;
A_44{6}(:,(end-6):end) = 0;
A_45{1}(:,:) = 0;
A_45{4}(:,(end-3):end) = 0;
A_45{5}(:,(end-5):end) = 0;
A_45{6}(:,(end-7):end) = 0;
A_42{1}((end-5):end,:) = 0;

A_31{6}(:,:) = 0;
A_31{7}(:,:) = 0;
A_32{6}(:,:) = 0;
A_32{7}(:,:) = 0;
A_33{7}(:,:) = 0;
A_34{7}(:,:) = 0;
A_35{7}(:,:) = 0;
A_31{1}(:,1:12) = 0;
A_31{4}(:,1:6) = 0;
A_31{4}(:,(end-4):end) = 0;
A_31{5}((end-6):end,:) = 0;
A_31{5}(:,(end-4):end) = 0;
A_32{1}(:,1:5) = 0;
A_32{5}(:,(end-3):end) = 0;
A_33{1}(:,1:10) = 0;
A_33{6}(:,1:6) = 0;
A_34{1}((end-3):end,:) = 0;
A_34{2}(:,(end-8):end) = 0;
A_34{4}(:,(end-6):end) = 0;
A_34{5}(:,(end-9):end) = 0;
A_34{6}(:,(end-11):end) = 0;
A_35{1}(:,:) = 0;
A_35{2}((end-3):end,:) = 0;
A_35{4}(:,(end-5):end) = 0;
A_35{5}(:,(end-12):end) = 0;
A_35{6}(:,(end-12):end) = 0;
A_34{6}(13:18,14:19) = 0;
A_35{6}(12:18,11:15) = 0;

A_21{1}(:,1:3) = 0;
A_21{2}(:,(end-4):end) = 0;
A_21{5}(:,(end-6):end) = 0;
A_21{6}(:,(end-7):end) = 0;
A_21{7}(:,1:12) = 0;
A_21{7}(1:14,:) = 0;
A_22{1}(:,1:5) = 0;
A_22{2}(:,(end-4):end) = 0;
A_22{5}(:,(end-6):end) = 0;
A_22{6}(:,(end-5):end) = 0;
A_22{7}(:,1:10) = 0;
A_22{7}(1:14,:) = 0;
A_23{5}(:,(end-3):end) = 0;
A_23{6}(:,1:2) = 0;
A_23{6}(:,(end-5):end) = 0;
A_23{7}(1:18,:) = 0;
A_23{7}(:,1:13) = 0;
A_24{5}(:,(end-7):end) = 0;
A_24{6}(:,(end-5):end) = 0;
A_24{7}(:,1:10) = 0;
A_24{7}(:,(end-8):end) = 0;
A_25{2}((end-4):end,:) = 0;
A_25{5}(:,29:end) = 0;
A_25{6}(:,26:end) = 0;
A_25{7}(:,1:9) = 0;
A_25{7}(:,24:end) = 0;

% vykresleni castice v sedmi rezech pro kazdou z peti pozic v prvnim radku
% matice
figure ('name','Vykreslení oříznutých a vyčištěných snímků - PRVNÍ ŘÁDEK matice','numbertitle','off')
 for a = 1:7
   subplot (5,7,a)
   imshow(A_11{a})
   title (['A11 (',int2str(a-1),')']);
   
   subplot (5,7,(a+7))
   imshow(A_12{a})
   title (['A12 (',int2str(a-1),')'])
   
   subplot (5,7,(a+14))
   imshow(A_13{a})
   title (['A13 (',int2str(a-1),')'])
   
   subplot (5,7,(a+21))
   imshow(A_14{a})
   title (['A14 (',int2str(a-1),')'])
   
   subplot (5,7,(a+28))
   imshow(A_15{a})
   title (['A15 (',int2str(a-1),')'])
 end
  
% vykreslení castice v sedmi rezech pro kazdou z peti pozic v druhém radku
% matice
figure ('name','Vykreslení oříznutých a vyčištěných snímků - DRUHÝ ŘÁDEK matice','numbertitle','off')
 for b = 1:7
   subplot (5,7,b)
   imshow(A_21{b})
   title (['A21 (',int2str(b-1),')']);
   
   subplot (5,7,(b+7))
   imshow(A_22{b})
   title (['A22 (',int2str(b-1),')'])
   
   subplot (5,7,(b+14))
   imshow(A_23{b})
   title (['A23 (',int2str(b-1),')'])
   
   subplot (5,7,(b+21))
   imshow(A_24{b})
   title (['A24 (',int2str(b-1),')'])
   
   subplot (5,7,(b+28))
   imshow(A_25{b})
   title (['A25 (',int2str(b-1),')'])
 end
  
% treti radek matice
figure ('name','Vykreslení oříznutých a vyčištěných snímků - TŘETÍ ŘÁDEK matice','numbertitle','off')
  for c = 1:7
   subplot (5,7,c)
   imshow(A_31{c})
   title (['A31 (',int2str(c-1),')']);
   
   subplot (5,7,(c+7))
   imshow(A_32{c})
   title (['A32 (',int2str(c-1),')'])
   
   subplot (5,7,(c+14))
   imshow(A_33{c})
   title (['A33 (',int2str(c-1),')'])
   
   subplot (5,7,(c+21))
   imshow(A_34{c})
   title (['A34 (',int2str(c-1),')'])
   
   subplot (5,7,(c+28))
   imshow(A_35{c})
   title (['A35 (',int2str(c-1),')'])
  end
  
% ctvrty radek matice
figure ('name','Vykreslení oříznutých a vyčištěných snímků - ČTVRTÝ ŘÁDEK matice','numbertitle','off')  
  for d = 1:7
   subplot (5,7,d)
   imshow(A_41{d})
   title (['A41 (',int2str(d-1),')']);
   
   subplot (5,7,(d+7))
   imshow(A_42{d})
   title (['A42 (',int2str(d-1),')'])
   
   subplot (5,7,(d+14))
   imshow(A_43{d})
   title (['A43 (',int2str(d-1),')'])
   
   subplot (5,7,(d+21))
   imshow(A_44{d})
   title (['A44 (',int2str(d-1),')'])
   
   subplot (5,7,(d+28))
   imshow(A_45{d})
   title (['A45 (',int2str(d-1),')'])
  end
   
  
%%      DRUHA CAST PROGRAMU 
%
% REALIZUJE NALEZENI TEZISTE CASTICE + POCITANI PIXELU V AXIALNIM A 
% LATERALNIM SMERU OD TOHOTO PIXELU A VYKRESLENI VYSLEDKU  

% vytvarim bunky do kterych budu ukladat data o vlastnostech vybranych 
% oblasti 
A11prop = {};
A12prop = {};
A13prop = {};
A14prop = {};
A15prop = {};
A21prop = {};
A22prop = {};
A23prop = {};
A24prop = {};
A25prop = {};
A31prop = {};
A32prop = {};
A33prop = {};
A34prop = {};
A35prop = {};
A41prop = {};
A42prop = {};
A43prop = {};
A44prop = {};
A45prop = {};

% pocitani teziste oblasti pomoci funkce regionprops 
for z = 1:7
 A11prop{z} = regionprops(A_11{z}, 'Centroid');
 A12prop{z} = regionprops(A_12{z}, 'Centroid');
 A13prop{z} = regionprops(A_13{z}, 'Centroid');
 A14prop{z} = regionprops(A_14{z}, 'Centroid');
 A15prop{z} = regionprops(A_15{z}, 'Centroid');
 A21prop{z} = regionprops(A_21{z}, 'Centroid');
 A22prop{z} = regionprops(A_22{z}, 'Centroid');
 A23prop{z} = regionprops(A_23{z}, 'Centroid');
 A24prop{z} = regionprops(A_24{z}, 'Centroid');
 A25prop{z} = regionprops(A_25{z}, 'Centroid');
 A31prop{z} = regionprops(A_31{z}, 'Centroid');
 A32prop{z} = regionprops(A_32{z}, 'Centroid');
 A33prop{z} = regionprops(A_33{z}, 'Centroid');
 A34prop{z} = regionprops(A_34{z}, 'Centroid');
 A35prop{z} = regionprops(A_35{z}, 'Centroid');
 A41prop{z} = regionprops(A_41{z}, 'Centroid');
 A42prop{z} = regionprops(A_42{z}, 'Centroid');
 A43prop{z} = regionprops(A_43{z}, 'Centroid');
 A44prop{z} = regionprops(A_44{z}, 'Centroid');
 A45prop{z} = regionprops(A_45{z}, 'Centroid');
end

% pro pozdejsi praci je treba, aby zadne pole nemělo nulovou hodnotu,
% proto takova pole definuji jako kopie jinych, ktere nenulovou hodnotu 
% maji - v pozdejsim pocitani pixelu je na to vsak bran zretel, a pole 
% jenz byla puvodne nulova budou pozdeji opet nulovana
A25prop{1} = A25prop{2};
A35prop{1} = A35prop{2};
A35prop{7} = A35prop{2};
A31prop{6} = A31prop{5};
A31prop{7} = A31prop{5};
A32prop{7} = A32prop{5};
A32prop{6} = A32prop{5};
A33prop{7} = A33prop{5};
A34prop{7} = A34prop{5};
A41prop{7} = A41prop{5};
A42prop{7} = A42prop{5};
A43prop{1} = A43prop{5};
A43prop{7} = A43prop{5};
A44prop{1} = A44prop{5};
A44prop{7} = A44prop{5};
A45prop{1} = A45prop{5};
A45prop{7} = A45prop{5};

% v kazde bunce je nyni obsazena struktura, kterou prevadim opet na bunku
% pro usnadneni pozdejsich operaci
for c = 1:7 
A11centroid(c) = struct2cell(A11prop{c}); 
A12centroid(c) = struct2cell(A12prop{c}); 
A13centroid(c) = struct2cell(A13prop{c}); 
A14centroid(c) = struct2cell(A14prop{c}); 
A15centroid(c) = struct2cell(A15prop{c}); 
A21centroid(c) = struct2cell(A21prop{c}); 
A22centroid(c) = struct2cell(A22prop{c}); 
A23centroid(c) = struct2cell(A23prop{c}); 
A24centroid(c) = struct2cell(A24prop{c}); 
A25centroid(c) = struct2cell(A25prop{c}); 
A31centroid(c) = struct2cell(A31prop{c}); 
A32centroid(c) = struct2cell(A32prop{c}); 
A33centroid(c) = struct2cell(A33prop{c}); 
A34centroid(c) = struct2cell(A34prop{c}); 
A35centroid(c) = struct2cell(A35prop{c}); 
A41centroid(c) = struct2cell(A41prop{c}); 
A42centroid(c) = struct2cell(A42prop{c}); 
A43centroid(c) = struct2cell(A43prop{c}); 
A44centroid(c) = struct2cell(A44prop{c}); 
A45centroid(c) = struct2cell(A45prop{c}); 
end

% nulovani poli, ktera byla pred prevodem struktury na bunku umele zaplnena
A25centroid{1}(:) = 0; 
A35centroid{1}(:) = 0; 
A35centroid{7}(:) = 0; 
A31centroid{6}(:) = 0; 
A31centroid{7}(:) = 0; 
A32centroid{6}(:) = 0; 
A32centroid{7}(:) = 0; 
A33centroid{7}(:) = 0; 
A34centroid{7}(:) = 0; 
A41centroid{7}(:) = 0; 
A42centroid{7}(:) = 0; 
A43centroid{1}(:) = 0; 
A43centroid{7}(:) = 0; 
A44centroid{1}(:) = 0; 
A44centroid{7}(:) = 0; 
A45centroid{1}(:) = 0; 
A45centroid{7}(:) = 0; 

% priprava pro pocitani pixelu od zjisteneho stredu
pocet11_axial = zeros(1,7);
pocet11_lateral = zeros(1,7);
pocet12_axial = zeros(1,7);
pocet12_lateral = zeros(1,7);
pocet13_axial = zeros(1,7);
pocet13_lateral = zeros(1,7);
pocet14_axial = zeros(1,7);
pocet14_lateral = zeros(1,7);
pocet15_axial = zeros(1,7);
pocet15_lateral = zeros(1,7);
pocet21_axial = zeros(1,7);
pocet21_lateral = zeros(1,7);
pocet22_axial = zeros(1,7);
pocet22_lateral = zeros(1,7);
pocet23_axial = zeros(1,7);
pocet23_lateral = zeros(1,7);
pocet24_axial = zeros(1,7);
pocet24_lateral = zeros(1,7);
pocet25_axial = zeros(1,7);
pocet25_lateral = zeros(1,7);
pocet31_axial = zeros(1,7);
pocet31_lateral = zeros(1,7);
pocet32_axial = zeros(1,7);
pocet32_lateral = zeros(1,7);
pocet33_axial = zeros(1,7);
pocet33_lateral = zeros(1,7);
pocet34_axial = zeros(1,7);
pocet34_lateral = zeros(1,7);
pocet35_axial = zeros(1,7);
pocet35_lateral = zeros(1,7);
pocet41_axial = zeros(1,7);
pocet41_lateral = zeros(1,7);
pocet42_axial = zeros(1,7);
pocet42_lateral = zeros(1,7);
pocet43_axial = zeros(1,7);
pocet43_lateral = zeros(1,7);
pocet44_axial = zeros(1,7);
pocet44_lateral = zeros(1,7);
pocet45_axial = zeros(1,7);
pocet45_lateral = zeros(1,7);

% pocitani pixelu pozdeji bude provadeno od pozice (radek-sloupec) kterou
% zaokrouhluji na cele cislo, jelikoz matlab pro indexovani radku/sloupcu
% v tomto pripade netoleruje des. cisla
for v1 = 1:7 
sloupec11 = round(A11centroid{v1}(1));     
  radek11 = round(A11centroid{v1}(2));
sloupec12 = round(A12centroid{v1}(1));     
  radek12 = round(A12centroid{v1}(2));
sloupec13 = round(A13centroid{v1}(1));     
  radek13 = round(A13centroid{v1}(2));
sloupec14 = round(A14centroid{v1}(1));     
  radek14 = round(A14centroid{v1}(2));
sloupec15 = round(A15centroid{v1}(1));     
  radek15 = round(A15centroid{v1}(2));  
sloupec21 = round(A21centroid{v1}(1));     
  radek21 = round(A21centroid{v1}(2));
sloupec22 = round(A22centroid{v1}(1));     
  radek22 = round(A22centroid{v1}(2));
sloupec23 = round(A23centroid{v1}(1));     
  radek23 = round(A23centroid{v1}(2));
sloupec24 = round(A24centroid{v1}(1));     
  radek24 = round(A24centroid{v1}(2));
sloupec25 = round(A25centroid{v1}(1));     
  radek25 = round(A25centroid{v1}(2)); 
sloupec31 = round(A31centroid{v1}(1));     
  radek31 = round(A31centroid{v1}(2));
sloupec32 = round(A32centroid{v1}(1));     
  radek32 = round(A32centroid{v1}(2));
sloupec33 = round(A33centroid{v1}(1));     
  radek33 = round(A33centroid{v1}(2));
sloupec34 = round(A34centroid{v1}(1));     
  radek34 = round(A34centroid{v1}(2));
sloupec35 = round(A35centroid{v1}(1));     
  radek35 = round(A35centroid{v1}(2));
sloupec41 = round(A41centroid{v1}(1));     
  radek41 = round(A41centroid{v1}(2));
sloupec42 = round(A42centroid{v1}(1));     
  radek42 = round(A42centroid{v1}(2));
sloupec43 = round(A43centroid{v1}(1));     
  radek43 = round(A43centroid{v1}(2));
sloupec44 = round(A44centroid{v1}(1));     
  radek44 = round(A44centroid{v1}(2));
sloupec45 = round(A45centroid{v1}(1));     
  radek45 = round(A45centroid{v1}(2));
   
% jelikoz v nekterych regionproperities je teziste 0 a zde pocitame radky
% a sloupce, je treba nastavit v oblastech s nulovým těžištěm řádek i
% sloupec na nenulovou hodnotu - libovolnou, jelikoz v danem snimku jsou
% vsechny radky i sloupce nuly, avsak nulty (z hlediska poradi) sloupec 
% nebo radek v matlabu neexistuje, proto nastavuji hodnotu napr. na 1 
  if v1 < 2
    radek25 = 1;
    sloupec25 = 1;
    radek35 = 1;
    sloupec35 = 1;
    radek43 = 1;
    sloupec43 = 1;
    radek44 = 1;
    sloupec44 = 1;
    radek45 = 1;
    sloupec45 = 1;
  end
  if v1 < 7 && v1 > 5
    sloupec31 = 1;
      radek31 = 1;
    sloupec32 = 1;
      radek32 = 1;
  end 
  if v1 > 6
    radek35 = 1;
    sloupec35 = 1;
    radek31 = 1;
    sloupec31 = 1;
    radek32 = 1;
    sloupec32 = 1;
    radek33 = 1;
    sloupec33 = 1;
    radek34 = 1;
    sloupec34 = 1;
    radek41 = 1;
    sloupec41 = 1;
    radek42 = 1;
    sloupec42 = 1;
    radek43 = 1;
    sloupec43 = 1;
    radek44 = 1;
    sloupec44 = 1;
    radek45 = 1;
    sloupec45 = 1;
  end

% pocitani pixelu v axialnim a lateralnim smeru          
for prochazeni = 1:36
 if A_11{v1}(radek11,prochazeni) > 0
     pocet11_lateral(v1) = pocet11_lateral(v1)+1;
 end
 if A_11{v1}(prochazeni,sloupec11) > 0
     pocet11_axial(v1) = pocet11_axial(v1)+1;
 end
  if A_12{v1}(radek12,prochazeni) > 0
     pocet12_lateral(v1) = pocet12_lateral(v1)+1;
 end
 if A_12{v1}(prochazeni,sloupec12) > 0
     pocet12_axial(v1) = pocet12_axial(v1)+1;
 end
  if A_13{v1}(radek13,prochazeni) > 0
     pocet13_lateral(v1) = pocet13_lateral(v1)+1;
 end
 if A_13{v1}(prochazeni,sloupec13) > 0
     pocet13_axial(v1) = pocet13_axial(v1)+1;
 end
  if A_14{v1}(radek14,prochazeni) > 0
     pocet14_lateral(v1) = pocet14_lateral(v1)+1;
 end
 if A_14{v1}(prochazeni,sloupec14) > 0
     pocet14_axial(v1) = pocet14_axial(v1)+1;
 end 
  if A_15{v1}(radek15,prochazeni) > 0
     pocet15_lateral(v1) = pocet15_lateral(v1)+1;
 end
 if A_15{v1}(prochazeni,sloupec15) > 0
     pocet15_axial(v1) = pocet15_axial(v1)+1;
 end
  if A_21{v1}(radek21,prochazeni) > 0
     pocet21_lateral(v1) = pocet21_lateral(v1)+1;
 end
 if A_21{v1}(prochazeni,sloupec21) > 0
     pocet21_axial(v1) = pocet21_axial(v1)+1;
 end
  if A_22{v1}(radek22,prochazeni) > 0
     pocet22_lateral(v1) = pocet22_lateral(v1)+1;
 end
 if A_22{v1}(prochazeni,sloupec22) > 0
     pocet22_axial(v1) = pocet22_axial(v1)+1;
 end
  if A_23{v1}(radek23,prochazeni) > 0
     pocet23_lateral(v1) = pocet23_lateral(v1)+1;
 end
 if A_23{v1}(prochazeni,sloupec23) > 0
     pocet23_axial(v1) = pocet23_axial(v1)+1;
 end
  if A_24{v1}(radek24,prochazeni) > 0
     pocet24_lateral(v1) = pocet24_lateral(v1)+1;
 end
 if A_24{v1}(prochazeni,sloupec24) > 0
     pocet24_axial(v1) = pocet24_axial(v1)+1;
 end 
  if A_25{v1}(radek25,prochazeni) > 0
     pocet25_lateral(v1) = pocet25_lateral(v1)+1;
 end
 if A_25{v1}(prochazeni,sloupec25) > 0
     pocet25_axial(v1) = pocet25_axial(v1)+1;
 end 
  if A_31{v1}(radek31,prochazeni) > 0
    pocet31_lateral(v1) = pocet31_lateral(v1)+1;
 end
 if A_31{v1}(prochazeni,sloupec31) > 0
     pocet31_axial(v1) = pocet31_axial(v1)+1;
 end
  if A_32{v1}(radek32,prochazeni) > 0
     pocet32_lateral(v1) = pocet32_lateral(v1)+1;
 end
 if A_32{v1}(prochazeni,sloupec32) > 0
     pocet32_axial(v1) = pocet32_axial(v1)+1;
 end
  if A_33{v1}(radek33,prochazeni) > 0
     pocet33_lateral(v1) = pocet33_lateral(v1)+1;
 end
 if A_33{v1}(prochazeni,sloupec33) > 0
     pocet33_axial(v1) = pocet33_axial(v1)+1;
 end
  if A_34{v1}(radek34,prochazeni) > 0
     pocet34_lateral(v1) = pocet34_lateral(v1)+1;
 end
 if A_34{v1}(prochazeni,sloupec34) > 0
     pocet34_axial(v1) = pocet34_axial(v1)+1;
 end 
  if A_35{v1}(radek35,prochazeni) > 0
     pocet35_lateral(v1) = pocet35_lateral(v1)+1;
 end
 if A_35{v1}(prochazeni,sloupec35) > 0
     pocet35_axial(v1) = pocet35_axial(v1)+1;
 end
  if A_41{v1}(radek41,prochazeni) > 0
     pocet41_lateral(v1) = pocet41_lateral(v1)+1;
 end
 if A_41{v1}(prochazeni,sloupec41) > 0
     pocet41_axial(v1) = pocet41_axial(v1)+1;
 end
  if A_42{v1}(radek42,prochazeni) > 0
     pocet42_lateral(v1) = pocet42_lateral(v1)+1;
 end
 if A_42{v1}(prochazeni,sloupec42) > 0
     pocet42_axial(v1) = pocet42_axial(v1)+1;
 end
  if A_43{v1}(radek43,prochazeni) > 0
     pocet43_lateral(v1) = pocet43_lateral(v1)+1;
 end
 if A_43{v1}(prochazeni,sloupec43) > 0
    pocet43_axial(v1) = pocet43_axial(v1)+1;
end
  if A_44{v1}(radek44,prochazeni) > 0
     pocet44_lateral(v1) = pocet44_lateral(v1)+1;
 end
 if A_44{v1}(prochazeni,sloupec44) > 0
     pocet44_axial(v1) = pocet44_axial(v1)+1;
end 
  if A_45{v1}(radek45,prochazeni) > 0
    pocet45_lateral(v1) = pocet45_lateral(v1)+1;
 end
if A_45{v1}(prochazeni,sloupec45) > 0
    pocet45_axial(v1) = pocet45_axial(v1)+1;
end
end
end

% pridani nulovych krajnich bodu do kazdeho vektoru (nutne pro pozdejsi
% vypocet FWHM
pocet11_lateral=nulovani(pocet11_lateral);
pocet12_lateral=nulovani(pocet12_lateral);
pocet13_lateral=nulovani(pocet13_lateral);
pocet14_lateral=nulovani(pocet14_lateral);
pocet15_lateral=nulovani(pocet15_lateral);
pocet11_axial=nulovani(pocet11_axial);
pocet12_axial=nulovani(pocet12_axial);
pocet13_axial=nulovani(pocet13_axial);
pocet14_axial=nulovani(pocet14_axial);
pocet15_axial=nulovani(pocet15_axial);

pocet21_lateral=nulovani(pocet21_lateral);
pocet22_lateral=nulovani(pocet22_lateral);
pocet23_lateral=nulovani(pocet23_lateral);
pocet24_lateral=nulovani(pocet24_lateral);
pocet25_lateral=nulovani(pocet25_lateral);
pocet21_axial=nulovani(pocet21_axial);
pocet22_axial=nulovani(pocet22_axial);
pocet23_axial=nulovani(pocet23_axial);
pocet24_axial=nulovani(pocet24_axial);
pocet25_axial=nulovani(pocet25_axial);

pocet31_lateral=nulovani(pocet31_lateral);
pocet32_lateral=nulovani(pocet32_lateral);
pocet33_lateral=nulovani(pocet33_lateral);
pocet34_lateral=nulovani(pocet34_lateral);
pocet35_lateral=nulovani(pocet35_lateral);
pocet31_axial=nulovani(pocet31_axial);
pocet32_axial=nulovani(pocet32_axial);
pocet33_axial=nulovani(pocet33_axial);
pocet34_axial=nulovani(pocet34_axial);
pocet35_axial=nulovani(pocet35_axial);

pocet41_lateral=nulovani(pocet41_lateral);
pocet42_lateral=nulovani(pocet42_lateral);
pocet43_lateral=nulovani(pocet43_lateral);
pocet44_lateral=nulovani(pocet44_lateral);
pocet45_lateral=nulovani(pocet45_lateral);
pocet41_axial=nulovani(pocet41_axial);
pocet42_axial=nulovani(pocet42_axial);
pocet43_axial=nulovani(pocet43_axial);
pocet44_axial=nulovani(pocet44_axial);
pocet45_axial=nulovani(pocet45_axial);

% jelikoz ma kazdy vektor vice nez 9 vzorku, muzeme konecne provest druhou
% interpolaci s vyuzitim matlabovske funkce interp
pocet11_lateral_interp2 = interp(pocet11_lateral,4);
pocet12_lateral_interp2 = interp(pocet12_lateral,4);
pocet13_lateral_interp2 = interp(pocet13_lateral,4);
pocet14_lateral_interp2 = interp(pocet14_lateral,4);
pocet15_lateral_interp2 = interp(pocet15_lateral,4);
pocet21_lateral_interp2 = interp(pocet21_lateral,4);
pocet22_lateral_interp2 = interp(pocet22_lateral,4);
pocet23_lateral_interp2 = interp(pocet23_lateral,4);
pocet24_lateral_interp2 = interp(pocet24_lateral,4);
pocet25_lateral_interp2 = interp(pocet25_lateral,4);
pocet31_lateral_interp2 = interp(pocet31_lateral,4);
pocet32_lateral_interp2 = interp(pocet32_lateral,4);
pocet33_lateral_interp2 = interp(pocet33_lateral,4);
pocet34_lateral_interp2 = interp(pocet34_lateral,4);
pocet35_lateral_interp2 = interp(pocet35_lateral,4);
pocet41_lateral_interp2 = interp(pocet41_lateral,4);
pocet42_lateral_interp2 = interp(pocet42_lateral,4);
pocet43_lateral_interp2 = interp(pocet43_lateral,4);
pocet44_lateral_interp2 = interp(pocet44_lateral,4);
pocet45_lateral_interp2 = interp(pocet45_lateral,4);
pocet11_axial_interp2 = interp(pocet11_axial,4);
pocet12_axial_interp2 = interp(pocet12_axial,4);
pocet13_axial_interp2 = interp(pocet13_axial,4);
pocet14_axial_interp2 = interp(pocet14_axial,4);
pocet15_axial_interp2 = interp(pocet15_axial,4);
pocet21_axial_interp2 = interp(pocet21_axial,4);
pocet22_axial_interp2 = interp(pocet22_axial,4);
pocet23_axial_interp2 = interp(pocet23_axial,4);
pocet24_axial_interp2 = interp(pocet24_axial,4);
pocet25_axial_interp2 = interp(pocet25_axial,4);
pocet31_axial_interp2 = interp(pocet31_axial,4);
pocet32_axial_interp2 = interp(pocet32_axial,4);
pocet33_axial_interp2 = interp(pocet33_axial,4);
pocet34_axial_interp2 = interp(pocet34_axial,4);
pocet35_axial_interp2 = interp(pocet35_axial,4);
pocet41_axial_interp2 = interp(pocet41_axial,4);
pocet42_axial_interp2 = interp(pocet42_axial,4);
pocet43_axial_interp2 = interp(pocet43_axial,4);
pocet44_axial_interp2 = interp(pocet44_axial,4);
pocet45_axial_interp2 = interp(pocet45_axial,4);


% jelikoz matlabovska funkce interp vytvari i zaporne hodnoty, je treba
% tyto "zaporne pixely" vynulovat
pocet11_axial_interp2(pocet11_axial_interp2<0)=0;
pocet12_axial_interp2(pocet12_axial_interp2<0)=0;
pocet13_axial_interp2(pocet13_axial_interp2<0)=0;
pocet14_axial_interp2(pocet14_axial_interp2<0)=0;
pocet15_axial_interp2(pocet15_axial_interp2<0)=0;
pocet21_axial_interp2(pocet21_axial_interp2<0)=0;
pocet22_axial_interp2(pocet22_axial_interp2<0)=0;
pocet23_axial_interp2(pocet23_axial_interp2<0)=0;
pocet24_axial_interp2(pocet24_axial_interp2<0)=0;
pocet25_axial_interp2(pocet25_axial_interp2<0)=0;
pocet31_axial_interp2(pocet31_axial_interp2<0)=0;
pocet32_axial_interp2(pocet32_axial_interp2<0)=0;
pocet33_axial_interp2(pocet33_axial_interp2<0)=0;
pocet34_axial_interp2(pocet34_axial_interp2<0)=0;
pocet35_axial_interp2(pocet35_axial_interp2<0)=0;
pocet41_axial_interp2(pocet41_axial_interp2<0)=0;
pocet42_axial_interp2(pocet42_axial_interp2<0)=0;
pocet43_axial_interp2(pocet43_axial_interp2<0)=0;
pocet44_axial_interp2(pocet44_axial_interp2<0)=0;
pocet45_axial_interp2(pocet45_axial_interp2<0)=0;
pocet11_lateral_interp2(pocet11_lateral_interp2<0)=0;
pocet12_lateral_interp2(pocet12_lateral_interp2<0)=0;
pocet13_lateral_interp2(pocet13_lateral_interp2<0)=0;
pocet14_lateral_interp2(pocet14_lateral_interp2<0)=0;
pocet15_lateral_interp2(pocet15_lateral_interp2<0)=0;
pocet21_lateral_interp2(pocet21_lateral_interp2<0)=0;
pocet22_lateral_interp2(pocet22_lateral_interp2<0)=0;
pocet23_lateral_interp2(pocet23_lateral_interp2<0)=0;
pocet24_lateral_interp2(pocet24_lateral_interp2<0)=0;
pocet25_lateral_interp2(pocet25_lateral_interp2<0)=0;
pocet31_lateral_interp2(pocet31_lateral_interp2<0)=0;
pocet32_lateral_interp2(pocet32_lateral_interp2<0)=0;
pocet33_lateral_interp2(pocet33_lateral_interp2<0)=0;
pocet34_lateral_interp2(pocet34_lateral_interp2<0)=0;
pocet35_lateral_interp2(pocet35_lateral_interp2<0)=0;
pocet41_lateral_interp2(pocet41_lateral_interp2<0)=0;
pocet42_lateral_interp2(pocet42_lateral_interp2<0)=0;
pocet43_lateral_interp2(pocet43_lateral_interp2<0)=0;
pocet44_lateral_interp2(pocet44_lateral_interp2<0)=0;
pocet45_lateral_interp2(pocet45_lateral_interp2<0)=0;

% priprava pro vykreslovani, nastaveni osy x
x = linspace(0,0.07,length(pocet45_axial_interp2));  
          
% vykreslení počtu pixelů v laterálním směru a prolozeni gaussovou funkci s
% vyuzitm funkce mygaussfit pro nalezeni gaussovy funkce; v kazdem kroku 
% for cyklu probiha take posunuti cele gaussovy krivky na horizontalni osu
% (funkce posun) aby bylo mozne korektne vypocist FWHM (funkce fwhm)
figure ('name','Odah PSF v jednotlivých pozicích - LATERÁLNÍ směr','numbertitle','off')  
 for z2 = 1:5       
   subplot (4,5,z2)
   mezipromena_pocet = ['pocet1',num2str(z2),'_lateral_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A1',num2str(z2)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')  
   fwhm_lateral_1(z2)= fwhm(odhad_gaussem,length(odhad_gaussem));
   
   subplot (4,5,5+z2)
   mezipromena_pocet = ['pocet2',num2str(z2),'_lateral_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   x_um = linspace(0,70,length(odhad_gaussem));
   odhad_gaussem = posun(odhad_gaussem);
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A2',num2str(z2)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_lateral_2(z2)= fwhm(odhad_gaussem,length(odhad_gaussem));
   
   subplot (4,5,10+z2)
   mezipromena_pocet = ['pocet3',num2str(z2),'_lateral_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A3',num2str(z2)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_lateral_3(z2)= fwhm(odhad_gaussem,length(odhad_gaussem));
   
   subplot (4,5,15+z2)
   mezipromena_pocet = ['pocet4',num2str(z2),'_lateral_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A4',num2str(z2)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_lateral_4(z2)= fwhm(odhad_gaussem,length(odhad_gaussem));
 end
 
% zopakovani predchoziho for cyklu, ale pro axialni smer
figure ('name','Odah PSF v jednotlivých pozicích - AXIÁLNÍ směr','numbertitle','off')  
 for z3 = 1:5 
   subplot (4,5,z3)
   mezipromena_pocet = ['pocet1',num2str(z3),'_axial_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));  
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A1',num2str(z3)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet)); 
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_axial_1(z3)= fwhm(odhad_gaussem,length(odhad_gaussem));
      
   subplot (4,5,5+z3)
   mezipromena_pocet = ['pocet2',num2str(z3),'_axial_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A2',num2str(z3)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));   
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_axial_2(z3)= fwhm(odhad_gaussem,length(odhad_gaussem));
   
   subplot (4,5,10+z3)
   mezipromena_pocet = ['pocet3',num2str(z3),'_axial_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   odhad_gaussem = posun(odhad_gaussem);
   x_um = linspace(0,70,length(odhad_gaussem));
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A3',num2str(z3)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));      
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_axial_3(z3)= fwhm(odhad_gaussem,length(odhad_gaussem));
   
   subplot (4,5,15+z3)
   mezipromena_pocet = ['pocet4',num2str(z3),'_axial_interp2'];
   [sigma,mu,A]=mygaussfit(x,eval(mezipromena_pocet),0.2);
   odhad_gaussem = A*exp(-(x-mu).^2 ./(2*sigma^2));
   x_um = linspace(0,70,length(odhad_gaussem));
   odhad_gaussem = posun(odhad_gaussem);
   plot(x_um,odhad_gaussem,'red','LineWidth',5);
   title(['A4',num2str(z3)]);  
   hold on
   stem(x_um,eval(mezipromena_pocet));    
   xlabel('vzdálenost [\mum]')
   ylabel('počet pixelů')
   fwhm_axial_4(z3)= fwhm(odhad_gaussem,length(odhad_gaussem));
 end
 
 % ulozeni vypoctenych fwhm do matice korespondujici rozmerove a pozicne s
 % vykreslenou mapou odhadu axialni PSF
 FWHM_axialni = zeros (4,5);
 FWHM_axialni(1,:) = fwhm_axial_1;
 FWHM_axialni(2,:) = fwhm_axial_2;
 FWHM_axialni(3,:) = fwhm_axial_3;
 FWHM_axialni(4,:) = fwhm_axial_4;
 
 % ulozeni vypoctenych fwhm do matice korespondujici rozmerove a pozicne s
 % vykreslenou mapou odhadu lateralni PSF
 FWHM_lateralni = zeros (4,5);
 FWHM_lateralni(1,:) = fwhm_lateral_1;
 FWHM_lateralni(2,:) = fwhm_lateral_2;
 FWHM_lateralni(3,:) = fwhm_lateral_3;
 FWHM_lateralni(4,:) = fwhm_lateral_4;
 % vykresleni prostoroveho rozlozeni FWHM
 FWHM_axialni
 FWHM_lateralni
 
% vykresleni barevne modulovane mapy prostoroveho rozlozeni FWHM
figure ('name','Barevna modulace FWHM','numbertitle','off')
subplot (2,1,1)
nazorne_fwhm(FWHM_axialni,512,512,23,38)
title('Barevná modulace prostorové distribuce axiální FWHM')
    xlabel('osa y');
    ylabel('osa z');
subplot (2,1,2) 
nazorne_fwhm(FWHM_lateralni,512,512,23,38)
title('Barevná modulace prostorové distribuce laterální FWHM')
    xlabel('osa y');
    ylabel('osa z');
 
%% KONEC PROGRAMU                                     JAN KADLA, 25.5.2012