Professional Documents
Culture Documents
o
t: time
The main principals used in this
project:
So we can get a background image in
video sequences. Let it be background,
we can compare any frame in video
sequences with background, then we
get the motion.
Real process in the project:
First, we read all the data from video file, and
store them in a 4D array I(:,:,:,framenum);
Let image = I(:,:,:,k) – I(:,:,:,K-1), K=2
…noOfFrameImages.
Compute the norm of each image(x,y,:), if
norm > T1 then image(x,y,:) = 255 else
image(x,y,:) = 0;
PDIFF(:,:,:,K-1) = image; PDIFF records all
the pixels’ variation along time axis
Real process in the project:
Here is PDIFF image at time(frame) 68;
Real process in the project:
Denoise: Take erode operation on every
PDIFF image. Carefully select the slide
window size and threshold T2; The
following is the denoise matlab code:
function frameDif = erodeFramediff(frameDif)
height = size(frameDif,1);
width = size(frameDif,2);
erohalfwin = 1; %half of the erode window
T2 = 5;
%search for the entire image to denoise
for h = erohalfwin+1:1:height-erohalfwin-1
for w = erohalfwin+1:1:width-erohalfwin-1
count = 0;
if frameDif(h,w,:) ~= 0
%to decide if this point is a noise or not according to its
%neighbourhood
for h1 = -erohalfwin:1:erohalfwin
for w1 = -erohalfwin:1:erohalfwin
if frameDif(h+h1,w+w1,:) ~= 0
%to decide if this point is a noise or not according to its
%neighbourhood
for h1 = -erohalfwin:1:erohalfwin
for w1 = -erohalfwin:1:erohalfwin
if frameDif(h+h1,w+w1,:) ~= 0
count=count+1;
end
end
end
if count < erothreshold %this point is a noise
tempdif(h,w,:) = 0;
else tempdif(h,w,:) = 255;
end
end
end
end
frameDif = tempdif;
Get background image:
According to the PDIFF, we compute the
largest length in PDIFF along time axis
for every fixed pixel, select the middle
point among the segment as the
corresponding pixel of background.
Then we get the whole background
image.
A background image with filtering:
Motion detection:
We can locate the motion according to
the comparison between a frame at any
time t and the background image;
Motion location
Motion Location
The above result is a difference image
between background image and a
random frame from the video.
Conclusion:
To select a suitable threshold T1 and
T2 is very important to get the final
result .
Take erode operations on PDIFF is
necessary, the slide window size should
also be carefully selected.