Saturday, May 22, 2010
medium complexity background subtraction using approximate median
In this method the previous N frames of video are buffered, and the background is calculated as the median of buffered frames. The problem is the background is cleared of all objects after few frames to show a cleared background.
Median filtering has been shown to be very robust and to have performance comparable to higher complexity methods. However, storing and processing many frames of video (as is often required to track slower moving objects) requires an often prohibitively large amount of memory. This can be alleviated somewhat by storing and processing frames at a rate lower than the frame rate— thereby lowering storage and computation requirements at the expense of a slower adapting background.
The approximate median method works as such: if a pixel in the current frame has a value larger than the corresponding background pixel, the background pixel is incremented by 1. Likewise, if the current pixel is less than the background pixel, the background is decremented by one. In this way, the background eventually converges to an estimate where half the input pixels are greater than the background, and half are less than the background—approximately the median (convergence time will vary based on frame rate and amount movement in the scene.)
for i = 2:length(source)
fr = source(i).cdata;
fr_bw = rgb2gray(fr); % convert frame to grayscale
fr_diff = abs(double(fr_bw) - double(bg_bw)); % avoid negative overflow
for j=1:width
for k=1:height
if ((fr_diff(k,j) > thresh))
fg(k,j) = fr_bw(k,j);
else
fg(k,j) = 0;
end
if (fr_bw(k,j) > bg_bw(k,j))
bg_bw(k,j) = bg_bw(k,j) + 1;
elseif (fr_bw(k,j) <>
bg_bw(k,j) = bg_bw(k,j) - 1;
end
end
end
figure(1),subplot(3,1,1),imshow(fr)
subplot(3,1,2),imshow(uint8(bg_bw))
subplot(3,1,3),imshow(uint8(fg))
end
Subscribe to:
Post Comments (Atom)
these example are not usable ... elseif (fr_bw(k,j) <>
ReplyDeletethese are not examples, just portions of the code ive used...
ReplyDeletecan have an example of coding ?
ReplyDeletedo you have code of kalman ???? or any moving object tracking code??? can u plz give some examples for object tracking using background separation.
ReplyDeleteHai, Thank you, for uploading this Code.
ReplyDeleteBut, i have error while iam run this code,
the error is...
elseif (fr_bw(k,j) <>
Pl kindly give the correct changes in this statement.
Hi. Please. Can you help me send the full code of this method?
ReplyDeletemy email: locq91@gmail.com
Hi. Please. Can you help me send the full code of this method?
ReplyDeletemy email: ytzhakh@gmail.com
Can you help me send the full code of this method?
ReplyDeletemy email: dipt912@gmail.com
Can you help me send the full code of this method?
ReplyDeletemy email: bieshsp1992@gmail.com@gmail.com
Can you help me send the full code of this method?
ReplyDeletemy email: oritrabel@gmail.com
Can you help me send the full code of this method?
ReplyDeletemy email: harishcoole@gmail.com
Can you help me send the full code of this method?
ReplyDeletemy email: shikhamangal.muskan56@gmail.com