clear all; close all; %clc

% zoznam = [1,1; 1,4; 2,2; 2,4; 3,3; 3,4; 4,1; 5,1; 6,1; 4,2;...
%           5,2; 6,2; 4,3; 5,3; 6,3; 4,4; 5,4; 6,4];
% sz = size(zoznam);
% for z = 1:sz(2);

% prípustné kombinácie
% metoda_lbp, metoda_kontrast
% 1,1
% 1,4
% 2,2
% 2,4
% 3,3
% 3,4

% Pre R = 1; N = 8;     Pre R = 2; N = 12;    Pre R = 3; N = 16;    
% 4,1                   4,2                   4,3                  
% 5,1                   5,2                   5,3                  
% 6,1                   6,2                   6,3                  

% pre ľubovoľné R a N
% 4,4
% 5,4
% 6,4

%% LBP
metoda_lbp = 1; % naprogramovana funkcia R = 1, N = 8
% metoda_lbp = 2; % naprogramovana funkcia R = 2, N = 12
% metoda_lbp = 3; % naprogramovana funkcia R = 3, N = 16
% metoda_lbp = 4; % prevzata funkcia LBP - potrebne definovat R, N
% metoda_lbp = 5; % prevzata funkcia LBP u2 - potrebne definovat R, N
% metoda_lbp = 6; % prevzata funkcia LBP ri - potrebne definovat R, N
% metoda_lbp = 7; % prevzata funkcia LBP riu2 - potrebne definovat R, N
R = 1; N = 8;

%% kontrast
metoda_kontrast = 1; % naprogramovana funkcia R = 1, N = 8
% metoda_kontrast = 2; % naprogramovana funkcia R = 2, N = 12
% metoda_kontrast = 3; % naprogramovana funkcia R = 3, N = 16
% metoda_kontrast = 4; % prevzata funkcia - potrebne definovat R, N

%% počet kvantizačných úrovní kontrastu
pq = 4; % pre 1,1

%% spôsob kvantizácie
% q_k = 1; % kvantizácia celého rozsahu od min po max
% q_k = 2; % kvantizácia rozsahu <median-1.5*IQR, median+1.5*IQR>
q_k = 3; % kvantizácia podľa rozdelenia celych dat - percentily
% q_k = 4; % kvantizácia rozsahu <kvantil_1-1.5*IQR, kvantil_3+1.5*IQR>

%% konštanta
K = 500;
%% načítanie dát pre klasifikáciu
% load('databaza_tried_lbp.mat')
% load('databaza_testov_lbp.mat')

load('databaza_tried_lbp_br.mat')
load('databaza_testov_lbp_br.mat')

% load('databaza_tried_lbp_br_uprava_jasu.mat')
% load('databaza_testov_lbp_br_uprava_jasu.mat')

%% Klasifikácia

[s1,s2] = size(dVzoriek_triedy);
sd = size(dVzoriek_triedy{1,1});

h_tr = cell(s1, s2); % bunkove pole zdruzenych histogramov vsetkych vzoriek
h_te = cell(s1, s2); % bunkove pole zdruzenych histogramov vsetkych vzoriek

%% analyza distribucie kontrastu/VAR v celom súbore dát
switch(metoda_lbp)
    case 1
        C_z = zeros(s1*s2*(sd(1)-2), sd(2)-2);
    case 2
        C_z = zeros(s1*s2*(sd(1)-4), sd(2)-4);
    case 3
        C_z = zeros(s1*s2*(sd(1)-6), sd(2)-6);
end

p = 1;
for i = 1:s1
    for j = 1:s2
        a = double(dVzoriek_triedy{i,j});
        switch(metoda_kontrast)
            case 1
                C_z(p:p+(sd(1)-3),:) = kontrast_8_1(a);
            case 2
                C_z(p:p+(sd(1)-5),:) = kontrast_12_2(a);
            case 3
                C_z(p:p+(sd(1)-7),:) = kontrast_16_3(a);
            case 4
                C_z(p:p+(sd(1)-3),:) = cont(a,R,N);
        end
        p = p + sd(1)-2;
    end
end

% % overenie vplyvu počtu kvantizačných úrovní na presnosť klasifikácie
% max_pq = 15;
% u_pm = zeros(max_pq-1,1);
% p = 1;
% for pq = 2:max_pq

% % overenie vplyvu veľkosti konštanty K na presnosť klasifikácie
% max_K = 1000;
% u_K = zeros(10,1);
% p = 1;
% for K = 1:20:max_K

%% vytvorenie intervalov pre kvantovanie podľa spôsobu kvantovania
C_z = C_z'; C_z = C_z(:)'; % prevod matice priznakov na vektor

switch(q_k)
    case 2
        iqr_C = iqr(C_z);
    	C_median = median(C_z);
        int_Cm1 = C_median-1.5*iqr_C;
        int_Cm2 = C_median+1.5*iqr_C;
        krok_m = (int_Cm2-int_Cm1)/pq;
        C_med = int_Cm1:krok_m:int_Cm2;
        C_med(1) = min(min(C_z));
        C_med(end) = max(max(C_z));
    case 3
        krok_p = 100/pq;
        C_perc = prctile(C_z,krok_p:krok_p:100-krok_p);
        C_perc = [min(min(C_z)), C_perc, max(max(C_z))];
    case 4
        iqr_C = iqr(C_z);
        k1 = quantile(C_z,0.25);
        k3 = quantile(C_z,0.75);
        int_Ck1 = k1-1.5*iqr_C;
        int_Ck2 = k3+1.5*iqr_C;
        krok_k = (int_Ck2-int_Ck1)/pq;
        C_k = int_Ck1:krok_k:int_Ck2;
        C_k(1) = min(min(C_z));
        C_k(end) = max(max(C_z));
end

%% klasifikácia
for i = 1:s1
    for j = 1:s2
        a = double(dVzoriek_triedy{i,j});
        switch(metoda_lbp)
            case 1
                lbp_m = lbp_8_1(a);
                lbp_q = 256;
            case 2
                lbp_m = lbp_12_2(a);
                lbp_q = 4096;
            case 3
                lbp_m = lbp_16_3(a);
                lbp_m = kvantizacia_lbp(lbp_m, 4096);
                lbp_q = 4096;
            case 4
                lbp_m = lbp(a,R,N,0,0);
                lbp_q = 256;
            case 5
                mapping = getmapping(N,'u2');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
            case 6
                mapping = getmapping(N,'ri');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
            case 7
                mapping = getmapping(N,'riu2');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
        end

        switch(metoda_kontrast)
            case 1
                C_m = kontrast_8_1(a);
            case 2
                C_m = kontrast_12_2(a);
            case 3
                C_m = kontrast_16_3(a);
            case 4
                C_m = cont(a,R,N);
        end

        switch(q_k)
            case 1
            C_m = kvantizacia_C(C_m, pq);
            case 2
            C_m = kvantizacia_C_median_iqr(C_m, C_med);
            case 3
            C_m = kvantizacia_C_percentily(C_m, C_perc);
            case 4
            C_m = kvantizacia_C_kvantily_iqr(C_m, C_k);
        end

        h = joint_histogram_d(C_m, lbp_m, pq, lbp_q); % kontrast vertikalna os, lbp horizontalna
%         h = joint_histogram(C_m,lbp_m); % kontrast vertikalna os, lbp horizontalna
        
        h = h*K;
        h_tr{i,j} = h;
    end
end

h1 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h1(:,:,i) = h_tr{i,1}; 
end

h2 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h2(:,:,i) = h_tr{i,2}; 
end

h3 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h3(:,:,i) = h_tr{i,3}; 
end

h4 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h4(:,:,i) = h_tr{i,4}; 
end

h5 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h5(:,:,i) = h_tr{i,5}; 
end

h6 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h6(:,:,i) = h_tr{i,6}; 
end

h7 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h7(:,:,i) = h_tr{i,7}; 
end

h8 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h8(:,:,i) = h_tr{i,8}; 
end

h9 = zeros(pq, lbp_q, s1);
for i = 1:s1
   h9(:,:,i) = h_tr{i,9}; 
end

%     h1m = round(mean(h1,3));
%     h2m = round(mean(h2,3));
%     h3m = round(mean(h3,3));
%     h4m = round(mean(h4,3));
%     h5m = round(mean(h5,3));
%     h6m = round(mean(h6,3));
%     h7m = round(mean(h7,3));
%     h8m = round(mean(h8,3));
%     h9m = round(mean(h9,3));

    h1m = mean(h1,3);
    h2m = mean(h2,3);
    h3m = mean(h3,3);
    h4m = mean(h4,3);
    h5m = mean(h5,3);
    h6m = mean(h6,3);
    h7m = mean(h7,3);
    h8m = mean(h8,3);
    h9m = mean(h9,3);

%     h1m = sum(h1,3);
%     h2m = sum(h2,3);
%     h3m = sum(h3,3);
%     h4m = sum(h4,3);
%     h5m = sum(h5,3);
%     h6m = sum(h6,3);
%     h7m = sum(h7,3);
%     h8m = sum(h8,3);
%     h9m = sum(h9,3);

    h1m(h1m<1)=1;
    h2m(h2m<1)=1;
    h3m(h3m<1)=1;
    h4m(h4m<1)=1;
    h5m(h5m<1)=1;
    h6m(h6m<1)=1;
    h7m(h7m<1)=1;
    h8m(h8m<1)=1;
    h9m(h9m<1)=1;

% Testovanie
for i = 1:s1
    for j = 1:s2
        a = double(dVzoriek_testy{i,j});
        switch(metoda_lbp)
            case 1
                lbp_m = lbp_8_1(a);
                lbp_q = 256;
            case 2
                lbp_m = lbp_12_2(a);
                lbp_q = 4096;
            case 3
                lbp_m = lbp_16_3(a);
                lbp_m = kvantizacia_lbp(lbp_m, 4096);
                lbp_q = 4096;
            case 4
                lbp_m = lbp(a,R,N,0,0);
                lbp_q = 256;
            case 5
                mapping = getmapping(N,'u2');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
            case 6
                mapping = getmapping(N,'ri');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
            case 7
                mapping = getmapping(N,'riu2');
                lbp_m = lbp(a,R,N,mapping,0);
                lbp_q = mapping.num;
        end

        switch(metoda_kontrast)
            case 1
                C_m = kontrast_8_1(a);
            case 2
                C_m = kontrast_12_2(a);
            case 3
                C_m = kontrast_16_3(a);
            case 4
                C_m = cont(a,R,N);
        end

        switch(q_k)
            case 1
            C_m = kvantizacia_C(C_m, pq);
            case 2
            C_m = kvantizacia_C_median_iqr(C_m, C_med);
            case 3
            C_m = kvantizacia_C_percentily(C_m, C_perc);
            case 4
            C_m = kvantizacia_C_kvantily_iqr(C_m, C_k);
        end
        
        h = joint_histogram_d(C_m, lbp_m, pq, lbp_q); % kontrast vertikalna os, lbp horizontalna
        h = h*K;
        h_te{i,j} = h;
    end
end

riadok = 1;
prehlad = zeros(s1*s2, s2);
for i = 1:s2
    for j = 1:s1
        t = h_te{j,i};
        t(t<1)=1;
        G = zeros(1,s2);
        G(1,1) = g_stat(t, h1m);
        G(1,2) = g_stat(t, h2m);
        G(1,3) = g_stat(t, h3m);
        G(1,4) = g_stat(t, h4m);
        G(1,5) = g_stat(t, h5m);
        G(1,6) = g_stat(t, h6m);
        G(1,7) = g_stat(t, h7m);
        G(1,8) = g_stat(t, h8m);
        G(1,9) = g_stat(t, h9m);

        prehlad(riadok,:) = G;
        riadok = riadok+1;
    end
end

vysledky = zeros(s1*s2, s2);
for o = 1:s1*s2
        [M,I] = min(prehlad(o,:));
        vysledky(o,I) = 1;
end


% časti matice výsledkov kde má byť podľa správnosti súčet rovný
% testovanému počtu obrázkov danej triedy

v1 = vysledky(1:s1,1);
v2 = vysledky(s1+1:2*s1,2);
v3 = vysledky(2*s1+1:3*s1,3);
v4 = vysledky(3*s1+1:4*s1,4);
v5 = vysledky(4*s1+1:5*s1,5);
v6 = vysledky(5*s1+1:6*s1,6);
v7 = vysledky(6*s1+1:7*s1,7);
v8 = vysledky(7*s1+1:8*s1,8);
v9 = vysledky(8*s1+1:9*s1,9);

ch_a2 = vysledky(1:s1,2);            pch_a2 = sum(ch_a2); % súčet chybných klasifikácii
ch_a3 = vysledky(1:s1,3);            pch_a3 = sum(ch_a3);
ch_a4 = vysledky(1:s1,4);            pch_a4 = sum(ch_a4);
ch_a5 = vysledky(1:s1,5);            pch_a5 = sum(ch_a5);
ch_a6 = vysledky(1:s1,6);            pch_a6 = sum(ch_a6);
ch_a7 = vysledky(1:s1,7);            pch_a7 = sum(ch_a7);
ch_a8 = vysledky(1:s1,8);            pch_a8 = sum(ch_a8);
ch_a9 = vysledky(1:s1,9);            pch_a9 = sum(ch_a9);

ch_b1 = vysledky(s1+1:2*s1,1);        pch_b1 = sum(ch_b1);
ch_b3 = vysledky(s1+1:2*s1,3);        pch_b3 = sum(ch_b3);
ch_b4 = vysledky(s1+1:2*s1,4);        pch_b4 = sum(ch_b4);
ch_b5 = vysledky(s1+1:2*s1,5);        pch_b5 = sum(ch_b5);
ch_b6 = vysledky(s1+1:2*s1,6);        pch_b6 = sum(ch_b6);
ch_b7 = vysledky(s1+1:2*s1,7);        pch_b7 = sum(ch_b7);
ch_b8 = vysledky(s1+1:2*s1,8);        pch_b8 = sum(ch_b8);
ch_b9 = vysledky(s1+1:2*s1,9);        pch_b9 = sum(ch_b9);

ch_c1 = vysledky(2*s1+1:3*s1,1);      pch_c1 = sum(ch_c1);
ch_c2 = vysledky(2*s1+1:3*s1,2);      pch_c2 = sum(ch_c2);
ch_c4 = vysledky(2*s1+1:3*s1,4);      pch_c4 = sum(ch_c4);
ch_c5 = vysledky(2*s1+1:3*s1,5);      pch_c5 = sum(ch_c5);
ch_c6 = vysledky(2*s1+1:3*s1,6);      pch_c6 = sum(ch_c6);
ch_c7 = vysledky(2*s1+1:3*s1,7);      pch_c7 = sum(ch_c7);
ch_c8 = vysledky(2*s1+1:3*s1,8);      pch_c8 = sum(ch_c8);
ch_c9 = vysledky(2*s1+1:3*s1,9);      pch_c9 = sum(ch_c9);

ch_d1 = vysledky(3*s1+1:4*s1,1);      pch_d1 = sum(ch_d1);
ch_d2 = vysledky(3*s1+1:4*s1,2);      pch_d2 = sum(ch_d2);
ch_d3 = vysledky(3*s1+1:4*s1,3);      pch_d3 = sum(ch_d3);
ch_d5 = vysledky(3*s1+1:4*s1,5);      pch_d5 = sum(ch_d5);
ch_d6 = vysledky(3*s1+1:4*s1,6);      pch_d6 = sum(ch_d6);
ch_d7 = vysledky(3*s1+1:4*s1,7);      pch_d7 = sum(ch_d7);
ch_d8 = vysledky(3*s1+1:4*s1,8);      pch_d8 = sum(ch_d8);
ch_d9 = vysledky(3*s1+1:4*s1,9);      pch_d9 = sum(ch_d9);

ch_e1 = vysledky(4*s1+1:5*s1,1);      pch_e1 = sum(ch_e1);
ch_e2 = vysledky(4*s1+1:5*s1,2);      pch_e2 = sum(ch_e2);
ch_e3 = vysledky(4*s1+1:5*s1,3);      pch_e3 = sum(ch_e3);
ch_e4 = vysledky(4*s1+1:5*s1,4);      pch_e4 = sum(ch_e4);
ch_e6 = vysledky(4*s1+1:5*s1,6);      pch_e6 = sum(ch_e6);
ch_e7 = vysledky(4*s1+1:5*s1,7);      pch_e7 = sum(ch_e7);
ch_e8 = vysledky(4*s1+1:5*s1,8);      pch_e8 = sum(ch_e8);
ch_e9 = vysledky(4*s1+1:5*s1,9);      pch_e9 = sum(ch_e9);

ch_f1 = vysledky(5*s1+1:6*s1,1);      pch_f1 = sum(ch_f1);
ch_f2 = vysledky(5*s1+1:6*s1,2);      pch_f2 = sum(ch_f2);
ch_f3 = vysledky(5*s1+1:6*s1,3);      pch_f3 = sum(ch_f3);
ch_f4 = vysledky(5*s1+1:6*s1,4);      pch_f4 = sum(ch_f4);
ch_f5 = vysledky(5*s1+1:6*s1,5);      pch_f5 = sum(ch_f5);
ch_f7 = vysledky(5*s1+1:6*s1,7);      pch_f7 = sum(ch_f7);
ch_f8 = vysledky(5*s1+1:6*s1,8);      pch_f8 = sum(ch_f8);
ch_f9 = vysledky(5*s1+1:6*s1,9);      pch_f9 = sum(ch_f9);

ch_g1 = vysledky(6*s1+1:7*s1,1);      pch_g1 = sum(ch_g1);
ch_g2 = vysledky(6*s1+1:7*s1,2);      pch_g2 = sum(ch_g2);
ch_g3 = vysledky(6*s1+1:7*s1,3);      pch_g3 = sum(ch_g3);
ch_g4 = vysledky(6*s1+1:7*s1,4);      pch_g4 = sum(ch_g4);
ch_g5 = vysledky(6*s1+1:7*s1,5);      pch_g5 = sum(ch_g5);
ch_g6 = vysledky(6*s1+1:7*s1,6);      pch_g6 = sum(ch_g6);
ch_g8 = vysledky(6*s1+1:7*s1,8);      pch_g8 = sum(ch_g8);
ch_g9 = vysledky(6*s1+1:7*s1,9);      pch_g9 = sum(ch_g9);

ch_h1 = vysledky(7*s1+1:8*s1,1);      pch_h1 = sum(ch_h1);
ch_h2 = vysledky(7*s1+1:8*s1,2);      pch_h2 = sum(ch_h2);
ch_h3 = vysledky(7*s1+1:8*s1,3);      pch_h3 = sum(ch_h3);
ch_h4 = vysledky(7*s1+1:8*s1,4);      pch_h4 = sum(ch_h4);
ch_h5 = vysledky(7*s1+1:8*s1,5);      pch_h5 = sum(ch_h5);
ch_h6 = vysledky(7*s1+1:8*s1,6);      pch_h6 = sum(ch_h6);
ch_h7 = vysledky(7*s1+1:8*s1,7);      pch_h7 = sum(ch_h7);
ch_h9 = vysledky(7*s1+1:8*s1,9);      pch_h9 = sum(ch_h9);

ch_i1 = vysledky(8*s1+1:end,1);      pch_i1 = sum(ch_i1);
ch_i2 = vysledky(8*s1+1:end,2);      pch_i2 = sum(ch_i2);
ch_i3 = vysledky(8*s1+1:end,3);      pch_i3 = sum(ch_i3);
ch_i4 = vysledky(8*s1+1:end,4);      pch_i4 = sum(ch_i4);
ch_i5 = vysledky(8*s1+1:end,5);      pch_i5 = sum(ch_i5);
ch_i6 = vysledky(8*s1+1:end,6);      pch_i6 = sum(ch_i6);
ch_i7 = vysledky(8*s1+1:end,7);      pch_i7 = sum(ch_i7);
ch_i8 = vysledky(8*s1+1:end,8);      pch_i8 = sum(ch_i8);

ks1 = sum(v1);   % kontrolná suma - súčet príslušnej časti každého zo stĺpcov musí  
ks2 = sum(v2);   % byť rovný počtu obr. z danej triedy
ks3 = sum(v3);
ks4 = sum(v4);
ks5 = sum(v5);
ks6 = sum(v6);
ks7 = sum(v7);
ks8 = sum(v8);
ks9 = sum(v9);

% confusion matrix - vyjadrenie percentuálnej úspešnosti klasifikácie
cm = zeros(10);
a = (1:9);
b = a';
cm(1:1,2:10) = a;
cm(2:10,1:1) = b;

cm(2,2) = ks1/s1;    cm(3,3) = ks2/s1;    cm(4,4) = ks3/s1;    cm(5,5) = ks4/s1;
cm(6,6) = ks5/s1;    cm(7,7) = ks6/s1;    cm(8,8) = ks7/s1;    cm(9,9) = ks8/s1;    cm(10,10) = ks9/s1;

cm(3,2) = pch_a2/s1; cm(4,2) = pch_a3/s1; cm(5,2) = pch_a4/s1; cm(6,2) = pch_a5/s1; cm(7,2) = pch_a6/s1; cm(8,2) = pch_a7/s1; cm(9,2) = pch_a8/s1; cm(10,2) = pch_a9/s1;

cm(2,3) = pch_b1/s1; cm(4,3) = pch_b3/s1; cm(5,3) = pch_b4/s1; cm(6,3) = pch_b5/s1; cm(7,3) = pch_b6/s1; cm(8,3) = pch_b7/s1; cm(9,3) = pch_b8/s1; cm(10,3) = pch_b9/s1;

cm(2,4) = pch_c1/s1; cm(3,4) = pch_c2/s1; cm(5,4) = pch_c4/s1; cm(6,4) = pch_c5/s1; cm(7,4) = pch_c6/s1; cm(8,4) = pch_c7/s1; cm(9,4) = pch_c8/s1; cm(10,4) = pch_c9/s1;

cm(2,5) = pch_d1/s1; cm(3,5) = pch_d2/s1; cm(4,5) = pch_d3/s1; cm(6,5) = pch_d5/s1; cm(7,5) = pch_d6/s1; cm(8,5) = pch_d7/s1; cm(9,5) = pch_d8/s1; cm(10,5) = pch_d9/s1;

cm(2,6) = pch_e1/s1; cm(3,6) = pch_e2/s1; cm(4,6) = pch_e3/s1; cm(5,6) = pch_e4/s1; cm(7,6) = pch_e6/s1; cm(8,6) = pch_e7/s1; cm(9,6) = pch_e8/s1; cm(10,6) = pch_e9/s1;

cm(2,7) = pch_f1/s1; cm(3,7) = pch_f2/s1; cm(4,7) = pch_f3/s1; cm(5,7) = pch_f4/s1; cm(6,7) = pch_f5/s1; cm(8,7) = pch_f7/s1; cm(9,7) = pch_f8/s1; cm(10,7) = pch_f9/s1;

cm(2,8) = pch_g1/s1; cm(3,8) = pch_g2/s1; cm(4,8) = pch_g3/s1; cm(5,8) = pch_g4/s1; cm(6,8) = pch_g5/s1; cm(7,8) = pch_g6/s1; cm(9,8) = pch_g8/s1; cm(10,8) = pch_g9/s1;

cm(2,9) = pch_h1/s1; cm(3,9) = pch_h2/s1; cm(4,9) = pch_h3/s1; cm(5,9) = pch_h4/s1; cm(6,9) = pch_h5/s1; cm(7,9) = pch_h6/s1; cm(8,9) = pch_h7/s1; cm(10,9) = pch_h9/s1;

cm(2,10)= pch_i1/s1; cm(3,10)= pch_i2/s1; cm(4,10)= pch_i3/s1; cm(5,10) = pch_i4/s1; cm(6,10) = pch_i5/s1; cm(10,2) = pch_i6/s1; cm(8,10) = pch_i7/s1; cm(9,10) = pch_i8/s1;


cm(2:end, 2:end) = cm(2:end, 2:end)*100;

% cn = [9, 1];
% výpočet počtu chýb
p_ch = s2*s1-ks1-ks2-ks3-ks4-ks5-ks6-ks7-ks8-ks9;

% celková úspešnosť klasifikácie v %
u_p = (s2*s1-p_ch)/(s2*s1)*100;
%   disp(p_ch)
disp(cm)
disp(['celková úspešnosť: ' num2str(u_p) ' %'])
disp(['metoda_lbp: ' num2str(metoda_lbp)])
disp(['metoda_kontrast: ' num2str(metoda_kontrast)])
disp(['počet kvantizačných úrovní: ' num2str(pq)])
disp(['spôsob kvantizácie: ' num2str(q_k)])

% % overenie vplyvu počtu kvantizačných úrovní na presnosť klasifikácie
%     u_pm(p,1) = u_p;
%     u_pm(p,2) = pq;
%     p = p+1;
%     
% end
% % overenie vplyvu veľkosti konštanty K na presnosť klasifikácie
%     u_K(p,1) = u_p;
%     u_K(p,2) = K;
%     p = p+1;
%     
% end


% figure
% plot(u_pm(:,2), u_pm(:,1))

% figure
% plot(u_K(:,2), u_K(:,1))

% save('klasifikacia_br_lbp_joint.mat', 'u_pm', 'metoda_lbp', 'metoda_kontrast', 'q_k', 'K')
