%TYP4 najprv gaussian, potom rozdiely voči statickému pozadiu % Nedostatok: zaniká tracking pri prechode do tiena clear all close all videoObjekt = VideoReader('test.mpg'); nFrames = videoObjekt.NumberOfFrames subplot(2,2,1);colormap(gray(256)) subplot(2,2,2);colormap(gray(256)) subplot(2,2,3);colormap(gray(256)) subplot(2,2,4);colormap(gray(256)) bkgrframe=double(rgb2gray(read(videoObjekt, 1))); h = fspecial('gaussian', [33 33], 10); bkgframe = imfilter(bkgrframe, h); for k = 2 : nFrames actrframe=double(rgb2gray(read(videoObjekt, k))); actframe = imfilter(actrframe, h); dframe=abs(actframe-bkgframe); bwframe = 255*im2bw(uint8(dframe), 10/255); subplot(2,2,1);image(actframe); subplot(2,2,2);image(bkgframe); subplot(2,2,3);image(dframe); subplot(2,2,4);image(bwframe); pause k end