Edge Detection & Thresholding
Global thresholding using otsu method
Agenda
What is edge detection
Why is edge detection important in image processing
Edge detection operators
• what are the edges? Why we detect edges?
• Prewitt, Sobel operators
• Laplacian, Canny operator
• Edge detection operator comparison
Thresholding
• Types of thresholding
• Thresholding using otsu method
What is Edge Detection?
• Edges are defined as “sudden
and significant changes in
intensity” of an image.
• These changes happen between
the boundaries of object in an
image.
• We take a input image, and once
edges are detected, one can find
out exact layout or boundary of
the object.
• The edges are detected based on
significant change in intensity
between objects in the image.
Why to detect edges?
• One can understand the shape of objects in the image only
when the edges are detected.
• There are many issues and challenges mapped to the
segmentation, object identification techniques. Edges prove
to be more efficient than above techniques at the
fundamental levels.
Steps in Edge Detection
• Image Smoothening
• Edge Points detection
• Edge Localization
Image Smoothening & Edge Point Detection
It is all about removal of noise from the image. In addition to that
removal of of the noise should be done in such a way that, the
quality of image is not altered.
Smoothening is all about making the image noise free.
Edges are detected through identifying the sudden changes in
intensity. Even noise is all about sudden change in intensity. Edge
point detection is a process where noise alone removed retaining
the edges.
Edge Localization
• The final step in the sequence is edge Localization.
The processes like thinning and linking are to be
carried out to locate the edges. This process is called
edge localization.
Sobel Edge Operator
• The image is processed in the X and Y directions one
after another.
• This will result in the formation of new image which
would be the sum of X and sum of Y edges in the
image.
• This approach is calculated by the gradient of the image
intensity at every pixel within the image.
Contd
• Sobel filter has 2 kernels.
• These two kernels shall be
convoluted with the original image
under process and through which
the edge points are calculated with
ease.
• The gaussian filter play a vital role in
the entire process.
• The fundamental idea behind
Gaussian filter is the center having
more weight than the another.
• The general approach is with the
first and second order derivatives.
Contd
• The next is to convolute the G(x) and
G(y) over the input image which shall
enable us to calculate the value for
one pixel at a time.
• Then the shift happens and the move
has to be made towards right the next
column shift till the column end.
• Similar process is followed for the row
shifting from top – bottom.
contd
• The value we get by convoluted using G(x) is ‘a’ and the
value we get by convoluted by using G(y) is ‘b’.
• Then the Gradient approximation is expressed as
G=
when convolute with x-derivate we get 105 and we
convolute with y-derivative we get 315 so from them we
calculated G as 332.
Prewitt Edge Operator
• The prewitt edge operator is almost
similar to the sobel operator but with
a minor change. The prewitt operator
shall give the values which are
symmetric around the center. But
sobel operator gives weight to the
point which is lying around the (x,y).
• Prewitt x and y operator values are
presented as
Prewitt operator to detect vertical edges
Prewitt operator to detect horizontal edges
Types of edges
There are four types of edges/ discontinuity.
Step edge
Line edge
Ramp edge
Roof edge.
Step edge
• In this type the image intensity
is unexpectedly and sharply
changes from one value to
another. It looks like
step/pulse and hence
regarded as step edges.
Line edge
• This is almost similar as Step edge
but there is a small change. The
intensity is changes from smaller
to larger value but it will again
return the smaller value in a
shorter span of distance.
Ramp edge
• Step edges shall be framed as Ramp
edges while the intensity changes are
not occurred in a immediate time it
takes over a finite distance gradually
over a longer period of time.
Roof edges
• Line edges shall be framed as
the roof edges while the
intensity changes are not
immediate it takes longer
duration and it reduces
gradually
Comparison
of Edges
Canny edge Detector
• Canny is not like traditional detectors, it is just not
masking on the input image matrix.
• It has several steps
Conversion to the Grayscale
Gaussian Blur
Intensity Gradient Calculation( In here we use Sobel
operator)
The edge direction is calculated theta=
Non-Maximum suppression (we have to gone to
suppress which is not maximum)
Satellite Image
Robotic Vision
Applications
Fingerprint Scanners
Medical science
Thresholding
• Thresholding plays an very important role in
segmentation, This makes a difference between the
object and background of the image.
• Thresholding may be defined as:
Single level Thresholding.
Multilevel Thresholding.
Single level Thresholding suppose that an image f(x,y)
has light object an a dark background. If we draw the
histogram of the type of image, it will have the dominant
models of gray scale.
Single level
• In a histogram the lines are closer to
each other and looks like dark. When
these lines are move far after the
thresholding T it becomes the light .
• If F(x,y)>T it is called object.
F(x,y)<T it is called Background.
Multi level
• In multi level thresholding we used
more than one threshold separation
of image information.
Types of Thresholding
• Global thresholding: If thresholding depends upon only
the gray levels of the image.
• Local Thresholding: If thresholding depends upon the
gray levels of the image and some local properties also.
• Adaptive Thresholding: This thresholding uses when we
thresholding a particular pixel. This depends upon gray
levels of image and local properties and the position of
the pixel. It is also known as dynamic Thresholding.
Optimal otsu Thresholding algorithm
• Optimal threshold is used where there is a considerable
overlapping of the histogram.
• It uses a merit function of either maximization and
minimization to determine the optimal threshold.
• Let us assume that there are two classes.
class 1 class2
Weight w1(t) w2(t)
Variance (t)
contd
• Weighted sum of variance is
=
Threshold with the max b/w class variance also has
min within class variance.
=
Steps in OTSU algorithm
Compute histogram Set up initial class Step through all
and probabilities of probability and initial possible thresholds
each intensity level. class means. maximum intensity.
Desired threshold
Compute between class corresponds to the
Update qi and μi.
variance. maximum value of
between class variance.