- clear all
- clc
- imaqhwinfo
- vid = videoinput('winvideo')
- obraz=getsnapshot(vid);
- obr_sz=rgb2gray(obraz);
- obraz=imresize(obr_sz , 0.25);
- %tworzenie obrazow z zakloceniami
- obr_g=imnoise(obraz, 'gaussian');
- obr_sp=imnoise(obraz, 'salt & pepper');
- obr_p=pasy(obraz, 1, 25, 'poziome');
- figure(1);
- subplot(4,3,1); imshow(obr_g); title('gaus');
- subplot(4,3,2); imshow(obr_sp); title('salt and pepper');
- subplot(4,3,3); imshow(obr_p); title('poziome');
- %FILTRY
- %usredniajacy
- h_usr3=fspecial('average', [7 7]);
- obr_f = imfilter(obr_g,h_usr3);
- subplot(4,3,4); imshow(obr_f); title('usredniajacy');
- h_usr3=fspecial('average', [7 7]);
- obr_f = imfilter(obr_sp,h_usr3);
- subplot(4,3,5); imshow(obr_f); title('usredniajacy');
- h_usr3=fspecial('average', [7 7]);
- obr_f = imfilter(obr_p,h_usr3);
- subplot(4,3,6); imshow(obr_f); title('usredniajacy');
- %gaussa
- h_gauss = fspecial('gaussian', [3 7]);
- obr_f = imfilter(obr_g,h_gauss);
- subplot(4,3,7);
- imshow(obr_f);
- title('gauss');
- h_gauss = fspecial('gaussian', [3 7]);
- obr_f = imfilter(obr_sp,h_gauss);
- subplot(4,3,8);
- imshow(obr_f);
- title('gauss');
- h_gauss = fspecial('gaussian', [3 7]);
- obr_f = imfilter(obr_p,h_gauss);
- subplot(4,3,9);
- imshow(obr_f);
- title('gauss');
- %medianwy
- obr_f = medfilt2(obr_g, [3 7]);
- subplot(4,3,10);
- imshow(obr_f);
- title('medianwy');
- obr_f = medfilt2(obr_sp, [3 7]);
- subplot(4,3,11);
- imshow(obr_f);
- title('medianwy');
- obr_f = medfilt2(obr_p, [3 7]);
- subplot(4,3,12);
- imshow(obr_f);
- title('medianwy');
- %operator Sobela
- figure(2)
- h_sob1=fspecial('sobel');
- kraw_sob1=filter2(h_sob1,obr_sz);
- subplot(2,2,1);
- imshow(kraw_sob1);
- title('sobel1')
- h_sob2=-h_sob1';
- kraw_sob2=filter2(h_sob2,obr_sz);
- subplot(2,2,2);
- imshow(kraw_sob2);
- title('sobel2')
- %operator laplacea
- h_lap=fspecial('LAPLACIAN');
- kraw_lap=filter2(h_lap,obr_sz);
- subplot(2,2,3);
- imshow(kraw_lap);
- title('laplace1')
- %operator laplacea
- h_log=fspecial('log');
- kraw_log=filter2(h_log,obr_sz);
- subplot(2,2,4);
- imshow(kraw_log);
- title('logarytmiczny')
- h_sob2=-h_sob1';
- kraw_sob2=filter2(h_sob2,obr_sz);
- figure(3);
- subplot(111)
- imshow(kraw_sob2);