clear all close all videoObjekt = VideoReader('test.mpg'); nFrames = videoObjekt.NumberOfFrames subplot(2,3,1);colormap(gray(256)) subplot(2,3,2);colormap(gray(256)) subplot(2,3,3);colormap(gray(256)) subplot(2,3,4);colormap(gray(256)) subplot(2,3,5);colormap(gray(256)) Bn=double(rgb2gray(read(videoObjekt, 1))); alpha = 0.05; thr = 10; h = fspecial('gaussian', [33 33], 10); for k = 2 : nFrames actframe=double(rgb2gray(read(videoObjekt, k))); dframe=abs(actframe-Bn); mframe = imfilter(dframe, h); bwframe = 255*im2bw(uint8(mframe), thr/255); % selektivita: mask = bwframe == 0; newdBn = alpha*double(actframe) + (1 - alpha)*Bn; Bn(mask == 1) = newdBn(mask == 1); subplot(2,3,1);image(actframe); subplot(2,3,2);image(Bn); subplot(2,3,3);image(dframe); subplot(2,3,4);image(mframe); subplot(2,3,5);image(bwframe); subplot(2,3,6);image(Bn.*mask); pause k end