Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all
- img = imread('piesek.jpg');
- %% zad 1 i 2
- % hist(1:256,1) = uint64(0);
- % imgv = img(:,:,1);
- % imgv = imgv(:);
- % for i=1:numel(imgv)
- % hist(imgv(i)+1) = hist(imgv(i)+1)+1;
- % end
- % cumul = cumsum(double(hist));
- % figure(1)
- % bar(hist)
- % figure(2)
- % bar(cumul)
- %% zad 3
- szary = cv.cvtColor(img,'RGB2GRAY');
- colormap(gray(256));
- szary1 = szary(:);
- szary1 = szary1(:);
- hist(1:256,1) = 0;
- for i = 1:length(szary1)
- hist(szary1(i)+1) = hist(szary1(i)+1)+1;
- end
- figure(10)
- bar(smooth(hist,90))
- hh = smooth(hist,90);
- for i = 1:126
- if hh(128-i) < hh(127-i) && hh(128-i) < hh(129-i)
- min = 127 - i - 1;
- break;
- end
- if hh(128+i) < hh(127+i) && hh(128+i) < hh(129+i)
- min = 127 + i - 1;
- break;
- end
- end
- bin = szary>min;
- figure(4)
- colormap(gray(2));
- image(bin)
- %% zad 4
- figure(5)
- XX = cv.threshold(szary,'auto','Method', 'Binary');
- colormap(gray(2));
- image(XX)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement