moving object detection using background subtraction algorithm matlab code
moving object detection using background subtraction algorithm matlab code
Posts: 8,059
Threads: 1
Joined: Mar 2014
moving object detection using background subtraction algorithm matlab code
Abstract
Background subtraction methods are widely exploited for moving object detection in videos in many applications, such as traffic monitoring, human motion capture and video surveillance. How to correctly and efficiently model and update the background model and how to deal with shadows are two of the most distinguishing and challenging aspects of such approaches. This work proposes a general-purpose method which combines statistical assumptions with the object-level knowledge of moving objects, apparent objects (ghosts) and shadows acquired in the processing of the previous frames. Pixels belonging to moving objects, ghosts and shadows are processed differently in order to supply an object-based selective update. The proposed approach exploits gray color information for both background subtraction to improve object segmentation. The approach proves fast, flexible and precise in terms of pixel accuracy. The implementation of the background subtraction algorithm is done in two domains code is written in Matlab, then using Simulink blocks sets.
Idea : When you substract two subsequent frames clicked by your cam, the part of image which does not change (background) gets subtracted to give zero intensity (black). Only the part of image moved (moving object) dont get reduced to zero as intensity of pixels of two subsequent frames are different. So you get non zero intensity for pixels corresponding moved object. Rest is simple. Just convert the image into binary and obtain the centroid of largest area of connected pixels !! You get your result.
Algorithm:
I got the idea of this algorithm from a paper “Implementation of an Automated Single Camera Object Tracking System Using Frame Differencing and Dynamic Template Matching” by guys from IIT-Kanpur and NIT-Nagpur which can be obtained from here. Although I modified it to directly take and operate on rgb images. The algorithm is as follows :
Grab ith frame.
Grab subtract it from (i-3)th frame.
Convert the image into binary.
Fill small holes.
Label the connected pixels.
Run the loop to number of labels and find the label for maximum area.
Find centroid of the obtained area.
Mark the area if you just want to track or use the centroid information for other applications.
Go to step 1.
Here subtraction is done with (i-3)th frame keeping in mind slow moving objects. I implemented this algorithm completely in MATLAB. My code is right now a little prone to occlusion and is having less frames per second.