function [ obraz_koeficientu ] = zobraz_koeficienty( koeficienty, urovne, colormapa )
%ZOBRAZ_KOEFICIENTY - Funkce slouzi k ulozeni vsech koeficientu libovolneho
%                     poctu transformaci do obrazu  
%   Detailed explanation goes here



x_height = 0;

% urceni rozmeru vysledenho obrazu

for p_ur = 1:urovne
    [rows,cols] = size(koeficienty{p_ur,1}{1,1});
    x_height = 4*rows + 3*5 + x_height;
    if p_ur < urovne
        x_height = x_height+5;
    end
    
    if p_ur == 1
        width = 4*cols + 3*5;
    end
end

if colormapa == 1
    plocha = zeros(x_height,width);

else
    plocha = ones(x_height,width); 
%plocha = plocha + 255;
end

struktura = zeros(urovne,2);
for p_ur = 1:urovne
    [struktura(p_ur,1),struktura(p_ur,2)] = size(koeficienty{p_ur,1}{1,1});
end



progress = waitbar(0, 'Vyckejte prosim ...');

for p_ur = 1:urovne
    posl_ur = urovne - p_ur + 1;
    [rows,cols] = size(koeficienty{posl_ur,1});
    radku = struktura(posl_ur,1);
    sloupcu = struktura(posl_ur,2);
    
    poc_rad_urovne = 0;
    
    for ur = 1:p_ur % vzdy pocatecni radek jednotlive urovne
        pred_uroven = urovne - ur + 2;
        if ur == 1
            poc_rad_urovne = 0;
        else
            poc_rad_urovne = poc_rad_urovne + 4*struktura(pred_uroven,1) + 4*5;
        end
    end
    
    
   % [radku,sloupcu] = size(koeficienty{posl_ur,1}{1,1});
    for row = 1:rows
        for col = 1:cols
            
            if row==1 && col==1 && p_ur>1
                
            else
            
                for akt_radek = 1:radku
                    origin_radek = poc_rad_urovne + akt_radek + (row-1)*radku + (row-1)*5;
                    origin_sloupec = 1+(col-1)*(sloupcu+5);

                       % imshow(log(abs(koeficienty{1,1}{1,1})/max(max(abs(koeficienty{1,1}{1,1})))+1));
                        temp_obraz = log(abs(koeficienty{posl_ur,1}{row,col})/max(max(abs(koeficienty{posl_ur,1}{row,col})))+1);

                    plocha(origin_radek,origin_sloupec : (origin_sloupec + sloupcu-1)) = temp_obraz(akt_radek,:);
                end
            end
        end
    end
    
    waitbar(p_ur/urovne,progress);
end

close(progress);


obraz_koeficientu = plocha;

end

