You are on page 1of 19

A report on

MOVING OBJECT DETECTION


USING MATLAB
By

M. Anila 07241A0560

N. Sindhu 07241A05A2

D. Srivalli 07241A05A8

GOKARAJU RANGARAJU

INSTITUTE OF

ENGINEERING AND TECHNOLOGY

BACHUPALLY

(2010)
CERTIFICATE

This is to certify that the project report entitled MOVING OBJECT


DETECTION USING MATLAB that is done by M.Anila, N.Sindhu,
D.Srivalli, in partial fulfillment of the requirement for the award of the degree
Bachelor of Technology in Computer Science and Engineering from
Jawaharlal Nehru Technological University, Kukatpally, Hyderabad.

Internal Guide:
K. Praveen Kumar Verma.

Head of the Department:


K.Anuradha.

GOKARAJU RANGARAJU INSTITUTE OF ENGINEERING AND

TECHNOLOGY

BACHUPALLY, HYDERABAD.
ACKNOWLEDGEMENT

Sincere thanks to our guide K. Praveen Kumar Verma who have helped us all
the way from the concept of the project to the code of the same.

Our sincere thanks to J.N.Murthy (Principal,GRIET) and K.Anuradha(HOD


Computer Science Department, GRIET) to provide us with an opportunity to
prove our talents and improve our confidence by giving presentations through mini
project.

I thank one and all of the team for the cheerful encouragement and unstinted
support rendered to me by their professional knowledge for the successful
completion of Project.

I will be failing in duty if I do not acknowledge with grateful thanks to the authors
of the references and other literatures referred to in this Project.
ABSTRACT

Moving object detection is a fundamental task required for many image and video
processing applications like video surveillance, medical imaging, satellite imaging,
biometrics identification, automated inspection in industry products etc. Basically
this involves segmentation of moving object in the scene.

Segmentation subdivides an image into its constituent regions or objects. The level
to which the segmentation is carried depends on the problem being solved.
Segmentation uses different techniques like morphing, point, line and edge
detection.Problems with illumination like shadows on the background,difference
in the intensities of the objects in the image may arise in segmentation.

In this project, we will use MATLAB environment to implement this algorithm.


MATLAB stands for Matrix Laboratory. It is complemented by a family of
application specific solutions called toolboxes. The image processing tool box is a
collection of MATLAB functions that extend the capability of MATLAB
environment for rapid prototyping, implementation and testing of the image
processing algorithms.

We aim to implement a robust moving object detection algorithm that can detect
object in variety of challenging real world scenarios.We organize the video into
frames in which the background is stationary.We use image processing tool box for
obtaining the object by subtracting the frames.The moment of the object is
described using edge detection techniques. We will collect experiment datasets for
these scenarios for testing our algorithm performance.
CONTENTS

CHAPTER 1:

INTRODUCTION

1.1 Image processing

1.2 Background on MATLAB

1.3 Objective of the project

CHAPTER 2:

SYSTEM ANALYSIS AND DESIGN

2.1 System Requirements

2.2 Hardware and Software Requirements

CHAPTER 3:

SYSTEM DESIGN

3.1. Inputs gathered

3.2. Operations performed.

3.2. Problems encountered

3.4. Desired output

CHAPTER 4:

CODE AND SAMPLE OUTPUT

4.1 Code of the program

4.2 Sample Output

4.3 Screenshots
CHAPTER 5:

5.1: Applications

CHAPTER 6:

6.1: Further developments

CHAPTER 7:

CONCLUSION AND REFERENCES

7.1: Conclusion

7.2: References
1:INTRODUCTION

1.1 IMAGE PROCESSING

Digital Image Processing refers to processing of digital images by means of a


digital computer. Digital image can be defined as two dimensional function f(x,y)
and the amplitude of f at any point gives the gray level or intensity of the image.

Image Processing is done in three levels:

 Low level processing involves primitive operations like noise reduction ,


image sharpening etc.

 Mid level processing involves partitioning an image into regions or objects.

 Higher level processing involves “making sense” of an ensemble of


recognized objects.

Moving object detection comes under mid- level processing.

1.2 BACKGROUND ON MATLAB

MATLAB is a high performance language for technical computation whose basic


data element is an array that does not require dimensioning. MATLAB stands for
matrix laboratory which is a standard computational tool for advanced courses in
mathematics, engineering and sciences. MATLAB is a choice for research and
analysis as it is complemented by a family of application specific solutions called
tool boxes. Image processing tool box helps in digital image processing.

1.3 OBJECTIVE

We aim to implement a robust moving object detection algorithm that can detect
objects in variety of challenging real world scenarios.
2: SYSTEM ANALYSIS AND DESIGN

System analysis is a process of gathering and interpreting facts, diagnosing


problems and the information to recommend improvements on the system. It is a
problem solving activity that requires intensive communication between the system
users and system developers. System analysis or study is an important phase of any
system development process. The system is studied to the minutest detail and
analyzed. The system analyst plays the role of the interrogator and dwells deep into
the working of the present system. The system is viewed as a whole and the input
to the system are identified. The outputs from the organizations are traced to the
various processes. System analysis is concerned with becoming aware of the
problem, identifying the relevant and decisional variables, analyzing and
synthesizing the various factors and determining an optimal or at least a
satisfactory solution or program of action.

2.1: SYSTEM REQUIREMENTS:

 Windows XP, Intel Pentium Processor [p4]

2.2: SOFTWARE AND HARDWARE REQUIREMENTS:

 MATLAB

 256MB RAM
3:SYSTEM DESIGN

3.1. INPUTS GATHERED:

A sample video with a stationery background and a single object moving


is considered. This video is converted into frames using a software. Video
to image converter is the software used. This converts the input video file
into images of jpg format. These images are provided in sequence as
input to the program.

3.2. OPERATIONS PERFORMED

 imread():This operation reads an image given as input and stores it in


the form of a matrix. The pixels of the image can be read by using
array editor.

 rgb2gray ():This function converts color image into a gray scale


image. This operation is done because matlab functions are
performed only on gray images.

 imsubtract(): This function is used to subtract one image from the


other. Both the images should be of same type. Here we use it to
isolate the object from the image.

 im2bw(): It is used to convert an image into binary format. It helps in


removing the noise around the object. The threshold value of the
object can be manipulated to clear the noise to a little large extent.

 Strel(): It is a user defined object or of a defined shape such as


diamond, rectangle, etc. It is used in dilating and eroding an object.
 imdilate(): Dilation helps in thickening the object, it combines the
disconnected components of the image.

 imerode(): Erosion helps in thinning the object, it helps in removing


the noise on the edges of the object.

 imclose(): It is used to close the open parts of an object to form a


single component.

 imfill(): It is used to fill the small holes in the object which have a
closed outline.

 bwlabel(): It labels the different components present in the image.


This helps us to know the number of objects present.

 graythresh(img): Returns the threshold of the input image.

 bwareaopen(): Helps in removing the small amount of noise in the


background according to the given pixel intensity.

 plot(): This function is used plot lines on the frame. We use it here to
draw a bounding box around the object.

 getframe(): This function is used to store the current frame generated.

 addframe(): This adds the specified frames into an avi object created.
This avi object is later presented as a video.
3.3. PROBLEMS ENCOUNTERED

 The similar color of the image and the background results in a


problem. While we isolate the object from the background, the part
of the object that is similar in color is lost in the result.

 The different color intensities of the image may give noise at further
stages.

 Illumination on different parts of the image results in extra edges


during edge detection.

 MATLAB doesn’t support the operations like union, intersection


of images if they are of different type or format.

 When animated videos of high resolution are considered, we faced


problem in isolating the object from the background.

3.4. DESIRED OUTPUT: The desired output of the task is to show the
movement of the object alone.

The frames obtained in the yester stages are unified into a single object. The
output is shown as a video. Abounding box is plotted around the object to
show the area in which object is present.
4: CODING AND SAMPLE OUTPUT

4.1 CODE

aviobj=avifile('sp','COMPRESSION','NONE','fps',3);

for i=2:50

string1=strcat('E:\MATLAB\work\cind\',int2str(1),'.jpg');

im1=rgb2gray(imread(string1));

s %figure,imshow(im1);

string2=strcat('E:\MATLAB\work\cind\',int2str(i),'.jpg');

im2=rgb2gray(imread(string2));

%figure,imshow(im2);

im=imsubtract(im1,im2);

%figure,imshow(im);

f=im2uint16(im);

t=graythresh(f);

b=im2bw(f,t);

%figure,imshow(b)

se3 = strel('disk', 5);

m = imclose(b,se3);

%figure,imshow(m);

n=imfill(m,'holes');

se5 = strel('diamond', 9);

n=imdilate(n,se5);
n=imfill(n,'holes');

%figure,imshow(n);

se4=strel('disk',6);

%n=imopen(n,se4);

%figure, imshow(n);

n=imerode(n,se4);

n=bwareaopen(n,50);

[L,num]=bwlabel(n,8);

k=1;

figure,imshow(n);

hold on

if k==1

[r,c]=find(L==k)

ymin=min(r)

xmin=min(c)

ymax=max(r);

xmax=max(c);

end

x=xmin:xmax;

y=ymin;

plot(x,y,'-r','LineWidth',5);
x=xmin:xmax;

y=ymax;

plot(x,y,'-r','LineWidth',5);

x=xmin;

y=ymin:ymax;

plot(x,y,'-r','LineWidth',5);

x=xmax;

y=ymin:ymax;

plot(x,y,'-r','LineWidth',5);

hold off

hfig = imgcf;

F(i) = getframe(hfig);

aviobj=addframe(aviobj,F(i));

end

aviobj=close(aviobj);
4.2: SAMPLE OUTPUT

4.3: SCREEN SHOTS


The image is in its initial form.

This is the image obtained after subtracting it from the background.


The image is converted into binary format.

The frame shown is after dilation.


This frame shows the object as a single component.

5: APPLICATIONS

Moving object detection is a fundamental task required for many image and video
processing applications like:

 video surveillance

 medical imaging

 satellite imaging

 biometrics identification

 automated inspection in industry products etc.


6:FURTHER DEVELOPMENTS

 This basic idea of detecting a single object is extended to multiple object


detection.

 A moving object can also be detected when the background is not stationery.

7: CONCLUSION AND REFERENCES

7.1. CONCLUSION

This project is a basic step in detection of a moving object, these kind of


ideas are useful in many fields for developing useful detecting systems.
7.2. REFERENCES

 www.google.co.in/.com

 www.mathworks.com

 Image processing using MATLAB: Rafeal C.Gonzalez, Richard E.Woods

You might also like