function wpaktree(c)
% WPAKTREE - Zobrazeni kvarterniho stromu transformace Wavelet Packet
%   WPAKTREE zobrazi pomoci koeficientu dekompozice C kvarterni strom 
%   a vyznaci v nich uzly dulezite z hlediska rekonstrukce.
% 
%   Vstup C musi obsahovat vsechny koeficienty dekompozice WPAKDEC.
% 
%   Obecny tvar funkce:
%   WPAKTREE(C)

%% Definice pomocnych promennych
leng = length(c);
e = length(c{end});
figure;
xlim([(0-(ceil(0.01*e))) (e+(ceil(0.01*e)))]);
ylim([0 leng+1]);
hold on;
%% Vykresleni vsech bodu Kvarterniho stromu 
for i = leng:-1:1
    for k = 1:length(c{leng-i+1})
        if isempty(c{leng-i+1}{k}) == 0;
            p1 = k*e/(length(c{leng-i+1}));
            p2 = 1*e/(length(c{leng-i+1}));
            plot(p1-p2/2,i,'Marker','o','Color','b','MarkerSize',2)
            text((p1-p2/2),i,['(',num2str(leng-i+1),',', num2str(k),')' ]);
            matice{leng-i+1}{k} = [p1-p2/2 i];
        else matice{leng-i+1}{k} = [];
        end
    end    
end
%% Spojeni bodu stromu
for i = 2:leng
    for k = 4:4:length(matice{i})
        if isempty(matice{i}{k}) == 0
            for r = 0:1:3
            plot([matice{i}{k-r}(1) matice{i-1}{k/4}(1)] , [matice{i}{k-r}(2) matice{i-1}{k/4}(2)]);
            end
        end
    end
end
%% Definice potrebnych koeficientu
for i = 2:1:leng
    d = 1;
    for k = 1:4:length(c{i})
        if isempty(c{i}{k}) == 0 || isempty(c{i}{k+1}) == 0 || isempty(c{i}{k+2}) == 0 || isempty(c{i}{k+3}) == 0
           c{i-1}{d} = [];
            d = d+1; 
        else d = d+1; 
        end        
    end    
end
%% Vyznaceni potrebnych koeficientu
for i = leng:-1:1
    for k = 1:length(c{leng-i+1})
        if isempty(c{leng-i+1}{k}) == 0;
            p1 = k*e/(length(c{leng-i+1}));
            p2 = 1*e/(length(c{leng-i+1}));
            plot(p1-p2/2,i,'Marker','o','Color','r','MarkerSize',2)
            matice{leng-i+1}{k} = [p1-p2/2 i];
        else matice{leng-i+1}{k} = [];
        end
        
    end
end
title('Kvarterni strom "Best Tree"');