% clear all; close all; clc
% load('vysledok_br6_kontrast_spr.mat')
% load('obr_na_segmentaciu_br2.mat')
% s_max = 4*s_min;
% [s1, s2] = size(a);
% 
% % imshow(BW2)
% r_lbp = 16;
% % r_lbp_max = 16;
% % p_ch_z = zeros(r_lbp_max-2,2);
% % p = 1;
% % for r_lbp = 3:30;
% 
% f_s = p_klasifikacia(a, b, bf, s_min, pq, r_lbp, K, q_k, metoda_lbp, metoda_kontrast, kvant, R, N, lbp_q);
% 
% % %% zmena veľkosti obrazu v závislosti na zvolenom s_min
% % orezanie
% [ss1, ss2] = size(segmenty);
% rd = (ss1-floor(ss1/s_max)*s_max)/2; % rozdiel riadky
% cd = (ss2-floor(ss2/s_max)*s_max)/2; % rozdiel stĺpce
% segmenty = segmenty(1+rd : end - rd, 1+cd : end - cd);
% segmenty = segmenty(1:floor(ss1/s_max)*s_max, 1:floor(ss2/s_max)*s_max);
% 
% 
% se1 = segmenty(s1/4*1, s2/4*1);
% se2 = segmenty(s1/4*1, s2/4*3);
% se3 = segmenty(s1/4*3, s2/4*1);
% se4 = segmenty(s1/4*3, s2/4*3);
% se5 = segmenty(s1/2, s1/2);
% 
% sse1 = f_s(s1/4*1, s2/4*1);
% sse2 = f_s(s1/4*1, s2/4*3);
% sse3 = f_s(s1/4*3, s2/4*1);
% sse4 = f_s(s1/4*3, s2/4*3);
% sse5 = f_s(s1/2, s1/2);
% 
% vysledok = f_s;
% vysledok(f_s==sse1)=se1;
% vysledok(f_s==sse2)=se2;
% vysledok(f_s==sse3)=se3;
% vysledok(f_s==sse4)=se4;
% vysledok(f_s==sse5)=se5;
% 
% % figure
% % subplot(1,2,1)
% % imshow(vysledok,[])
% % subplot(1,2,2)
% % imshow(segmenty,[])
% 
% v = vysledok-segmenty;
% v = abs(v);
% v(v>0) = 1;
% p_ch = sum(sum(v));
% uspesnost = 100-p_ch/(s1*s2);
load('pixelwise_class.mat')

hranice = edge(vysledok,'Sobel');
hranice = bwmorph(hranice,'thin'); % stenšenie

original = a;
originalR = original;
originalG = original;
originalB = original;
originalR(hranice) = 0;
originalG(hranice) = 255;
originalB(hranice) = 0;

original(:,:,1)= originalR;
original(:,:,2)= originalG;
original(:,:,3)= originalB;
hranice = original;
original = original/255;

figure
subplot(1, 2, 1)
imshow(original,[])
subplot(1, 2, 2)
imshow(vysledok, [])
% p_ch_z(p, 1) = p_ch;
% p_ch_z(p, 2) = r_lbp;
% p = p+1;
% end
figure
plot(p_ch_z(:,2), p_ch_z(:,1))

figure
subplot(1, 2, 1)
imshow(segmenty,[])
subplot(1, 2, 2)
imshow(vysledok, [])