function out = wpaknnz(c)
% WPAKNNZ - Urceni poctu nenulovych hodnot dekompozice WPAKDEC
%   WPAKNNZ ziska pocet nenulovych hodnot z dekompozice C transformace
%   Wavelet Packet.
%   C se ziska pomoci WPAKDEC resp. WPAKDEC2
% 
%   Obecny tvar funkce:
%   OUT = WPAKNNZ(C)

%% Definice vstupnich promennych
leng = length(c);
%% Definice nejvyssi urovne
c{1}{1} = [];
%% Ponechani potrebnych vzorku
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
%% Urceni poctu nenulovych prvku vstupu
out = 0;
leng = length(c);
for i = 2:leng
    f = 1;
    for k = 1:length(c{i})
        if isempty(c{i}{f})==0
            w=nnz(c{i}{f});
            if isempty(w)==0
                out = out+w;
            end
            f = f+1;
        else 
             f=f+1;
        end
    end
end