Seminar report on edge detection of video using matlab code
1. Edge Detection of Moving Object
CHAPTER NO. 1
INTRODUCTION
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
1
2. Edge Detection of Moving Object
2
Chapter 1
INTRODUCTION
1.1 Digital 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.
Edge detection of moving object comes under mid- level processing.
1.2 Edge Detection
Definition of edges - Edges is significant local changes of intensity in an image or video.
Edge Detection is a general name for a class of routines and techniques that operate on an
image and results in a line drawing of the image. The lines represented changes in values such
as cross sections of planes, intersections of planes, textures, lines, and colors, as well as
differences in shading and textures. Some techniques are mathematically oriented, some are
heuristic, and some are descriptive. All generally operate on the differences between the gray
levels of pixels or groups of pixels through masks or thresholds. The final result is a line
drawing or similar representation that requires much less memory to be stored, is much simpler
to be processed, and saves in computation and storage costs. Edge detection is also necessary
in subsequent process, such as segmentation and object recognition. Without edge detection, it
may be impossible to find overlapping parts, to calculate features such as a diameter and an
area or to determine parts by region growing. Edge detection is a very important area in the
field of Computer Vision.
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
3. Edge Detection of Moving Object
3
In the ideal case, the result of applying an edge detector to an image or video may lead to a
set of connected curves that indicate the boundaries of objects, the boundaries of surface
markings as well as curves that correspond to discontinuities in surface orientation. Thus,
applying an edge detection algorithm to an image may significantly reduce the amount of data
to be processed and may therefore filter out information that may be regarded as less relevant,
while preserving the important structural properties of an image.
Edges can be categorized based upon their intensity profiles like step edge, Ramp Edge,
Ridge Edge, roof edge. Edge detection can be done in four steps smoothing, Enhancement,
Detection and localization. There are many edge detection algorithms Prewitt, Robert, Sobel
and canny but the proposed work is done on Sobel Edge detector. Field Programmable Gate
Array hardware are becoming more and more important for image processing applications
because it can be used to implement almost any digital logic function
1.3 Objective of Seminar.
By using different types of Edge detector method find the edge of the moving object.
.
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
4. Edge Detection of Moving Object
4
CHAPTER NO. 2
EDGE DETECTION
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
5. Edge Detection of Moving Object
5
Chapter 2
EDGE DETECTION
2.1 Properties of Edges
The edges extracted from a two-dimensional image of a three-dimensional scene can be
classified as either viewpoint dependent or viewpoint independent. A viewpoint independent
edge typically reflects inherent properties of the three-dimensional objects, such as surface
markings and surface shape. A viewpoint dependent edge may change as the viewpoint
changes, and typically reflects the geometry of the scene, such as objects occluding one
another. A typical edge might for instance be the border between a block of red color and a
block of yellow. In contrast a line (as can be extracted by a ridge detector) can be a small
number of pixels of a different color on an otherwise unchanging background. For a line, there
may therefore usually be one edge on each side of the line.
2.2 Types of Edges
a. Step edge: the image intensity abruptly changes from one value to one side of the
discontinuity to a different value on the opposite side.
b. Ramp edge: a step edge where the intensity change is not instantaneous but occur
over a finite distance.
c. Ridge edge: the image intensity abruptly changes value but then returns to the
starting value within some short distance (generated usually by lines).
d. Line edge: One dimensional profile of edge is known as line.
Fig.2.2:- Typica Edge profile
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
6. Edge Detection of Moving Object
6
2.3 Edge Descriptors
a. Edge normal: unit vector in the direction of maximum intensity change.
b. Edge direction: unit vector to perpendicular to the edge normal.
c. Edge position or center: the image position at which the edge is located.
d. Edge strength: related to the local image contrast along the normal.
Fig2.3:-Edge Descriptors
2.4 Steps in Edge detection
The four steps of edge detection
a) Smoothing: suppress as much noise as possible, without destroying the true
edges.
b) Enhancement: apply a filter to enhance the quality of the edges in the image
(sharpening).
c) Detection: determine which edge pixels should be discarded as noise and
which should be retained (usually, thresholding provides the criterion used for
detection).
d) Localization: determine the exact location of an edge Edge thinning and linking are
usually required in this step.
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
7. Edge Detection of Moving Object
7
2.5Importance of Edge Detection
Edge detection is a problem of fundamental importance in image analysis. The purpose of
edge detection is to identify areas of an image where a large change in intensity occurs. These
changes are often associated with some physical boundary in the scene From which the image
Real-time video and image processing is used in a wide variety of applications from video
surveillance and traffic management to medical imaging applications. Important features can
be extracted from the edges of an image (e.g., corners, lines, curves).
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
8. Edge Detection of Moving Object
CHAPTER NO. 3
METHODS OF EDGE
DETECTION
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
8
9. Edge Detection of Moving Object
9
Chapter 3
METHODS OF EDGE DETECTION
3.1 First Order Derivative Method /Gradient Method
The gradient method detects the edges by looking for the maximum and minimum in the
first derivative of the image. The gradient is a vector which has certain magnitude and
direction
The Gradient vector is denoted by letter ‘G’ and magnitude & direction is as follow
Magnitude-
Direction-
∂f
Gx ∂ x
G[ f (x, y)] = =
Gy ∂ f
∂ y
G = Gx 2 +Gy 2 ≈ Gx + Gy
Gy
Gx
θ = tan −1
(3.1)
(3.2)
(3.3)
Computation of the gradient of an image is based on obtaining the partial derivatives of ∂f/∂x
and ∂f/∂y at every pixel location.
3.1.1 Robert Edge Detection
Roberts’s operator is a kind of the simplest operator which makes use of partial difference
operator to look for edge. Its effect is the best for the image with steep low noise. But the
borderline of the extracted image is quite thick using the Roberts operator, so the edge location
is not very accurate. Robert operator highlights the region of high special function which often
corresponds to edges.
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
10. Edge Detection of Moving Object
10
The mask for Robert operator is obtain using following equation
(3.4)
(3.5)
Here Gx and Gy is Gradient component of x and y component respectively. The ideal 3x3
convolution mask is as follow
Fig3.1:- Ideal 3x3 convolution mask
Fig3.2:- Masks used by Robert operator
In Robert operator the position of the edges is more accurate, but the problem with the short
support of the filters is its vulnerability to noise. It also produces very weak response to
genuine edges unless they are very sharp.
Fig3.3:- original image of jocker
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
Fig3.4:- Robert Edge Detector of image of jocker
11. Edge Detection of Moving Object
11
3.1.2 Sobel Edge detector
Technically, it is a discrete differentiation operator, computing an approximation of
the gradient of the image intensity function. At each point in the image, the result of the Sobel
operator is either the corresponding gradient vector or the norm of this vector. The Sobel
operator is based on convolving the image with a small, separable, and integer valued
filter in horizontal and vertical direction and is therefore relatively inexpensive in terms of
computations. On the other hand, the gradient approximation that it produces is relatively
crude, in particular for high frequency variations in the image.
The 3X3 convolution mask smoothes the image by some amount , hence it is less
susceptible to noise. But it produces thicker edges. Sobel operator can process those images
with lots of noises and gray gradient well. The Sobel operator is the most known among the
classical methods. The Sobel edge detector applies 2D spatial gradient convolution operation
on an image. It uses the convolution masks shown in to compute the gradient in two directions
(i.e. row and column orientations), and then works out the pixels gradient The Sobel edge
detector is very much similar to the Prewitt edge detector. The difference between both is that
the weight of the centre coefficient is 2 in the Sobel operator.
Convolution Mask
Masks of size 3×3matrics is obtain by following eqn
Gx = (Z3 + 2Z6 +Z9)-(Z1+2 Z4+ Z7)
Gy= (Z1+2 Z2+ Z3)-(Z7+ 2Z8+ Z9)
Fig3.5:- Masks used by Sobel Operator
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
(3.6)
(3.7)
12. Edge Detection of Moving Object
12
Example for Sobel operator:
Fig3.6:- color picture of a steam engine
Fig3.7:- The Sobel operator applied to that image
Comparison of the output of the Sobel Operator with that of the Roberts operator
Fig3.8:Sobel operator applied to image
Fig3.9:Roberts operator applied to image
The spurious edges are still present but they are relatively less intense compared to genuine
lines.
a. Roberts’s operator has missed a few edges.
b. Sobel operator detects thicker edges.
c. Will become clearer with the final demo.
3.1.3Prewitt Edge Detector
Prewitt operator is similar to the Sobel operator and is used for detecting vertical and
horizontal edges in images. In Perwitt operator not only edges is detected but also edge due to
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
13. Edge Detection of Moving Object
13
noise get obtained. At each point in the image, the result of the Prewitt operator is either the
corresponding gradient vector or the norm of this vector. The Prewitt operator is based on
convolving the image with a small, separable, and integer valued filter in horizontal and
vertical direction and is therefore relatively inexpensive in terms of computations. On the other
hand, the gradient approximation which it produces is relatively crude, in particular for high
frequency variations in the image. Using the Prewitt operator can not only detect edge points,
but also restrain the noise. They differentiate in one direction and average in the other
direction, so the edge detector is less vulnerable to noise. The Prewitt operator was developed
by Judith M. S. Prewitt.
Formulation:
Mathematically, the operator uses two 3×3 kernels which are convolved with the original
image to calculate approximations of the derivatives - one for horizontal changes, and one for
vertical. If we define
as the source image, and
and
are two images which at
each point contain the horizontal and vertical derivative approximations, the latter are
Computed as
Gx = (Z3+Z6+Z9)-(Z1+Z4+Z7)
(3.8)
Gx = (Z1+Z2+Z3)-(Z7+Z8+Z9)
(3.9)
Fig3.10:- Masks used by Prewitt operator
Example for Prewitt operator:-
Fig3.11:- Original Image without Prewitt operator
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
Fig3.12:- The Prewitt operator applied to that image
14. Edge Detection of Moving Object
14
3.1.4 First Order Derivative Method – Summary
a. Noise – simple edge detectors are affected by noise – filters can be used to reduce noise
b. Edge Thickness – Edge is several pixels wide for Sobel operator– edge is not localized
properly
c. Roberts operator is very sensitive to noise
d. Sobel operator goes for averaging and emphasizes on the pixel closer to the center of the
mask. It is less affected by noise and is one of the most popular Edge Detectors.
3.2 Second Order Derivative Method / Zero Crossing Edge Detector
Zero crossing of the second derivative of a function indicates the presence of a maxima .If
there is a significant spatial change in the second derivative, an edge is detected. Types is as
follow
3.2.1 Laplacian Edge Detector
The Laplace operator is named after the French mathematician Pierre-Simon de Laplace.
It also called Harmonic Function. The Laplacian of a 2-D function L (x, y) is a second-order
derivative defined as
(3.10)
Masks of size 3×3matrics is obtain by following equation
L (x, y) =4z5-( z2+ z4+ z6+ z8)
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
(3.11)
15. Edge Detection of Moving Object
15
Fig3.13:- Masks used by Prewitt operator
Properties
a) Laplacian is an isotropic operation means it having same magnitude in al direction
b) It is cheaper in implementation because only one mask is present.
c) It is more sensitive to noise
d) There is use of filter Laplace of Gaussian
3.2.2 Laplacian of Gaussian (LoG)
It also called Marr-Hildreth Edge Detector. principle used in the Laplacian of Gaussian
method is, the second derivative of a signal is zero when the magnitude of the derivative is
maximum. The Laplacian is a 2-D isotropic measure of the 2ndspatial derivative of an image.
The Laplacian of an image highlights regions of rapid intensity change and is therefore often
used for edge detection. The Laplacian is often applied to an image that has first been
smoothed with something approximating a Gaussian Smoothing filter in order to reduce its
sensitivity to noise. The operator normally takes a single gray level image as input and
produces another gray level image as output.
a. Defined as
(3.12)
b. Greater the value of s, broader is the Gaussian filter, more is the smoothing
c. Too much smoothing may make the detection of edges difficult
d. Also called the Mexican Hat operator
As per following steps edge is detected in Laplacian of Gaussian
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
16. Edge Detection of Moving Object
16
Steps
a) Smooth the image using Gaussian filter.
b) Enhance the edges using Laplacian operator.
c) Zero crossings denote the edge location.
d) Use linear interpolation to determine the sub-pixel location of the edge.
3.2.3 Difference of Gaussian (DoG)
In image science, difference of Gaussian is a feature enhancement algorithm that involves
the subtraction of one blurred version of an original image from another less blurred version of
the original.
−(
x 2+ y 2
)
−(
x 2+ y 2
2
2
DoG is defined as
e 2πσ1
e 2πσ 2
DoG ( x, y ) =
−
2
2
2πσ 1
2πσ 2
)
(3.13)
Difference of Gaussian Laplacian of Gaussian but difference is that in LoG there is large
computation time for a large edge detector mask as compare to DoG
Advantage of DoG
a. Close approximation of LoG
b. Less computation effort
c. Width of edge can be adjusted by changing 1 and 2
Example for DoG operator:-
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
17. Edge Detection of Moving Object
Fig3.14:- Original Image
17
Fig3.15:- The DoG operator applied to image
3.2.4 Second Order Derivative Method- Summary
a. Second Order Derivative methods especially Laplacian, are very sensitive to noise
b. Probability of false and missing edges remain
c. Localization is better than Gradient Operators
3.3 Optimal Edge Detection
Optimal edge detector depending on
a. Low error rate – edges should not be missed and there must not be spurious responses
b. Localization – distance between points marked by the detector and the actual center of the
edge should be minimum
c. Response – Only one response to a single
Optimal edge Detector contain Canny Edge Detector described as bellow
3.3.1 Canny Edge Detector
The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to
detect a wide range of edges in images. It was developed by John F. Canny in 1986. Canny's
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
18. Edge Detection of Moving Object
18
aim was to discover the optimal edge detection algorithm. In this situation, an "optimal" edge
detector means:
Good detection – the algorithm should mark as many real edges in the image as possible.
Good localization – edges marked should be as close as possible to the edge in the real image.
Minimal response – a given edge in the image should only be marked once, and where
possible, image noise should not create false edges.
The steps in the Canny edge detector are as follows:
a. The first step is to filter out any noise in the original image before trying to locate and
detect any edges. And because the Gaussian filter can be computed using a simple mask,
it is used exclusively in the Canny algorithm. Once a suitable mask has been calculated,
the Gaussian smoothing can be performed using standard convolution methods.
b. After smoothing the image and eliminating the noise, the next step is to find the edge
strength by taking the gradient of the image.
c. The direction of the edge is computed using the gradient in the x and y directions.
d. Once the edge direction is known, the next step is to relate the edge direction to a direction
that can be traced in an image.
e. After the edge directions are known, non-maximum suppression now has to be applied.
Non-maximum suppression is used to trace along the edge in the edge direction and
suppress any pixel value that is not considered to be an edge. This will give a thin line in
the output image.
f. Finally, hysteresis is used as a means of eliminating streaking. Streaking is the breaking
up of an edge contour caused by the operator output fluctuating above and below the
threshold.
Example for Canny Edge detector:-
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
19. Edge Detection of Moving Object
19
Fig3.16: Image using Canny edge detector
CHAPTER NO. 4
CODING and RESULT
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
20. Edge Detection of Moving Object
20
Chapter 4
CODING and RESULT
4.1 Code
Edge detection of video by using Matlab code
1. hVideoSrc = signalblks.MultimediaFileReader('vipmen.avi', ...
'ImageColorSpace', 'Intensity', ...
'VideoOutputDataType', 'Inherit');
2. hEdge = video.EdgeDetector( ...
'Method', 'Prewitt', ...
'ThresholdSource', 'Property', ...
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
22. Edge Detection of Moving Object
(a)
Fig4.1:-(a)original image
22
(b)
Fig4.2:-(b)edge image(Prewitt)
(c)
Fig4.3:-(c)overlay image
,
CHAPTER NO. 5
APPLICATION
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
23. Edge Detection of Moving Object
23
Chapter 5
APPLICATION
APPLICATION
Moving object Edge detection is a fundamental task required for many image and video
processing applications like:
a. Video surveillance
b. Medical imaging
c. Satellite imaging
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
24. Edge Detection of Moving Object
d. Biometric identification
e.
Automated inspection in industry products etc.
CHAPTER NO. 6
CONCLUSION AND
REFERENCES
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
24
25. Edge Detection of Moving Object
25
Chapter 6:
CONCLUSION AND REFERENCES
6.1 Conclusion
The Robert edge detector is detecting the edge by using first order derivative. Sobel
operator and prewitt operator is somewhat similar. Detecting the edge in thicker and in prewitt
presence of noise false edges get detected. Basically first order derivative is more affected by
noise as compare other operator. The Laplacian detecting the edge by using zero crossing
technique. The LoG is able to reduce noise due to presence of Gaussian filter DoG is similar to
LoG only difference is that calculation part get reduces in DoG Basically first order derivative
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
26. Edge Detection of Moving Object
26
is immune to noise but localization is not good. As compare to all operator Canny edge
detector is better in noise suppression and edge detection
Using edge technique developed a model using Matlab for Edge Detection on Video
Processing using Prewitt Edge detector. And it is observed that the edge is detected greatly
where large change in intensity variation is found.
6.2 References
a. www.google.co.in/.com
b. www.mathworks.com
c. Image processing using MATLAB: Rafeal C.Gonzalez, Richard E.Woods
d. J. Canny, “A computational approach to edge detection,” IEEE Trans. Pattern
Analysis and Machine Intelligence, Vol. 8, No. 6, pp. 679-698, Nov. 1986.
e. R. C. Gonzalez and R. E. Woods, Digital Image Processing. Upper Saddle
River, NJ: Prentice-Hall, 2001, pp. 572-585.
f. Harris and M. Stephens, “A Combined Corner and Edge Detector,” Proceedings
of The Fourth Alvey Vision Conference, Manchester, pp. 147-151, 1988
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
27. Edge Detection of Moving Object
Dept. of E&TC, PLITMS, Buldana. (By Bhushan M. Deore)
27