UNIT IV Image Segmentation
UNIT IV Image Segmentation
• Image analysis:
– Extracting information from an image.
• First step:
– To segment the image
– i.e. to subdivide an image into its constituent
regions or objects.
– Sub division is carried depends on the problem
– Segmentation should stop when the objects or
regions of interest have been detected.
Image Segmentation
• Segmentation is based on two basic
properties of gray-level values:
– Discontinuity, i.e. to partition the image based
on abrupt changes in intensity (gray levels), e.g.
edges
Isolated Points
Lines
Edges
9
R = w1 z1 + w2 z 2 + ... + w9 z9 = ∑ wi zi
i =1
Point Detection
• A point has been detected at the location on
which the mask is centered if: |R|>T
R1 R2 R3 R4
• Assumption:
– the regions are sufficiently homogeneous, so that
the transition between two regions can be
determined on the basis of gray-level
discontinuities alone.
Image Segmentation
Image Segmentation
Edge Detection
• Basic Idea:
– A profile is defined perpendicularly to the edge direction
and the results are interpreted.
– The magnitude of the first derivative is used to detect an
edge (if a point is on a ramp)
– The sign of the second derivative can determine whether
an edge pixel is on the dark or light side of an edge.
∂f
Gx ∂x
∇F = = ∂f
G y
∂y
∇f ≈| Gx | + | G y |
Gy
−1
Direction angle of ∇f at (x,y): a( x, y ) = tan
Gx
Image Segmentation
Image Segmentation
Image Segmentation
Image Segmentation
Image Segmentation
Gradient Operators
• Computation of the gradient of an image:
Gx = ( z7 + 2 z8 + z9 ) − ( z1 + 2 z 2 + z3 )
G y = ( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )
Summary: Gradient Operators
Positive: leading
Negative: trailing
Zero: in constant gray levels
∂x ∂y
∇ 2 f = 4 z 5 − ( z 2 + z 4 + z 6 + z8 )
Laplacian
• The idea:
r2 − σ 2 r2
∇ h = −
2
exp− 2
σ 2σ
4
where r2 = x2 + y2.
• Real life:
– The detected set of pixels very rarely describes a
complete edge due to effects from: noise, breaks
in the edge due to non-uniform illumination.
Edge Linking &
Boundary Detection
• Solution:
∇f ( x, y ) − ∇f ( x′, y′) ≤ T
• Problem:
– But: b = -xia + yi
equation of single line on ab plane
Global Processing via
the Hough Transform
Global Processing via
the Hough Transform
• A line in the (x,y) plane passes through
several points of interest and has a set of
specific (a,b) values.
x cosθ + y sin θ = ρ
Global Processing via
the Hough Transform
• Hough transform is applicable to any
function of the form g(v,c) = 0.
– v: vector of coordinates, c: coefficients.
( x − c1 ) 2 + ( y − c2 ) 2 = c32
Morphology
• Morphology is a branch of biology , deals with form
and structure of animals and plants
• Structuring element
1 1 1
• Output image 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0 0 1
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0 0 1 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0 0 1 0 0
Example for Erosion
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 0 0 0 0 1 0 0 0
Erosion
• Erosion is the set of all points in the image ,
where the structuring element “ fits into”
• Structuring element
1 1 1
• Output image 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1 1 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1 1 1 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1 1 1 1 1
Example for Dilation
• Input image 1 0 0 0 1 1 1 0 1 1
• Structuring element
1 1 1
• Output image 1 0 1 1 1 1 1 1
Dilation
• Dilation is the set of all points in the image ,
where the structuring element “touches” the
foreground
• Consider each pixel in the input image
- if the structuring element touches the foreground
image, write a “1” at the origin of the structuring
element
Dilation & Erosion
• Basic definitions:
Complement of A: Ac = {x|x∉A}
A ⊕ B = {x | ( Bˆ ) x ∩ A ≠ ∅}
Dilation & Erosion
• Dilation:
A ⊕ B = {x | [( Bˆ ) x ∩ A] ⊆ A}
In general:
( A B)c = Ac ⊕ Bˆ
Morphological Image Processing
Morphological Image Processing
Thresholding
• Foundation:
Thresholding
• In A: light objects in dark background
1 if f ( x, y ) > T (objects)
g ( x, y ) =
0 if f ( x, y ) ≤ T (background)
Thresholding
• Thresholding can be viewed as an operation
that involves tests against a function T of
the form:
T = T [ x, y, p ( x, y ), f ( x, y )]
where p(x,y) denotes
some local property of this point.
Thresholding
• If T is constant applicable over whole image
global thresholding
– Seed selection
– Selection of suitable properties for including
points in the various regions
• Descriptors
• Local vs. general criteria
Region Splitting and Merging
• Subdivide an image initially into a set of
arbitrary, disjointed regions and then merge
and/or split the regions in an attempt to
satisfy the conditions of region-oriented
segmentation.
• Quadtree-based algorithm
Region Splitting and Merging
• Procedure:
• Before flooding.
• To prevent water from spilling through the image
borders, we consider that the image is surrounded
by dams of height greater than the maximum image
intensity.
Morphological Watersheds (cont.)
Short dam
• Further flooding.
• The water from the left basin overflowed into the
right basin.
• A short dam is constructed to prevent water from
merging.
Morphological Watersheds (cont.)
• Further flooding.
• The effect is more pronounced.
• The first dam is now longer.
• New dams are created.
Morphological Watersheds (cont.)
Cn-1(M1) Cn-1(M2) q
Watersheds Watersheds
on the image
Morphological Watersheds (cont.)