0% found this document useful (0 votes)
5 views

IPMV_MOD_4

Image segmentation is the process of partitioning an image into groups that correspond to objects, typically using algorithms based on intensity properties such as discontinuity and similarity. Discontinuities can be detected through points, lines, and edges, with various methods including gradient operators like Prewitt and Sobel, as well as the Laplacian operator. The Hough Transform is introduced as a method for object recognition that allows for edge detection without requiring connected edges or complete visibility of objects.

Uploaded by

fire.smoke.yolo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

IPMV_MOD_4

Image segmentation is the process of partitioning an image into groups that correspond to objects, typically using algorithms based on intensity properties such as discontinuity and similarity. Discontinuities can be detected through points, lines, and edges, with various methods including gradient operators like Prewitt and Sobel, as well as the Laplacian operator. The Hough Transform is introduced as a method for object recognition that allows for edge detection without requiring connected edges or complete visibility of objects.

Uploaded by

fire.smoke.yolo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 159

Image Segmentation

◼ Segmentation attempts to partition the pixels of


an image into groups that strongly correlate
with the objects in an image
◼ Typically the first step in any automated
computer vision application
Image Segmentation
• Segmentation algorithms generally are based
on one of two basis properties of intensity
values
• Discontinuity: to partition an image based
on abrupt changes in intensity (such as
edges)

• Similarity: to partition an image into regions


that are similar according to a set of
predefined criteria.
Image Segmentation
Image Segmentation
◼ Image Segmentation
Image Segmentation
◼ Detection of discontinuities:
◼ There are three basic types of gray-level
discontinuities:
◼ points , lines , edges

◼ the common way is to run a mask through


the image
Detection of Discontinuities

• There are three kinds of discontinuities of intensity: points,


lines and edges.
• The most common way to look for discontinuities is to scan a
small mask over the image. The mask determines which kind
of discontinuity to look for.
9
R = w1 z1 + w2 z 2 + ... + w9 z9 =  wi zi
i =1
Point Detection:
• Note that the mark is the same as the mask of
Laplacian Operation (in last chapter )

• The only differences that are considered of


interest are those large enough (as determined
by T) to be considered isolated points.

|R| >T
Point Detection:
Line Detection

R1 R2 R3 R4

• Horizontal mask will result with max response when a line


passed through the middle row of the mask with a constant
background.
• the similar idea is used with other masks.
• note: the preferred direction of each mask is weighted with
a larger coefficient (i.e.,2) than other possible directions.
Line Detection
• Apply every masks on the image
• let R1, R2, R3, R4 denotes the response of
the horizontal, +45 degree, vertical and -45
degree masks, respectively.
• if, at a certain point in the image
|Ri| > |Rj|, for all j≠i,
• that point is said to be more likely
associated with a line in the direction of
mask i.
Line Detection
• Alternatively, if we are interested in detecting all
lines in an image in the direction defined by a
given mask, we simply run the mask through the
image and threshold the absolute value of the
result.
• The points that are left are the strongest
responses, which, for lines one pixel thick,
correspond closest to the direction defined by
the mask.
Line Detection
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 000 00000 00000000
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 000 0000000000000
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 40 40 40 40 40 40 40 40 40 40
10 10 10 10 10 10 10 10 10 10 10
000 00000 00000000
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0
000 0000000000000
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0

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.

◼ Edges found by looking at neighboring pixels.

◼ Region boundary formed by measuring gray


value differences between neighboring pixels
Edge Detection

• an edge is a set of connected pixels that


lie on the boundary between two regions.

• an edge is a “local” concept whereas a


region boundary, owing to the way it is
defined, is a more global idea.
Edge Detection
Edge Detection
Edge Detection
Edge Detection
◼ Detection of discontinuities: Image Derivatives
Edge Detection
• First column: images and gray-
level profiles of a ramp edge
corrupted by random Gaussian
noise of mean 0 and = 0.0,
0.1, 1.0 and 10.0, respectively.
• Second column: first-derivative
images and gray-level profiles.
• Third column : second-
derivative images and gray-
level profiles.
Edge Detection

◼ 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

Roberts cross-gradient operators

Prewitt operators

Sobel operators

ujwal harode 23
Detection of Discontinuities
Gradient Operators

Prewitt masks for


detecting diagonal edges

Sobel masks for


detecting diagonal edges

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

• Second-order derivatives: (The Laplacian)


– The Laplacian of an 2D function f(x,y) is defined as
2 f 2 f
 f = 2 + 2
2

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.

Positive Laplacian Operator

0 1 0
1 -4 1
0 1 0

Positive Laplacian Operator is use to take out outward edges in an image.

Negative Laplacian Operator

0 -1 0
-1 4 -1
0 -1 0

Negative Laplacian operator is use to take out inward edges in an image


How it works
➢Laplacian is a derivative operator; its uses highlight gray level
discontinuities in an image and try to deemphasize regions with slowly
varying gray levels.

➢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.

➢Similarly if we apply negative Laplacian operator then we have to add


the resultant image onto original image to get the sharpened image.
After applying Positive Laplacian Operator After applying Negative Laplacian Operator
Edge Detection
◼ The Laplacian
Detection of Discontinuities
Gradient Operators

• Consider the function: A Gaussian function


r2
− 2
h( r ) = −e 2
where r 2 = x 2 + y 2
and  : the standard deviation
• The Laplacian of h is
r2 The Laplacian of a Gaussian
r −  2 2 − 2
 h( r ) = − 
2
e
2 (LoG)

 
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

North West Direction Edges


Cont…..

West Direction Edges

South West Direction Edges


Cont…..
South Direction Edges

South East Direction Edges


Cont…..
East Direction Edges

North East 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

• Two properties of edge points are useful for edge linking:


– the strength (or magnitude) of the detected edge points
– their directions (determined from gradient directions)
• This is usually done in local neighborhoods.
• Adjacent edge points with similar magnitude and direction are
linked.
• For example, an edge pixel with coordinates (x0,y0) in a
predefined neighborhood of (x,y) is similar to the pixel at (x,y)
if
f ( x, y ) − ( x0 , y0 )  E , E : a nonnegative threshold
 ( x, y ) −  ( x0 , y0 )  A, A : a nonegative angle threshold
Edge Linking and Boundary Detection
Local Processing: Example

In this example,
we can find the
license plate
candidate after
edge linking
process.

ujwal harode 52
Hough Transform

• Elegant method for direct object recognition

• Edges need not be connected

• Complete object need not be visible

• Key Idea: Edges VOTE for the possible model


The 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:

• Quantize Parameter Space (m, c)


(m, c)
• Create Accumulator Array A(m, c)
x
• Set A(m, c) = 0 m, c Parameter Space
A(m, c)
• For each image edge ( xi , yi ) increment:
1 1

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

Improvement: (Finite Accumulator Array Size)


x
Line equation:  = − x cos  + y sin  Image Space

Here 0    2 
0     max
Given points ( xi , yi ) find (  ,  ) ?

Hough Space Sinusoid


Hough Space

The Hough Transform
◼ Global processing: The Hough Transform
Image space Votes

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

• Difficulties • How many lines?


– how big should the cells be? – Count the peaks in the
(too big, and we merge quite Hough array
different lines; too small, and
– Treat adjacent peaks as a
noise causes lines to be
single peak
missed)
• Which points belong to each
line?
– Search for points close to
the line
– Solve again for line and
iterate
Region-Based Segmentation
What is a Region?
◼ Basic definition :- A group of connected
pixels with similar properties.

◼ Important in interpreting an image because


they may correspond to objects in a scene.
◼ For that an image must be partitioned into
regions that correspond to objects or parts of
an object.
Region-Based vs. Edge-Based

Region-Based Edge-Based

◼ Closed boundaries ◼ Boundaries formed


not necessarily
closed
◼ Multi-spectral ◼ No significant
images improve improvement for
segmentation multi-spectral images
◼ Computation based ◼ Computation based
on similarity on difference
Region-Based Segmentation

• Edges and thresholds sometimes do not give good


results for segmentation.
• Region-based segmentation is based on the
connectivity of similar pixels in a region.
– Each region must be uniform.
– Connectivity of the pixels within the region is very
important.
• There are two main approaches to region-based
segmentation: region growing and region splitting.

ujwal harode 69
What is a Region?
• Basic definition :- A group of connected pixels with
similar properties.

• Important in interpreting an image because they may


correspond to objects in a scene.

• For correct interpretation, image must be partitioned


into regions that correspond to objects or parts of an
object.

ujwal harode 70
Partitioning – How?
• Partitioning into regions done often by using gray
values of the image pixels.

• Two general approaches :-

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

Assumption: Points on same object will project


to spatially close pixels on the image with similar
gray values.

ujwal harode 73
Limitation
• The assumption does not hold true in all cases.

• To overcome this, group pixels using given principles


and use domain-dependent knowledge.

• Match regions to object models.

ujwal harode 74
Region Segmentation
• Problem Statement:-

Given a set of image pixels and a homogeneity predicate


P(.), find a partition of the image into a set of n regions Ri
such that
n

 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

• Let R represent the entire image region.


• Segmentation is a process that partitions R into subregions,
R1,R2,…,Rn, such that
n
(a)  Ri = R
i =1
(b) Ri is a connected region, i = 1,2,..., n
(c) Ri  R j =  for all i and j , i  j
(d) P( Ri ) = TRUE for i = 1,2,..., n
(e) P( Ri  R j ) = FALSE for any adjacent regions Ri and R j
where P(Rk): a logical predicate defined over the points in set Rk
For example: P(Rk)=TRUE if all pixels in Rk have the same gray
level.
Original Image Region Segmented Image

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

• Fig. 10.41 shows the histogram of Fig. 10.40 (a). It is difficult to


segment the defects by thresholding methods. (Applying region
growing methods are better in this case.)

Figure 10.40(a) Figure 10.41


Region-Oriented Segmentation
Region Splitting

❑ Region growing starts from a set of seed points.
❑ An alternative is to start with the whole image as a single region and
subdivide the regions that do not satisfy a condition of homogeneity.

◼ 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

• The main problem with region splitting is determining where to


split a region.
• One method to divide a region is to use a quadtree structure.
• Quadtree: a tree in which nodes have exactly four descendants.

ujwal harode 84
Region-Based Segmentation
Region Splitting and Merging

• Region splitting is the opposite of region growing.


– First there is a large region (possible the entire image).
– Then a predicate (measurement) is used to determine if
the region is uniform.
– If not, then the method requires that the region be split
into two regions.
– Then each of these two regions is independently tested by
the predicate (measurement).
– This procedure continues until all resulting regions are
uniform.

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

– stop when all regions are


homogeneous: P(R ) = TRUE) obtain
i

quadtree structure
Bottom-up
– at each level, merge adjacent regions
R and R if P(R [ R ) = TRUE
i j i j

• Iterate until no further


splitting/merging is possible
Region-Based Segmentation
Region Splitting and Merging

• The split and merge procedure:


– Split into four disjoint quadrants any region Ri for which
P(Ri) = FALSE.
– Merge any adjacent regions Rj and Rk for which P(RjURk) =
TRUE. (the quadtree structure may not be preserved)
– Stop when no further merging or splitting is possible.

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

Sample image First split


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

Second split Third split


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

Merge Final result


Image Thresholding

•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

◼ Some automatic thresholding schemes:


1. P-tile method
2. Iterative threshold selection
3. Adaptive thresholding
Thresholding Methods
◼ P-tile Method:- If object
occupies P% of image pixels
then set a threshold T such
that P% of pixels have
intensity below T.

◼ 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?

• External representation is chosen when primary focus is on


shape characteristics.

• Internal representation is chosen when primary focus is on


regional properties such as color & texture.

• Sometimes it is necessary to choose both representations.

• Features selected as descriptors should be insensitive to

changes in size, translation & rotation.


Representation
• It deals with compaction of segmented data into
representations that facilitate the computation of descriptors.

1) Boundary (Border) Following:


Most of the algorithms require that points in the boundary of a
region be ordered in a clockwise (or counterclockwise)
direction.

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

Let b1 denote first neighbor encountered with value 1 & c1 be


background point immediately preceding b1 in the sequence.
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

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.

The algorithm is also called as Moore boundary Tracking


algorithm.

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

• Image regions (including segments) can be represented by


either the border or the pixels of the region. These can be
viewed as external or internal characteristics, respectively.
• Chain codes: represent a boundary of a connected region.
Representation
Chain Codes
Representation
Chain Codes

• Chain codes can be based on either 4-connectedness


or 8-connectedness.
• The first difference of the chain code:
– This difference is obtained by counting the number of
direction changes (in a counterclockwise direction)
– For example, the first difference of the 4-direction chain
code 10103322 is 3133030.
• Assuming the first difference code represent a closed
path, rotation normalization can be achieved by
circularly shifting the number of the code so that the
list of numbers forms the smallest possible integer.
• Size normalization can be achieved by adjusting the
size of the resampling grid.
Representation
Polygonal Approximations

• Polygonal approximations: to represent a boundary by straight line


segments, and a closed path becomes a polygon.
• The number of straight line segments used determines the accuracy of the
approximation.
• Only the minimum required number of sides necessary to preserve the
needed shape information should be used (Minimum perimeter polygons).
• A larger number of sides will only add noise to the model.
Representation
Polygonal Approximations

• Minimum perimeter polygons: (Merging and splitting)


– Merging and splitting are often used together to ensure that
vertices appear where they would naturally in the boundary.
– A least squares criterion to a straight line is used to stop the
processing.
Representation
Signature

• The idea behind a signature is to convert a two dimensional


boundary into a representative one dimensional function.
Representation
Signature

• Signatures are invariant to location, but will


depend on rotation and scaling.
– Starting at the point farthest from the reference
point or using the major axis of the region can be
used to decrease dependence on rotation.
– Scale invariance can be achieved by either scaling
the signature function to fixed amplitude or by
dividing the function values by the standard
deviation of the function.
Boundary Descriptors

• There are several simple geometric measures


that can be useful for describing a boundary.
– The length of a boundary: the number of pixels
along a boundary gives a rough approximation of
its length.
– Curvature: the rate of change of slope
• To measure a curvature accurately at a point in a digital
boundary is difficult
• The difference between the slops of adjacent boundary
segments is used as a descriptor of curvature at the
point of intersection of segments
Representation
chain code

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

Is same as first code.


Show that the first difference of chain normlize it to rotation
Boundary Descriptors
Shape Numbers

First difference

• The shape number of a boundary is defined as the first


difference of smallest magnitude.
• The order n of a shape number is defined as the number of
digits in its representation.
Boundary Descriptors
Shape Numbers
Boundary Descriptors
Shape Numbers
Regional Descriptors

• Some simple descriptors


– The area of a region: the number of pixels in the
region
– The perimeter of a region: the length of its
boundary
– The compactness of a region: (perimeter)2/area
– The mean and median of the gray levels
– The minimum and maximum gray-level values
– The number of pixels with values above and below
the mean
Regional Descriptors
Example
Regional Descriptors
Moments of Two-Dimensional Functions

• For a 2-D continuous function f(x,y), the moment of


order (p+q) is defined as
 
m pq =   x p y q f ( x, y )dxdy for p, q = 1,2,3,...
− −

• The central moments are defined as


 
 pq =   ( x − x ) ( y − y ) f ( x, y )dxdy
p q
− −
m10 m01
where x = and y =
m00 m00
Regional Descriptors
Moments of Two-Dimensional Functions

• If f(x,y) is a digital image, then


 pq =  ( x − x ) p ( y − y ) q f ( x, y )
x y
• The central moments of order up to 3 are
 00 =  ( x − x ) 0 ( y − y ) 0 f ( x, y ) =  f ( x, y ) = m00
x y x y
m10
10 =  ( x − x )1 ( y − y ) 0 f ( x, y ) = m10 − (m00 ) = 0
x y m00
m01
 01 =  ( x − x ) ( y − y ) f ( x, y ) = m01 −
0 1
(m00 ) = 0
x y m00
m10 m01
11 =  ( x − x ) ( y − y ) f ( x, y ) = m11 −
1 1

x y m00
= m11 − x m01 = m11 − ym10
Regional Descriptors
Moments of Two-Dimensional Functions

• The central moments of order up to 3 are


 20 =  ( x − x ) 2 ( y − y ) 0 f ( x, y ) = m20 − x m10
x y
 02 =  ( x − x ) 0 ( y − y ) 2 f ( x, y ) = m02 − ym01
x y

 21 =  ( x − x ) 2 ( y − y )1 f ( x, y ) = m21 − 2 x m11 − ym20 + 2 x m01


x y

12 =  ( x − x )1 ( y − y ) 2 f ( x, y ) = m12 − 2 ym11 − x m02 + 2 ym10


x y

30 =  ( x − x )3 ( y − y ) 0 f ( x, y ) = m30 − 3x m20 + 2 x 2 m10


x y

 03 =  ( x − x ) 0 ( y − y )3 f ( x, y ) = m03 − 3 ym02 + 2 y 2 m01


x y
Regional Descriptors
Moments of Two-Dimensional Functions

• The normalized central moments are defined as


 pq
 pq = 
 00
p+q
where  = +1 for p + q = 2,3,....
2
Regional Descriptors
Moments of Two-Dimensional Functions

• A seven invariant moments can be derived from the


second and third moments:
1 =  20 +  02
2 = ( 20 −  02 ) 2 + 4112
3 = (30 − 312 ) 2 + (3 21 −  03 ) 2
4 = (30 + 12 ) 2 + ( 21 +  03 ) 2
5 = (30 − 312 )(30 + 12 )(30 + 12 ) 2 − 3( 21 +  03 ) 2 

+ (3 21 −  03 )( 21 +  03 ) 3(30 + 12 ) 2 − ( 21 +  03 ) 2 
Regional Descriptors
Moments of Two-Dimensional Functions

6 = ( 20 −  02 )(30 + 12 ) 2 − ( 21 +  03 ) 2 

+ 411 (30 + 12 )( 21 +  03 )


7 = (3 21 −  03 )(30 + 12 )(30 + 12 ) 2 − 3( 21 +  03 ) 2 

+ (312 − 30 )( 21 +  03 ) 3(30 + 12 ) 2 − ( 21 +  03 ) 2 
• This set of moments is invariant to translation,
rotation, and scale change.
Regional Descriptors
Moments of Two-Dimensional Functions
Find the moments for the given image- m(0,0), m(1,0),
m(0,1), m(1,1), m(2,0), m(0,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.

◼ Choice of the technique depends on the


peculiar characteristics of individual
problem in hand.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy