Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
36 views

Module 3

This document provides a 3-paragraph summary of the key topics covered in the ECT 385: Topics in digital image processing module regarding image segmentation. It discusses the objectives of image segmentation, partitioning images into objects or regions, and image segmentation representing the first step in image analysis and pattern recognition.

Uploaded by

suma_hari6244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Module 3

This document provides a 3-paragraph summary of the key topics covered in the ECT 385: Topics in digital image processing module regarding image segmentation. It discusses the objectives of image segmentation, partitioning images into objects or regions, and image segmentation representing the first step in image analysis and pattern recognition.

Uploaded by

suma_hari6244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 98

ECT 385: Topics in digital

image processing
S5 Minor

Module 3 : Image segmentation

Reference Textbook: Digital Image Processing by S Jayaraman, S Essakirajan, T Veerakumar,


Digital Image Processing by Rafael C. Gonzalez and Richard E. Woods
Image segmentation
 The main objective of image segmentation is to extract various features of the
image which can be merged or split in order to build objects of interest on which
analysis and interpretation can be performed.
 Segmentation attempts to partition the pixels of an image into groups that strongly
correlate with the objects in an image
 Image segmentation represents the first step in image analysis and pattern
recognition.
• Image segmentation partitions an image into constituent regions or
objects based on the required application.
• The segmentation is based on measurements taken from the image and
might be grey level, colour, texture, depth, motion etc.
• It can be defined mathematically as:
𝐼 = 𝑅1 𝖴 𝑅2 𝖴… 𝑅𝑁
An image 𝑰 can be divided into 𝑵 disjoint sets, 𝑹𝟏, 𝑹𝟐, … 𝑹𝑵 called
segments or regions such that the union of all regions equals original
image 𝑰
• Segmentation should stop once the object of Region of Interest (ROI) is
identified
Applications:
• Identifying objects in a scene for object-based measurements such as size and shape

• Identifying objects in a moving scene for object-based video compression


(MPEG4)
• Identifying objects which are at different distances from a sensor using depth measurements.
This can be used to plan a path for a mobile robots
Classification of segmentation algorithms based
on intensity values
 Segmentation algorithms generally are based on one of two basic properties of
intensity values
 Discontinuity: to partition an image based on abrupt changes in intensity
 There are three basic types of gray-level discontinuities:

 points , lines , edges

 Similarity: to partition an image into regions that are similar according to a set
of predefined criteria.
 Region-based segmentation
Classification of segmentation based on the
image area of consideration
Local Segmentation
– Segmenting sub-images which are small windows on a whole image
– Number of pixels available will be lower than the global segmentation
Global Segmentation
– Concerned with segmenting a whole image
– Global segmentation deals with segments consisting of a relatively large number of pixels
Image Segmentation Approaches

Region approach
– Each pixel is assigned to a particular object or region.
Boundary approach
– Attempts to locate directly the boundaries that exist between the regions
Edge approach
– Edges are identified first, and are linked together to form required boundaries
Region Based Segmentation
• Region –an aggregation of pixels with common properties
• Properties like gray level, color, texture, shape help to identify regions and
similarity of such properties, is used to build groups of regions having a
particular meaning.
• Region-based segmentation is based on the connectivity of similar
pixels in a region.
• 2 main approaches to region-based segmentation:
– Region growing
– Region splitting and merging
Region Growing
• Groups pixels or sub-regions into larger regions based on predefined criteria.

• Neighbouring pixels are examined and added to a region class if no edges are found.

• This process is iterated for each boundary pixel in the region.

• The basic idea is to start with a set of seed points and from these grow regions by
appending to each seed those neighboring pixels that have properties similar to the seed
(specified ranges of gray level or colour)

• Once the region is identified, a new seed is chosen from the remaining pixels and the
process is repeated. This continues until all pixels have been allocated to a segment

Rajagiri School of Engineering & Technology, Kochi 10


Region Growing
Region growing algorithm
Let,
• f (x, y) : input image;
• S (x, y) : a seed array containing 1’s at the locations of seed points and 0’s elsewhere
• Q : a predicate to be applied at each location (x,y)
• Arrays f and S are assumed to be of the same size.
A basic region-growing algorithm based on 8-connectivity may be stated as follows
Region growing segmentation: Example
• 8-bit X-ray image of a weld (the horizontal dark region) containing several cracks and porosities
(the bright regions running horizontally through the center of the image).
• use of region growing by segmenting the defective weld regions
• The weld is very bright. The predicate used for region growing is to compare the absolute
difference between a seed point and a pixel to a threshold. If the difference is below it we accept
the pixel as crack

X-Ray image of weld Histogram Seed image (99.9% of max


with a crack we want to value in the initial image)
segment.
Seed image eroded to 1 Difference between Histogram of the
pixel regions. the original image and difference image.
the initial seed image.

The pixels are ready to be compared to the threshold.


Thresholding of the Segmentation result
difference image with by region growing.
threshold = 68
• The black points are the pixels for which the predicate was TRUE; the others failed the
predicate.
• The points in the good regions of the weld failed the predicate, so they will not be
included in the final result .
• The outer points in the background are also black, but it is not considered as crack
because It is removed by segmentation as it is not 8-connected to the seed pixels.
Advantages
• The boundaries of regions found by region growing are perfectly thin &
connected
• Can correctly separate the regions that have the same properties we define.
• Can provide the original images which have clear edges with good
segmentation results.
• Simple concept: only need a small number of seed points to represent the
property we want, then grow the region.
Region Splitting & Merging
 Subdivide an image initially into a set of disjoint regions
(Quadrants) and then merge and/or split the regions in an attempt
to satisfy the conditions of segmentation
 Splitting technique has a convenient representation in the form
of so-called quadtrees
 The images corresponding to the nodes of a quadtree sometimes
are called quadregions or quadimages
 The root of the tree corresponds to the image.
 Split the image to sub-images that do not satisfy a predicate Q.
 Algorithm
 Split into four disjoint quadrants any region Ri for which
Q(Ri)=FALSE.
 When no further splitting is possible, merge any adjacent
regions Ri and Rk for which Q (Ri∪Rk) = TRUE
 Stop when no further merging is possible.
18
Region Splitting & Merging - Example
• X-ray image of the Cygnus Loop nebula emission.
• We want to segment the outer ring of less dense
matter.
• Characteristics of the region of interest:
• Standard deviation grater than the background
(which is near zero) and the central region (which
is smoother).
• Mean value greater than the mean of background
and less than the mean of the central region.
• Predicate
Varying the minimum size of the quadregion

Larger quadregions
lead to block-like
segmentation.
32x32
Smaller quadregions
lead to small black
regions.

16x16 seems to be
the best result.
16x16 8x8
Apply split and merge segmentation to the following image and show the quadtree
Clustering Based Segmentation
• The clustering technique attempts to access the relationships among patterns of the
data set by organising the patterns into groups or clusters such that patterns within a
cluster are more similar to each other than patterns belonging to different clusters.
• Clustering refers to the classification of objects into groups according to certain
properties of these objects.
• In the clustering technique, an attempt is made to extract a feature vector from local
areas in the image.
• A standard procedure for clustering is to assign each pixel to the class of the nearest
cluster mean.
• Clustering : two categories
• hierarchical
• Partitional
• Within each category, there exist many types of algorithms for finding clusters.
23
Rajagiri School of Engineering & Technology, Kochi
Hierarchical clustering
 Hierarchical clustering techniques are based on the use of a proximity matrix
indicating the similarity between every pair of data points to be clustered.

 The end result is a tree of clusters representing the nested group of patterns and
similarity levels at which groupings change.

 The clustering methods differ in regard to the rules by which two small clusters are
merged or a large cluster is split.

 two main categories of algorithms used in the hierarchical clustering framework are

 Agglomerative

 divisive
Agglomerative Clustering
("bottom-up") Root abcd

• It starts with N single point


clusters. ab cd
• The most similar clusters are
grouped to form the next set of
cluster.
Leaf a b c Leaf d
• These clusters are then merged
to form larger set of clusters
• Finally all the data points are
made into a single cluster Tree like structure: Dendogram
Leaf node: Individual Data Sample
Root Node: Reserved for entire dataset

25
Agglomerative Clustering Algorithm
• More popular hierarchical clustering technique
• Basic algorithm is straightforward
1. Compute the distance matrix
2. Let each data point be a cluster
3. Repeat
4. Merge the two closest clusters
5. Update the distance matrix
6. Until only a single cluster remains

• Key operation is the computation of the distance between two


clusters
– Different approaches to defining the distance between clusters distinguish
the different algorithms

http://jcsites.juniata.edu/faculty/rhodes/ml/hiercluster.htm
2
6
How to Define Inter-Cluster Distance

p1 p2 p3 p4 p5 . ..
p1
Distance?
p2
p3
p4
p5
⚫ MIN
.
⚫ MAX
. Distance Matrix
⚫ Group Average .
⚫ Distance Between Centroids

27
Single Link Algorithm
– The distance between two clusters is represented by the distance of the
closest pair of data objects belonging to different clusters.
– Determined by one pair of points, i.e., by one link in the proximity graph
– merges two clusters according to the minimum distance between the data
samples from two clusters .
– The algorithm allows for a tendency to produce clusters with elongated
shapes
Complete Link Algorithm
• The distance between two clusters is represented by the distance of the
farthest pair of data objects belonging to different clusters
• Incorporates the maximum distance between data samples in clusters,
but its application always results in compact clusters

2
9
Minimum-variance algorithm (Ward’s method)
 Ward’s method (a.k.a. Minimum variance method or Ward’s Minimum Variance Clustering
Method) is an alternative to single-link clustering.

 Ward’s method starts with n clusters, each containing a single object. These n clusters are
combined to make one cluster containing all objects. At each step, the process makes a
new cluster that minimizes variance, measured by an index called E (also called the sum of
squares index).

 At each step, the following calculations are made to find E:

 Find the mean of each cluster.

 Calculate the distance between each object in a particular cluster, and that cluster’s
mean.

 Square the differences from Step 2.

 Sum (add up) the squared values from Step 3.


Divisive Clustering
("top-down")
• Divisive clustering begins with the entire
Root abcd

dataset in the same cluster, followed by


iterative splitting of the dataset until the ab cd
single-point clusters are attained on leaf
nodes.
• It follows a reverse clustering strategy Leaf a b c Leaf d
against agglomerative clustering.
• On each node, the divisive algorithm Tree like structure: Dendogram
conducts a full search for all possible pairs Leaf node: Individual Data Sample
Root Node: Reserved for entire dataset
of clusters for data samples on the node.
31
Partitional Clustering
Partitional clustering: Partitional algorithms determine all clusters at once.
E.g. K means Clustering, Fuzzy c-means clustering

32
K means Clustering:
• Simplest method of unsupervised learning
• Groups the unlabeled dataset into different clusters.
• K stands for the number of clusters (user input to algorithm) i.e K=2, there
will be two clusters, and for K=3, there will be three clusters, and so on
• It is a centroid-based algorithm, where each cluster is associated with a
centroid. T

33
K-means Clustering Algorithm
• Randomly choose K data points to be initial cluster centres (centroids)
• Assign each data point to the closest cluster centre
• Recompute the cluster centres using the current cluster membership
• Repeat the procedure from step 2 until the convergence criterion is met
Stopping/ Convergence Criterion

1. No re-assignment of data points to different clusters

2. No (minimum) change of centroid (cluster centre) (Convergence of


centroid)

3. Minimum decrease in sum of squared error


Rajagiri School of Engineering & Technology, Kochi 34
Advantages
• Relatively simple to implement.
• Scales to large data sets.
• Guarantees convergence.
• Can warm-start the positions of centroids.
• Easily adapts to new examples.
• Generalizes to clusters of different shapes and sizes, such as elliptical clusters.
Disadvantages
 No-optimal set of clusters
 K-means doesn’t allow the development of an optimal set of clusters and for
effective results, you should decide on the clusters before.
 Lacks consistency
 K-means clustering gives varying results on different runs of an algorithm. A
random choice of cluster patterns yields different clustering results resulting in
inconsistency.
 Uniform effect
 It produces clusters with uniform sizes even when the input data has different
sizes.
 Order of values
 The way in which data is ordered in building the algorithm affects the final results
of the data set.
 Sensitivity to scale
 Changing or rescaling the dataset either through normalization or standardization
will completely change the final results.
Disadvantages
 Computational load:
 When dealing with a large dataset, conducting a dendrogram technique will
cause increased computational load
 Handle numerical data
 K-means algorithm can be performed in numerical data only.
 Operates in assumption
 K-means clustering technique assumes that we deal with spherical clusters and
each cluster has equal numbers for observations. The spherical assumptions
have to be satisfied. The algorithm can’t work with clusters of unusual size.
 Specify K-values
 For K-means clustering to be effective, you have to specify the number of
clusters (K) at the beginning of the algorithm.
 Prediction issues
 It is difficult to predict the k-values or the number of clusters. It is also difficult
to compare the quality of the produced clusters.
Fuzzy Clustering
 Fuzzy clustering (also referred to as soft clustering or soft k-means) is a form of
clustering in which each data point can belong to more than one cluster
 Clustering methods can be classified as either hard or fuzzy depending on whether a
pattern data belongs exclusively to a single cluster or to several clusters with different
degrees.
 In hard clustering, a membership value of zero or one is assigned to each pattern data
 In fuzzy clustering, a value between zero and one is assigned to each pattern by a
membership function
 In general, fuzzy clustering methods can be considered to be superior to those of their
hard counterparts since they can represent the relationship between the input pattern data
and clusters more naturally.
 Frequently used in pattern recognition
Edge Based Segmentation
• Exploits spatial information by detecting the edges in an image.
• Edges refer to regions of an image where there is a abrupt change in intensity or
contrast
• Edges can be classified into:

Rajagiri School of Engineering & Technology, Kochi 40


Edge Based Segmentation
• Edges are discontinuities in image intensity due to changes in image structure
(due to different features of image, e.g. associated with boundaries of object)

• Sharpening filters are used to highlight variation in intensity


• First Order Derivatives:

Roberts, Sobel, Prewitt

• Second Order Derivatives:

Laplacian, Laplacian of Gaussian (LoG) and Difference of Gaussian (DoG)

Rajagiri School of Engineering & Technology, Kochi 41


42
First-order derivative & Second-order derivative
can be defined as follows:

f
= f ( x +1) − f ( x )
x
 f
2
= f ( x +1) + f ( x −1) − 2 f ( x )
x2
Gradient Operator

• To obtain the gradient of an image, the partial derivatives 𝜕𝑓


𝜕𝑥
and 𝜕𝑓
𝜕𝑦
must be
calculated at every pixel location in the image.
• The digital approximation of partial derivatives at a point (𝑥, 𝑦) is given by:
Common Masks for Computing Gradient
Roberts Cross Gradient: A 2 x 2 mask based on implementing differences in
the diagonal direction

-1 0 0 -1
0 1 1 0

𝑮𝒙 𝑮𝒚
Horizontal Vertical

3 X 3 region of an image These masks are simple but not useful in


with intensity values computing edge direction as compared to
3 x 3 masks
Common Masks for Computing Gradient
Prewitt Mask: It calculates the difference of right and left pixel values around
the edge in horizontal or vertical direction

-1 -1 -1 -1 0 1
0 0 0 -1 0 1
3 X 3 region of an image 1 1 1 -1 0 1
with intensity values
𝑮𝒙 𝑮𝒚
Horizontal Vertical
Common Masks for Computing Gradient
Sobel Mask: Similar to Prewitt mask, the center pixels around the edge region
are given more weightage.

-1 -2 -1 -1 0 1
Sobel masks are preferred because of
0 0 0 -2 0 2 better noise suppression characteristics
3 X 3 region of an image 1 2 1 -1 0 1
with intensity values
𝑮𝒙 𝑮𝒚
Horizontal Vertical
Example

-1 0 1 1*-1 +2*0+ 5*1+ 2*-2+…….+3*0 +4*1 =13

-2 0 2
-1 0 1
1 2 5 2
Gy 13
2 1 6 9
132 + 32 =13.34
3 3 4 9
1 0 1 8
-1 -2 -1
0 0 0
1 2 1 -1*1 +2*-2 +5*-1 +….. +3*2 +4*1 =3

Gx
Second derivative method of Edge detection
•Finding the ideal edge is
equivalent to finding the point
where the derivative is max or
min.
•To find the point where
derivative is max, differentiate the
1st derivative and equate to zero.
•Finding the optimal edge is
equivalent to finding places where
the second derivative is zero.
•Zero crossing is the place where
one pixel is positive and a
neighbouring pixel is negative.
27
Laplacian operator
Obtained by taking dot product of ∇ with itself
2 f 2 f
2 f = +
x2 y2
Application: Laplacian mask can be used
to detect an isolated point in an image
• Using the Laplacian mask, a point can be detected at the location (x,y) on
which the mask is centered, if the absolute value of the response of mask at
that point exceeds a specific threshold
• The output is obtained as:

50 50 50 50 Isolated point Note:


This principle can be extended
50 200 50 50 Laplacian Mask to detect lines and edges.
Adv: Laplacian operator is
50 50 50 50
isotropic i.e. response is
independent of direction
50 50 50 50
Laplacian of Gaussian (LoG)

Laplacian of Gaussian is defined as ∇2𝐺 where ∇2 is the Laplacian operator and 𝐺


is the 2D Gaussian function

• Prominent source of degradation of Laplacian operator is noise in input image


• Noise effects can be minimized by smoothing the image prior to edge
detection

Edge detection using LoG (Marr-Hildreth Algorithm) is summarized as follows:


i) Filter the input image with a Gaussian LPF
ii) Compute the Laplacian of resultant image obtained in Step 1.

iii) Find the zero crossings of image


Laplacian of Gaussian (LoG)

It is defined as ∇2𝐺 where ∇2 is the Laplacian operator and 𝐺 is the 2D Gaussian


function
• 2D Gaussian is defined as
1 −[𝑥 2 +𝑦 2 ]
𝐺 𝑥, 𝑦 = 𝑒 2𝜎 2
2𝜋𝜎2
• Laplacian operator is defined as
𝜕 2𝑓 𝜕 2𝑓
∇2𝑓 = 2 + 2
𝜕𝑥 𝜕𝑦
Therefore,
𝜕 2𝐺 𝜕 2𝐺
∇2𝐺 = 2
+ 2
𝜕𝑥 𝜕𝑦
Laplacian of Gaussian (LoG)

𝜕 2𝐺 𝜕 2𝐺
∇2𝐺 = 2
+ 2
𝜕𝑥 𝜕𝑦

− 𝑥 2 +𝑦 2
1 𝑥 2 +𝑦 2 −2𝜎 2
∇2𝐺 = 𝑒 2𝜎 2
𝜎4
2𝜋𝜎 2

The zero crossings of LoG occur at 𝑥 2 + 𝑦 2 = 2𝜎2 which defines a circle of


radius 2𝜎 centred on the origin
Advantage: It is isotropic and responds equally to changes in intensity in any mask
direction.
𝜵𝟐 𝑮

LoG is also known as


Mexican Hat Operator

Rajagiri School of Engineering & Technology, Kochi


Difference of Gaussian (DoG)

It is obtained by taking the difference of 2 Gaussian functions


• DoG is defined as

−[𝑥 2 +𝑦 2 ] −[𝑥 2 +𝑦 2 ]
1 2 1 2
𝐷𝑜𝐺 𝑥, 𝑦 = 𝑒 2𝜎1 − 𝑒 2𝜎2
2𝜋𝜎12 2𝜋𝜎22

with 𝜎1 > 𝜎2
• If the ratio of standard deviation is 1.6 ∶ 1, it gives a good approximation to LoG
Canny Edge Detector
Canny Edge Detection is based on 3 basic objectives:
1. Low Error Rate: All edges must be found and edges detected must be close to the
true edge.
2. Edge points must be well localized: The distance between point marked as an
edge by detector and centre of true edge must be minimum

3. Single edge point response: The detector should return only one point for each true
edge point
➢ One problem with a Laplacian zero-crossing as an edge detector is that it simply adds the
principal curvatures together. That is, it does not really determine the maximum of the
gradient magnitude. The Canny edge detector defines edges as zero-crossings of second
derivatives in the direction of the greatest first derivative.
Steps Involved in Canny Edge Detection
Let 𝑓(𝑥, 𝑦) denote the original image and 𝐺(𝑥, 𝑦) denote the 2D Gaussian function
1 −[𝑥 2 +𝑦 ]2
𝐺 𝑥, 𝑦 = 2
𝑒 2𝜎 2
2𝜋𝜎
 Step 1: Apply Gaussian filter to smooth the image in order to remove the noise

2D first
derivative operator is
 Step 2: Now compute gradient magnitude and direction (angle) of the image applied to the smoothed

after smoothing image to highlight regions


of the image with high
spatial derivatives.
Edges give rise to ridges in
the gradient magnitude
image.
Step 3: Apply Non-maximum suppression to get rid of
spurious response to edge detection
It helps to suppress all the gradient values to 0 except the local
maximal, which indicates location with the sharpest change of intensity
value.
• Compare the edge strength of the current pixel with the Non-maximal suppression:
edge strength of the pixel in the positive and negative Tracks along the top of these
gradient directions. ridges and sets to zero all
• If the edge strength of the current pixel is the largest pixels that are not actually on
the ridge top so as to give a
compared to the other pixels in the mask with the same thin line in the output
direction, the value will be preserved.
• Otherwise, the value will be suppressed.

Rajagiri School of Engineering & Technology, Kochi


Step 4: Apply double threshold to determine potential edges.
Set 2 threshold values: High Threshold value 𝑇1 and a Low Threshold
value 𝑇2
• If the gradient value of edge pixel > 𝑇1 → ‘Strong edge pixels’
• If 𝑇2 < gradient value of edge pixel < 𝑇1 → ‘Weak edge pixels’
• If the gradient value of edge pixel < 𝑇2, pixel is suppressed

Note: 𝑇1 and 𝑇2 values vary from image to image

Rajagiri School of Engineering & Technology, Kochi


Step 5: Track edge by hysteresis
• Weak edge pixels caused from true edges will be connected to strong
edge pixels
• If there is any strong edge pixel in the neighbourhood, that weak edge
point must be preserved
• All the other edges that are weak and not connected to strong edges are
suppressed
• Thus detection of edges can be finalized

Rajagiri School of Engineering & Technology, Kochi 61


Steps of Canny Edge Detector can be summarized as follows:
1. Apply Gaussian filter to smooth the image in order to remove
the noise
2. Find the intensity gradients of the image
3. Apply Non-maximum suppression to get rid of spurious
response to edge detection
4. Apply double threshold to determine potential edges
5. Track edge by hysteresis: Finalize the detection of edges by
suppressing all the other edges that are weak and not connected
to strong edges.

Rajagiri School of Engineering & Technology, Kochi 62


 The effectiveness of a Canny edge detector is determined by three parameters
 width of the Gaussian kernel
 upper threshold
 lower threshold used by the tracker
 Increasing the width of the Gaussian kernel reduces the detector’s sensitivity to
noise, at the expense of losing some of the finer details in the image.
 The localisation error in the detected edges also increases slightly as the Gaussian
width is increased.
 The Gaussian smoothing in the Canny edge detector fulfills two purposes.
 it can be used to control the amount of detail that appears in the edge image,
 It can be used to suppress noise.
 The upper tracking threshold is usually set quite high and the lower threshold value
is set quite low for good results.
 Setting the lower threshold too high will cause noisy edges to break up.
 Setting the upper threshold too low increases the number of spurious and
undesirable edge fragments appearing in the output
Canny Edge
Detector:
Example

Rajagiri School of Engineering & Technology, Kochi 64


Edge Linking Original Image

• Ideally, edge detection yields a set of pixels lying on


edges.

• In practice, these pixels cannot characterize a boundary


completely due to noise, non uniform illumination

• Edge Detection is followed by edge- linking algorithms.


Such algorithms assemble edge pixels into meaningful
edges or region boundaries.
• Can be classified into local, regional and global processing

Rajagiri School of Engineering & Technology, Kochi


• The detected pixels do not completely characterize edgesEdge Linking
completely due to
occlusions, non-uniform illumination and noise. Edge linking may be:

– Local: requiring knowledge of edge points in a small neighborhood.

– Regional: requiring knowledge of edge points on the boundary of a


region.

– Global: the Hough transform, involving the entire edge image.


Global Processing
• Used while working in unstructured environments

• All pixels are candidates for linking and have to be accepted or eliminated based
on predefined global properties.

Hough Transform : used to find subset of points that lie on a straight line

Rajagiri School of Engineering & Technology, Kochi 68


Hough Transform
 Any line in the x, y plane corresponds to a point in the 2D space defined by the
parameter ρ and θ.
 Thus the Hough transform of a straight line in the x, y space is a single point in the
ρ, θ space.
 Every straight line that passes through a particular point (xi, yi) in the (x, y) plane
plots to a point in the ρ, θ space and these points should satisfy the following
expression with xi, yi as constants

 Thus the locus of all such lines in the x, y space is a sinusoid in parameter space and
any point in the x, y plane corresponds to a particular sinusoidal curve in the ρ, θ
space.
 Suppose we have a set of edge points xi, yi that lie along a straight line having
parameters ρ0, θ0.
 Each edge point plots to a sinusoidal curve in the ρ, θ space, but these curves must
intersect at a point ρ0, θ0 since this is a line they all have common.
• In Hough transform, generally we consider the normal representation of line,
ρ = 𝑥𝑐𝑜𝑠𝜃 + 𝑦𝑠𝑖𝑛𝜃

A cell at coordinate
(𝑖, 𝑗) with
accumulator value
𝐴(𝑖, 𝑗) corresponds
to parameter space
coordinates (𝜌𝑖 , 𝜃𝑗 )

Rajagiri School of Engineering & Technology, Kochi


1
Edge Linking using Hough Transform
• The 𝜌 − 𝜃 parameter space is subdivided into accumulator cells (count initially set to 0).

(𝜌𝑚𝑖𝑛, 𝜌 max ) and (𝜃𝑚𝑖𝑛, 𝜃max) are expected ranges.

• For every point (𝑥𝑘 , 𝑦𝑘) and find 𝜌 = 𝑥𝑘𝑐𝑜𝑠𝜃 + 𝑦𝑘𝑠𝑖𝑛𝜃 for different values of 𝜃.
• The accumulator value corresponding to obtained value of 𝜌 and 𝜃 is incremented by one.
For example: if we obtain 𝜌𝑝, 𝜃𝑞 , the count in the corresponding accumulator cell 𝐴(𝑝, 𝑞) is
incremented by one.

• Repeat the process for all of the points (𝑥𝑖 , 𝑦𝑖) in the image .

Rajagiri School of Engineering & Technology, Kochi 71


• Find the accumulator cell with maximum count. The value of 𝜌, 𝜃 corresponding to
that cell will give the straight line in x-y plane with maximum points within it.

• Suppose 𝐴(𝑖, 𝑗) has a value of P, it means that there are P points in x-y plane on line
ρ𝑖 = 𝑥𝑐𝑜𝑠𝜃𝑗 + 𝑦𝑠𝑖𝑛𝜃𝑗

• Number of sub-divisions in 𝜌-𝜃 plane determine accuracy of collinearity of these


points

Rajagiri School of Engineering & Technology, Kochi 72


Active contour
 A promising image-analysis tool for refinement of an object boundary is the active contour or
snake.
 The curve formed by the connected edge points delineates the active contour.
 It is a set of connected points which interactively move so as to minimise a specified energy
function.
 Local properties of the image such as gray level, gradient, etc., contribute to the energy of the
snake.
 The snake reacts to the image, but moves in a smooth continuous manner towards the desired
object boundary

https://www.youtube.com/watch?v=CeU_yZjdVqY
Greedy-Snake Algorithm
 The steps involved in a greedy-snake algorithm are given below.
 A. Prepare the Image.
1. Define an energy function which could naturally take on low values for points located on the
actual boundary.
2. Generate an initial boundary by a segmentation technique such as thresholding.
 B. Wiggle the Snake.
1. Compare the boundary of each point on the boundary with the energies calculated for points in
its neighbourhood.
2. For each current boundary point, move the boundary to the neighbouring point that has the
lowest energy.
3. Perform this operation once on all points on the boundary to complete one iteration of the snake
algorithm.
4. Repeat this iteration until it causes no further movement of the boundary points.
5. When this happens, the snake is said to have ‘converged’ and the segmentation is complete.
 The choice of the energy function to be minimised determines the behaviour of
the algorithm.
 The energy function is given by

 Thus, the energy of the snake corresponds to three different forces:


 (i) Internal forces between points of the contour
 (ii) Image forces such as gray level and gradient magnitude that pull the snake
towards the optimal boundary position
 (iii) External constraints such as user forces applied to the contour
 The main advantages of the greedy-snake algorithm are computational
efficiency and relative simplicity.
 The two main drawbacks of snake formation are the following:
 (i) Poor convergence property of the active contours—specifically, concavities
in the object of interest are rarely covered.

 (ii) The second problem with snakes is the limited capture range, which is
related to the initialisation of the snake around the object of interest.
THRESHOLDING
• Image partitioning into regions directly from their
intensity values.
Noise in Thresholding
Difficulty in determining the threshold due to noise

Noiseless Gaussian (μ=0, σ=10) Gaussian (μ=0, σ=50)


Illumination in Thresholding
Difficulty in determining the threshold due to non-uniform illumination

(a) Noisy image (b) Intensity ramp Multiplication


image
Thresholding Example
 Imagine a poker playing robot that needs to visually interpret the cards in its
hand

Thresholded Image
Original Image
 If you get the threshold wrong the results can be disastrous

Threshold Too Low Threshold Too High


Basic Global Thresholding Algorithm
 Based on the histogram of an image
 Partition the image histogram using a single global threshold
 The success of this technique very strongly depends on how well the histogram
can be partitioned
 The basic global threshold, T, is calculated as follows:
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
4. Compute a new threshold value:

1 +  2
T=
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
Thresholding Example 1
Thresholding Example 2
Single Value Thresholding and Illumination

 Uneven illumination can really upset a single valued thresholding scheme


Basic Adaptive Thresholding
 An approach to handling situations in which single value thresholding will not
work is to divide an image into sub images and threshold these individually
 Since the threshold for each pixel depends on its location within an image this
technique is said to adaptive
 The image below shows an example of using adaptive thresholding with the image
shown previously

 As can be seen success is mixed


 But, we can further subdivide the troublesome sub images for more success
Basic Adaptive Thresholding Example (cont…)

 These images show the


troublesome parts of the
previous problem further
subdivided
 After this sub division
successful thresholding can be
achieved
Adaptive thresholding
Moving averages.
• Generally used along lines, columns or in zigzag .
• Useful in document image processing.
• Let zk+1 be the intensity of a pixel in the scanning sequence
at step k+1. The moving average (mean intensity) at this
point is: k +1


1 1
m(k +1) = zi = m(k) + (z k +1 − zk −n )
n i=k +2−n n
n is the number of points used in the average
• Segmentation is then performed at each point comparing
the pixel value to a fraction of the moving average.
Shaded text images Otsu Moving averages
occur typically from
photographic flashes
Sinusoidal variations (the Otsu Moving averages
power supply of the scanner
not grounded properly)

The moving average works well when the structure of interest is


small with respect to image size (handwritten text).
Optimal Thresholding
• Histogram shape can be useful in locating the threshold.

• However it is not reliable for threshold selection when peaks are not clearly
resolved.

• In optimal thresholding, a criterion function is devised that yields some measure


of separation between regions.

• A criterion function is calculated for each intensity and that which maximizes this
function is chosen as the threshold.

Rajagiri School of Engineering & Technology, Kochi 91


Optimum Global Thresholding
using Otsu’s Method
• The method is based on statistical decision theory.
• Minimization of the average error of assignment of pixels to two
(or more) classes.
• Bayes decision rule may have a nice closed form solution to this
problem provided
– The pdf of each class.
– The probability of class occurence.
• Pdf estimation is not trivial and assumptions are made
(Gaussian pdfs).
• Otsu (1979) proposed an attractive alternative maximizing
the between-class variance.
– Only the histogram of the image is used.
Example (no obvious valley in the histogram)

Image Histogram

Basic method Otsu’s method

You might also like