You are on page 1of 5

University Institute of Engineering

Department of Electronics & Communication Engineering

Experiment: 2.5

Student Name: Rekha Rani UID:19BEC1058


Branch: ECE Section/Group: ECE1 -B
Semester: 06 Date of Performance:04/04/22
Subject Name: Image Processing
Subject Code: ECB 365

1. Aim of the practical: To Observe Background Subtraction of a mp4 file.

2. Tool Used: Jupyter Notebook or Google colab.

3. Basic Concept/ Command Description:

OpenCV: OpenCV is a cross-platform library using which we can develop real-time computer vision
applications. It mainly focuses on image processing, video capture and analysis including features like
face detection and object detection. In this tutorial, we explain how you can use OpenCV in your
applications.

Background subtraction – OpenCV:


 The process of removing the background from a given image and displaying only the foreground
objects is called background subtraction in OpenCV and to perform the operation of background
subtraction.

 we make use of three algorithms namely:


 BackgroundSubtractorMOG
 BackgroundSubtractorMOG2
 BackgroundSubtractorGMG
University Institute of Engineering
Department of Electronics & Communication Engineering

Gaussian function:
In mathematics, a Gaussian function, often simply referred to as a Gaussian, is a function of the for
arbitrary real constants a, b and non-zero c. It is named after the mathematician Carl Friedrich Gauss.
The graph of a Gaussian is a characteristic symmetric "bell curve" shape. The parameter a is the height of the
curve's peak, b is the position of the centre of the peak, and c (the standard deviation, sometimes called the
Gaussian RMS width) controls the width of the "bell".
Gaussian functions are often used to represent the probability density function of a normally distributed random
variable with expected value μ = b and variance σ2 = c2. In this case, the Gaussian is of the form[1]
Gaussian functions are widely used in statistics to describe the normal distributions, in signal processing to
define Gaussian filters, in image processing where two-dimensional Gaussians are used for Gaussian blurs, and
in mathematics to solve heat equations and diffusion equations and to define the Weierstrass transform.

4. Sample Code:

import numpy as np
import cv2

cap = cv2.VideoCapture('Surfing - 368.mp4')

fgbg = cv2.createBackgroundSubtractorMOG2()

while(1):
ret, frame = cap.read()

fgmask = fgbg.apply(frame)

cv2.imshow('fgmask',frame)
University Institute of Engineering
Department of Electronics & Communication Engineering

cv2.imshow('frame',fgmask)

k = cv2.waitKey(30) & 0xff


if k == 27:
break
cap.release()
cv2.destroyAllWindows()

5. Observations, Simulation Screen Shots and Discussions:


University Institute of Engineering
Department of Electronics & Communication Engineering

6. Additional Creative Inputs (If Any):

Learning outcomes (What I have learnt):

1.Learnt about functions of Open CV

2.Understandiing background subtraction

3.Learnt about MOG.


University Institute of Engineering
Department of Electronics & Communication Engineering

Evaluation Grid (To be filled by Faculty):


Sr. No. Parameters Marks Obtained Maximum Marks
1. Worksheet completion including 10
writinglearning
objectives/Outcomes.(To besubmitted
at the end of the day)
2. Post Lab Quiz Result. 5
3. Student Engagement in 5
Simulation/Demonstration/Performance
and Controls/Pre-Lab Questions.
Signature of Faculty (with Date): Total Marks Obtained: 20

You might also like