IPMV_MOD_4
IPMV_MOD_4
|R| >T
Point Detection:
Line Detection
R1 R2 R3 R4
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0
Edge Detection Approach
◼ Segmentation by finding pixels on a region
boundary.
◼ Gradient Operator
f
Gx x
f = = f
G y
y
f = G + G 2
x y
2 1/ 2
for 3 3 mask
Gx = (z 7 + z8 + z9 ) − (z1 + z2 + z3 )
G y = (z 3 + z6 + z9 ) − (z1 + z4 + z7 )
Detection of Discontinuities
Gradient Operators
Prewitt operators
Sobel operators
ujwal harode 23
Detection of Discontinuities
Gradient Operators
ujwal harode 24
Edge Detection
◼ Prewitt and Sobel Operators
Edge Detection
Detection of Discontinuities
Gradient Operators: Example
f G x + G y
ujwal harode 27
Detection of Discontinuities
Gradient Operators: Example
ujwal harode 28
Edge Detection
Edge Detection
Edge Detection
Detection of Discontinuities
Gradient Operators
x y
– Two forms in practice:
Laplacian Operator
Laplacian Operator is also a derivative operator which is used to
find edges in an image. The major difference between Laplacian and
other operators like Prewitt, Sobel, Robinson and Kirsch is that
these all are first order derivative masks but Laplacian is a second
order derivative mask. In this mask we have two further
classifications one is Positive Laplacian Operator and other is
Negative Laplacian Operator.
Another difference between Laplacian and other operators is that
unlike other operators Laplacian didn’t take out edges in any
particular direction but it take out edges in following classification.
Inward Edges
Outward Edges
Cont…..
Let’s see that how Laplacian operator works.
0 1 0
1 -4 1
0 1 0
0 -1 0
-1 4 -1
0 -1 0
➢This operation in result produces such images which have grayish edge
lines and other discontinuities on a dark background. This produces inward
and outward edges in an image
➢The important thing is how to apply these filters onto image. Remember
we can’t apply both the positive and negative Laplacian operator on the
same image.
➢we have to apply just one but the thing to remember is that if we apply
positive Laplacian operator on the image then we subtract the resultant
image from the original image to get the sharpened image.
4
• The Laplacian of a Gaussian sometimes is called the Mexican
hat function. It also can be computed by smoothing the image
with the Gaussian smoothing mask, followed by application of
the Laplacian mask.
Edge Detection
Edge Detection
◼ The Laplacian of Gaussian (LoG)
Edge Detection
◼ The Laplacian of Gaussian (LoG)
• second derivation is a linear operation
• thus, 2f is the same as convolving the image
with Gaussian smoothing function first and
then computing the Laplacian of the result
Ujwal Harode 42
compass masks
Robinson compass masks are another type of derrivate mask which
is used for edge detection. This operator is also known as direction
mask. In this operator we take one mask and rotate it in all the 8
compass major directions that are following:
North
North West
West
South West
South
South East
East
North East
There is no fixed mask. You can take any mask and you have to rotate it to find
edges in all the above mentioned directions. All the masks are rotated on the
bases of direction of zero columns.
For example let’s see the following mask which is in North Direction and then
rotate it to make all the direction masks.
Cont…..
-1 0 1
-2 0 2
-1 0 1
0 1 2
-1 0 1
-2 -1 0
1 2 1
0 0 0
-1 -2 -1
2 1 0
1 0 -1
0 -1 -2
Cont…..
1 0 -1
2 0 -2
1 0 -1
0 -1 -2
1 0 -1
2 1 0
-1 -2 -1
0 0 0
1 2 1
-2 -1 0
-1 0 1
0 1 2
Cont…..
As you can see that all the directions are covered on the basis of zeros
direction. Each mask will give you the edges on its direction. Now let’s
see the result of the entire above masks. Suppose we have a sample
picture from which we have to find all the edges. Here is our sample
picture:
Sample Picture
Now we will apply all the above filters on this image and
we get the following result.
Cont…..
North Direction Edges
As you can see that by applying all the above masks you will get edges in all
the direction. Result is also depends on the image. Suppose there is an
image, which do not have any North East direction edges so then that mask
will be ineffective.
Edge Linking and Boundary Detection
Local Processing
In this example,
we can find the
license plate
candidate after
edge linking
process.
ujwal harode 52
Hough Transform
Yi=aXi+b
Image and Parameter Spaces
y = mx + c y
Equation of Line: y = mx + c
Find: (m, c)
Consider point: ( xi , yi ) ( xi , yi )
x
yi = mxi + c or c = − xi m + yi Image Space
m
Parameter space also called Hough Space
(m, c)
c
Parameter Space
Line Detection by Hough Transform
y
Algorithm:
A(m, c) = A(m, c) + 1 1 1
1 1
• If ( m, c )lies on the line: 2
1 1
c = − xi m + yi 1 1
1 1
• Find local maxima in A(m, c)
Problem
Given 4 points in xy plane (1,1),(2,2),(3,3) and (4,4). Use Hough Transform to join
these points.
X Y
1 1 b= -1a+1
2 2 b= -2a+2
3 3 b= -3a+3
4 4 b= -4a+4
Better Parameterization
y
NOTE: − m
Large Accumulator ( xi , yi )
More memory and computations
Here 0 2
0 max
Given points ( xi , yi ) find ( , ) ?
Horizontal axis is θ,
vertical is rho.
Image votes
space
The Hough Transform
◼ Global processing: The Hough Transform
The Hough Transform
◼ Global processing: The Hough Transform
Mechanics of the Hough transform
Region-Based Edge-Based
ujwal harode 69
What is a Region?
• Basic definition :- A group of connected pixels with
similar properties.
ujwal harode 70
Partitioning – How?
• Partitioning into regions done often by using gray
values of the image pixels.
Region-based segmentation
Boundary estimation using edge detection
ujwal harode 71
Region-based Approach
• Pixels corresponding to an object grouped
together and marked.
• Important principles:-
1. Value similarity
Gray value differences
Gray value variance
ujwal harode 72
Region-based Approach (continued)
2. Spatial Proximity
Euclidean distance
Compactness of a region
ujwal harode 73
Limitation
• The assumption does not hold true in all cases.
ujwal harode 74
Region Segmentation
• Problem Statement:-
Ri = R
i =1
Ri = True
i =1
75
Region Segmentation – Problem Statement
(Continued)
• P(Ri) = True , for all i
i.e any region satisfies the homogeneity
predicate
• Any two adjacent regions cannot be merged
into a single region
( )
P Ri Rj = False
76
Region-Based Segmentation
Basic Formulation
ujwal harode 78
REGION BASED SEGMENTATION
➢REGION GROWING
➢REGION SPLITTING
➢REGION MERGING
➢SPLIT AND MERGE
ujwal harode 79
REGION GROWING
• Group pixels or sub-regions into
larger regions when homogeneity
criterion is satisfied
• Region grows around the seed
point based on similar properties
(grey level, texture, color)
PROS:
• Better in noisy image where edges are
hard to identify
CONS:
• Seed point must be specified
• Different seed point will give
different results
Homogeneity criteria:
• The difference between 2 pixel values is less than or equal to 5
• Horizontal, vertical, diagonal
Region-Based Segmentation
Region Growing
ujwal harode 81
Region-Based Segmentation
Region Growing
◼ Region Merging
❑ Region merging is the opposite of region splitting.
❑ Start with small regions (e.g. 2x2 or 4x4 regions) and merge the regions
that have similar characteristics (such as gray level, variance).
❑ Typically, splitting and merging approaches are used iteratively.
7
Region-Based Segmentation
Region Splitting
ujwal harode 84
Region-Based Segmentation
Region Splitting and Merging
ujwal harode 85
Split and Merge Approach:
• This is a 2 step procedure:
– top-down: split image into
homogeneous quadrant regions
– bottom-up: merge similar adjacent
regions
• The algorithm includes:
Top-down
– successively subdivide image into
quadrant regions R i
quadtree structure
Bottom-up
– at each level, merge adjacent regions
R and R if P(R [ R ) = TRUE
i j i j
ujwal harode 87
EXAMPLE
The Split-and-Merge Algorithm
1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0
3 1 4 9 9 8 1 0 3 1 4 9 9 8 1 0
1 1 8 8 8 4 1 0 1 1 8 8 8 4 1 0
1 1 6 6 6 3 1 0 1 1 6 6 6 3 1 0
1 1 5 6 6 3 1 0 1 1 5 6 6 3 1 0
1 1 5 6 6 2 1 0 1 1 5 6 6 2 1 0
1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0
•What is thresholding?
•Simple thresholding
•Adaptive thresholding
Thresholding – A Key Aspect
◼ Most algorithms involve establishing a
threshold level of certain parameter.
◼ Correct thresholding leads to better
segmentation.
◼ Using samples of image intensity available,
appropriate threshold should be set
automatically in a robust algorithm i.e. no
hard-wiring of gray values
Automatic Thresholding
◼ Use of one or more of the following:-
1. Intensity characteristics of objects
2. Sizes of objects
3. Fractions of image occupied by objects
4. Number of different types of objects
◼ Size and probability of occurrence – most
popular
◼ Intensity distributions estimate by histogram
computation.
Automatic Thresholding Methods
◼ Iterative Thresholding:-
Successively refines an
T = (1+2)
approx. threshold to get a 1
new value which partitions 2
the image better.
◼ 4
1
P-Tile Thresholding
• Thresholding is usually the first
step in any segmentation approach
• Single value thresholding can be
given mathematically as follows:
1 if f (x, y) T
g(x, y) =
0 if f (x, y) T
P-Tile Thresholding
• Basic global thresholding:
• Based on the histogram of an image
Partition the image histogram using
a single global threshold
P-Tile Thresholding
• Basic global thresholding:
• The success of this technique very
strongly depends on how well the
histogram can be partitioned
Iterative P-Tile Thresholding
• The Basic global thresholding:
1. Select an initial estimate for T (typically the
average grey level in the image)
2. Segment the image using T to produce two
groups of pixels: G1 consisting of pixels with
grey levels >T and G2 consisting pixels with
grey levels ≤ T
3. Compute the average grey levels of pixels
in G1 to give μ1 and G2 to give μ2
Iterative P-Tile Thresholding
• The Basic global thresholding:
4. Compute a new threshold value:
T=
1 + 2
2
5. Repeat steps 2 – 4 until the difference in T
in successive iterations is less than a
predefined limit T∞
This algorithm works very well for finding thresholds
when the histogram is suitable.
P-Tile Thresholding
P-Tile Thresholding
P-Tile Thresholding
• Limitation of P-Tile thresholding:
P-Tile Thresholding
• Limitation of P-Tile thresholding:
P-Tile Thresholding
• Limitation of P-Tile thresholding:
Adaptive Thresholding
◼ Adaptive Thresholding is used in scenes with
uneven illumination where same threshold
value not usable throughout complete image.
◼ In such case, look at small regions in the
image and obtain thresholds for individual
sub-images. Final segmentation is the union
of the regions of sub-images.
Adaptive Thresholding
◼ Thresholding – Basic Adaptive Thresholding
Adaptive Thresholding
◼ Thresholding – Basic Adaptive Thresholding
Adaptive Thresholding
◼ Thresholding – Basic Adaptive Thresholding
Adaptive Thresholding
◼ Thresholding – Basic Adaptive Thresholding
Adaptive Thresholding
◼ Thresholding – Basic Adaptive Thresholding
Representation & Description
Introduction
• After an image is segmented into regions; the resulting
aggregate of segmented pixels is represented & described for
further computer processing.
• Representing region involves two choices:
➢ in terms of its external characteristics(boundary)
➢ in terms of its internal characteristics(pixels comprising the
region)
• Above scheme is only part of task of making data useful to
computer.
• Next task is to Describe the region based on representation.
• Ex. A region may be represented by its boundary & its boundary is
described by features such as its length, the orientation of straight line
joining its extreme points & number of concavities in the boundary.
Introduction
Q. Which to choose when?
We assume
i) we work with binary images with object and background
represented as 1 & 0 respectively.
ii) Images are padded with borders of 0s to eliminate the
possibility of object merging with image border.
Representation
1) Let the starting point b0 be the uppermost, leftmost point in
the image. c0 the west neighbor of b0. Examine 8 neighbors
of b0 starting at c0 & proceed in clockwise direction.
1 1 1 1
1 1
1 1
1 1
1 1 1 1
c0 b0 1 1 1 b 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1 1 1 1
Representation
2) Let b = b1 & c = c1
3) Let the 8-neighbors of b, starting at c & proceeding in
clockwise directions be denoted by n1, n2, …..n8. Find first nk
labeled 1.
4) Let b = nk & c = nk-1
b0 1 b 1 b 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1 1 1 1 1
Representation
5) Repeat step 3 & 4 until b = b0 & next boundary point found is
b1. The sequence of b points found when the algorithm stops
constitutes the set of ordered boundary points.
1 c0 b0
c
1 1 1 1
1 b
1 1
1
1 1 1 1
1 1
1 1 1 1 1 1
1 1 1
Representation
4-direction
8-direction
130
6 6 7 6 4 4 4 4 2 1 2 2 2 2 0 7 6
Comparing the two chain codes we can say that the circular
structure of chain code is retained.
0 7 6 6 6 7 6 4 4 4 4 2 1 2 2 2 2
First difference
x y m00
= m11 − x m01 = m11 − ym10
Regional Descriptors
Moments of Two-Dimensional Functions
6 = ( 20 − 02 )(30 + 12 ) 2 − ( 21 + 03 ) 2
•
1 2 3 4
y
1 3 1 2 2
2 2 3 2 2
3 3 2 0 1
4 1 0 3 2
x
1 2 3 4 5 6 7 8------------y
1
2
3
4
5
6
7
8
I
I
I
I Compute all the moments upto second order including the second
X moments for a binary image of chess board
Summary
◼ Segmentation is the most essential step
in most scene analysis and automatic
pictorial pattern recognition problems.