
clc
clear all
close all
warning off all
[num txt] = xlsread('seznam_registrovany sikim2.xls');
% [num txt] = xlsread('seznam_registrovany sikim2.xls');
cesta = 'c:\Users\Michal\Documents\VUTBR\Magistr\Diplomová práce\Programy\Hledání korespondenčních značek\Souřadnice_norm2\'; %cesta pro ulozeni vysledku
rozsah = size(txt);
tic

start = 1;
vse = 0;
for i = start:rozsah(2)
    for j = 2:rozsah(1)
        if length(cell2mat(txt(j,i))) == 0

            continue
        else
        vse = vse + 1;          

        end
    end
end
count = 0;
nul = 0;
souradnice_vse = [];
k = 1;
souradnice_jmena = [];
souradnice_jmena = string(souradnice_jmena);

for i = start:rozsah(2)
    for j = 2:rozsah(1)
        if length(cell2mat(txt(j,i))) == 0
            nul = nul + 1;
            continue
        else
                   
%             soubor = [cell2mat(txt(1,i)) '' cell2mat(txt(j,i))]
            if j ==2
                soubor = [cell2mat(txt(1,i)) '' cell2mat(txt(j,i)) '' '.jpg'];
            else
                soubor = [cell2mat(txt(1,i)) '' cell2mat(txt(j,i)) '' '.bmp'];
            end
            nazev = cell2mat(txt(j,i));
            count = count+1;
            clc
            odpocet(vse,count)  % zobrazeni provedenych % a casu do konce
            disp(num2str(cell2mat(txt(j,i))))
            disp('-------------------------------')
            
            a = imread(soubor);
            
            [obr,obr_vysl_g,souradnice] = komplexni(a);
            imwrite(obr_vysl_g,[cesta '' cell2mat(txt(j,i)) '' '_g.jpg']);
            imwrite(obr,[cesta '' cell2mat(txt(j,i)) '' '_norm.jpg']);
%             imwrite(obr,[cesta '' cell2mat(txt(j,i))]);
            
            souradnice_vse (k:k+1,1:length(souradnice)) = souradnice;
%             souradnice_jmena(k,1:length(nazev(1:end-4))) = nazev(1:end-4);
%             souradnice_jmena(k+1,1:length(nazev(1:end-4))) = nazev(1:end-4);
            souradnice_jmena(k,1:length(nazev)) = nazev;
            souradnice_jmena(k+1,1:length(nazev)) = nazev;           
            
            
            
            k = k+2;
        end
    end
    uloz_sourad = [cesta '' souradnice_jmena(1,:) '' '_sourad.mat'];
    uloz_popis = [cesta '' souradnice_jmena(1,:) '' '_sourad_popis.mat'];
    save (uloz_sourad, 'souradnice_vse')
    save (uloz_popis, 'souradnice_jmena')

    souradnice_vse = [];
    souradnice_jmena = [];
    souradnice_jmena = string(souradnice_jmena);
    k = 1;
end
