Professional Documents
Culture Documents
com
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Point Detection
Chapter 10
Image Segmentation
Line Detection
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Edge Detection
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Local Processing
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Foundation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Region
Growing
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
Chapter 10
Image Segmentation
b c
Image Segmentation
Image Segmentation
Æ Goal: Segmentation subdivides an image into its
constituent regions or objects that have similar
features according to a set of predefined criteria
Æ features?
Æ intensity
Æ histogram
Æ mean, variance
Æ energy
Æ texture
Æ ….
Æ It depends on applications or the problems to
solve
segmentation
enhancement Image
Preprocessing Analysis feature extraction,
restoration, etc
etc
w1 w2 w3
w4 w5 w6
w7 w8 w9
mask
Point Detection
Æ We say that a (isolated) point has been detected at the location on
which the mask is centered if
|R| > T, R: spatial filtering result, T: nonnegative threshold
-1 -1 -1
-1 8 -1
-1 -1 -1
Point Detection
Æ X-ray image of a jet-engine turbine blade with a porosity
in the upper, right quadrant of the image
Æ The threshold T is set to 90% of the highest absolute
pixel value of the image in Fig. 10.2(c)
Line Detection
Line Detection
Æ A binary image of a wire-bond
mask for an electronic circuit
Æ We are interested in finding all
the lines that are one pixel thick
and are oriented at -45°
Æ The line in the top, left quadrant
is not detected because it is not
one pixel thick
Edge Detection
Æ Edge detection is the most common approach for
detecting meaningful discontinuities
Æ Edge
Æ 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 is a
more global idea
Æ A reasonable definition of “edge” requires the ability to measure
gray level(intensity) transitions in a meaningful way
Æ An ideal edge has the properties of the model shown in
Fig. 10.5(a)
Æ An ideal edge according to this model is a set of
connected pixels, each of which is located at an
orthogonal step transition in gray level
Edge Detection
Æ In practice, optics, sampling, and other image acquisition
imperfections yeild edges that are blurred
Æ As a result, edges are more closely modeled as a “ramp”-like profile
Æ The degree of blurring is determined by factors such as the quality of
the image acquisition system, the sampling rate, and illumination
conditions
Æ An edge point is any point contained in the ramp, and an edge would
be a set of such points that are connected
Æ The “thickness” of the edge is determined by the length of the ramp
Æ Blurred edges tend to be thick and sharp edges tend to be thin
Edge Detection
Æ The magnitude of the first derivative can be used to detect the
presence of an edge
Æ The sign of the second derivative can be used to determine whether
an edge pixel lies on the dark or light side of an edge
Æ An imaginary straight line joining the extreme positive and negative
values of the second derivative would cross zero near the midpoint of
the edge (zero-crossing property)
Edge Detection
Æ Derivative is very
sensitive to noise
Æ Image smoothing is
needed
Edge Detection
Æ We define a point in an image as being an edge point if
its two-dimensional first-order derivative is greater than a
specified threshold
Æ A set of such points that are connected according to a
predefined criterion of connectedness is defined as an
edge
Æ The term edge segment generally is used if the edge is
short in relation to the dimensions of the image
Æ A key problem in segmentation is to assemble edge
segments into longer edges
Gradient Operators
Æ First-order derivatives of a digital image are based on various
approximations of the 2-D gradient
Æ The gradient is defined as the two-dimensional column vector
Æ The magnitude of the gradient vector often is referred to as the
gradient, too
⎡ ∂f ⎤ ∇f = mag(∇f ) = [G x2 + GY2 ]1 / 2
⎡G x ⎤ ⎢ ∂x ⎥
∇f = ⎢ ⎥ = ⎢ ∂f ⎥
1/ 2
G ⎡⎛ ∂f ⎞ 2 ⎛ ∂f ⎞ 2 ⎤
⎣ y ⎦ ⎢ ⎥
= ⎢⎜ ⎟ + ⎜⎜ ⎟⎟ ⎥
⎢⎣ ∂ y ⎥⎦
⎢⎣⎝ ∂x ⎠ ⎝ ∂y ⎠ ⎥⎦
∇f ≈ G x + G y
Gradient Operators
Æ The direction of the gradient vector
⎛ Gy ⎞
α ( x, y ) = tan −1 ⎜⎜ ⎟⎟
G
⎝ x⎠
The Gradient
Æ Robert cross-gradient operators
G x = ( z 9 − z 5 ) and G y = ( z 8 − z 6 )
[
∇f = ( z 9 − z 5 ) 2 + ( z 8 − z 6 ) 2 ] 1/ 2
∇f ≈ z 9 − z 5 + z8 − z 6
Æ Sobel Operator
∇f ≈ ( z7 + 2 z8 + z9 ) − ( z1 + 2 z2 + z3 )
+ ( z 3 + 2 z 6 + z 9 ) − ( z1 + 2 z 4 + z 7 )
Gradient Operator
⎡G x ⎤ ⎡( z 6 − z 5 ) ⎤
z1 z2 z3 ∇f = ⎢ ⎥ ≅ ⎢ ⎥
z4 z5 z6
G ( z
⎣ y⎦ ⎣ 8 5 ⎦ − z )
z7 z8 z9
[
∇ f ≅ ( z 6 − z 5 ) 2 + ( z8 − z 5 ) 2 ]
1/ 2
≅ | z 6 − z 5 | + | z8 − z 5 |
Gradient Operator
ÆRoberts cross-gradient
⎡G x ⎤ ⎡( z 9 − z 5 ) ⎤
z1 z2 z3 ∇f = ⎢ ⎥ ≅ ⎢ ⎥
G
⎣ ⎦y ⎣ ( z 8 − z 6 ) ⎦
z4 z5 z6
z7 z8 z9
[
∇ f ≅ ( z 9 − z 5 ) + ( z8 − z 6 )
2
]
2 1/ 2
≅ | z 9 − z 5 | + | z8 − z 6 |
Gradient Operator
ÆRobert cross-gradient filter masks
-1 0 ⎡G x ⎤ ⎡( z 9 − z 5 ) ⎤
∇f = ⎢ ⎥ ≅ ⎢ ⎥
G ( z
⎣ y⎦ ⎣ 8 6 ⎦ − z )
0 1
0 -1
[
∇ f ≅ ( z 9 − z 5 ) + ( z8 − z 6 )
2
]
2 1/ 2
≅ | z 9 − z 5 | + | z8 − z 6 |
1 0
Prewitt Operator
z1 z2 z3 -1 0 1 -1 -1 -1
z4 z5 z6 -1 0 1 0 0 0
z7 z8 z9 -1 0 1 1 1 1
Gx Gy
⎡Gx ⎤ ⎡( z3 + z6 + z9 ) − ( z1 + z 4 + z7 )⎤
∇f = ⎢ ⎥ ≅ ⎢ ⎥
G ( z
⎣ y⎦ ⎣ 7 8 9+ z + z ) − ( z1 + z 2 + z )
3 ⎦
∇f ≅ | G x | + | G y |
Sobel Operator
z1 z2 z3 -1 0 1 -1 -2 -1
z4 z5 z6 -2 0 2 0 0 0
z7 z8 z9 -1 0 1 1 2 1
Gx Gy
⎡Gx ⎤ ⎡( z3 + 2 z6 + z9 ) − ( z1 + 2 z 4 + z7 )⎤
∇f = ⎢ ⎥ ≅ ⎢ ⎥
G
⎣ y⎦ ⎣ 7( z + 2 z 8 + z 9 ) − ( z1 + 2 z 2 + z )
3 ⎦
∇f ≅ | G x | + | G y |
Examples
Diagonal Edge
Laplacian
Æ The Laplacian is a second-order derivative
∂2 f ∂2 f
∇ f = 2 + 2
2
∂x ∂y
Æ Digital approximation
∇ 2 f = 4 z 5 − ( z 2 + z 4 + z 6 + z8 )
∇ 2 f = 8 z5 − ( z1 + z 2 + z3 + z 4 + z6 + z7 + z8 + z9 )
0 -1 0 -1 -1 -1
-1 4 -1 -1 8 -1
0 -1 0 -1 -1 -1
Laplacian
Æ TheLaplacian generally is not used in its original
form for edge detection for several reasons
Æ It is unacceptably sensitive to noise
Æ The magnitude of the Laplacian produces double
edges
Æ It is unable to detect edge direction
Æ The role of the Laplacian in segmentation
Æ finding the location of edge using its zero crossing
property
Æ judging whether a pixel is on the dark or light side of
an edge
Laplacian of Gaussian
ÆThe Laplacian is combined with smoothing
to find edges
Æ Gaussian function
⎛ r2 ⎞
h(r ) = − exp⎜⎜ − ⎟
2 ⎟ r 2 = x2 + y2
⎝ 2σ ⎠
Æ LoG(Laplacian of Gaussian) : Mexican hat
⎡r2 −σ 2 ⎤ ⎛ r2 ⎞
∇ h( r ) = − ⎢ ⎥ exp⎜⎜ − ⎟
2
2 ⎟
⎣ σ 4
⎦ ⎝ 2σ ⎠
Laplacian of Gaussian
Æ Gaussian function with a
standard deviation of five pixels
Æ 27x27 spatial smoothing
mask
Æ The mask was obtained by
sampling the Gaussian function
at equal intervals
Æ After smoothing we apply the
Laplacian mask
Æ Comparison
Æ The edges in the zero-crossing
image are thinner than the
gradient edges
Æ The edges determined by zero
crossings form numerous closed
loops (spaghetti effect:
drawback)
Æ The computation of zero
crossings presents a challenge
Edge Linking
Æ Edge detection Æ edge linking
Æ One of the simplest approaches for linking edge points is
to analyze the characteristics of pixels in a small
neighborhood
Æ All points that are similar according to a set of predefined
criteria are linked
Æ Two principal properties
Æ The strength of the gradient
Æ The direction of the gradient vector
∇f ( x, y ) − ∇f ( x0 , y0 ) ≤ E
α ( x, y ) − α ( x0 , y0 ) ≤ A
Æ The direction of the edge at (x,y) is perpendicular to the
direction of the gradient vector at that point
Edge Linking
Æ Given n points in an image, suppose that we want to find
subsets of these points that lie on straight lines
Æ One possible solution is to first find all lines determined
by ebery pair of points,
Æ then find all subsets of points that are close to particular
lines
Æ It involves finding n(n-1)/2 lines and then performing n x
n(n-1)/2 comparisons !
Æ Hough transform[1962]
Hough Transform[1962]
Æ Parameter space consideration
Æ Infinitely many lines pass through a point are represented
a line in the parameter space(ab-plane)
yi = axi + b b = − xi a + yi
Æ When the line associated with ( xi , yi ) intersects the line
associated with ( x j , y j ) at (a' , b' ), a' is the slope and
b' the intercept of the line determined by the two points
Hough transform
Æ The Hough transform subdivides the parameter space into so-called
accumulator cells
Æ These cells are set to zero
Æ For every point (xk, yk) , we let the parameter a equal each of the
allowed subdivision values on the a-axis and solve for the
corresponding b
Æ The resulting b’s are then rounded off to the nearest allowed value in
the b-axis
Æ If a choice of ap results in solution bq, we let A(p,q)=A(p,q)+1
Æ At the end, a value of Q in A(i,j) corresponds to Q points in the xy-
plane lying on the line y=aix+bj
b j = − xk ai + yk
Hough transform
Æ Ifthere are K increments in the a axis, K computation is
needed for every point Æ nK computation for n image
points (linear)
Æ There is a problem when the slope approaches infinity
(vertical line)
Hough transform
Æ One solution: to use the following representation
x cosθ + y sin θ = ρ
Æ The loci are sinusoidal curves in the ρθ -plane
Æ Q collinear points lying on a line x cos θ j + y sin θ j = ρ i
yield Q sinusoidal curves that intersect at ( ρ i , θ j )
Hough transform
Æ Aerial infrared image
Æ Thresholded gradient image using Sobel operators
Æ Pixels are linked
Æ they belongs to one of the three accumulator cells with highest count
Æ No gaps were longer than five pixels
Thresholding
Æ Global Thresholding
Æ Apply the same threshold to the whole image
Æ Local Thresholding
Æ The threshold depends on local property such as local average
Æ Dynamic(adaptive) thresholding
Æ The threshold depends on the spatial coordinates
Æ The problem is how to select the threshold automatically!
Global Thresholding
Æ It
is successful in highly controlled environment
Æ One of the areas is in industrial inspection application,
where control of the illumination usually is feasible
Global Thresholding
Æ Automatic threshold selection
1. Select an initial estimate for T
2. Segment the image using T,
which produce two groups, G1, G2
3. Compute the average gray level
values μ1 and μ 2 for the pixels in
regions G1 and G2
4. Compute a new threshold value:
1
T= ( μ1 + μ 2 )
2
5. Repeat step 2 through 4 until the
difference in T in successive
iterations is smaller than a
predefined parameter T0
Basic Adaptive Thresholding
Æ divide the image into subimages, then thresholding
0 1 0 Labeling
∇f = mag (∇f ) ≅| Gx | + | G y |
ÆLaplacian:
∂2 f ∂2 f
∇ f = 2 + 2
2
∂x ∂y
Segmentation by local thresholding
Region-Based Segmentation
Æ Segmentation is a process that partitions R into n
subregions, R1, R2,..., Rn, such that
n
(a) U Ri = R (complete)
i =1
(b) Ri is a connected region
(c) Ri I R j = φ for all i and j , i ≠ j (disjoint)
(d ) P( Ri ) = TRUE for all i
(e) P( Ri U R j ) = FALSE for i ≠ j
Æ P( Ri ) is a logical predicate which represents criterion
that segments the regions
Region Growing
Æ Region growing is a procedure that groups pixels or subregions into
larger regions based on predefined criteria
Æ The basic approach 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
Æ Selections of ‘Seed’ point and similarity criteria are the primary
problem
Æ Another problem in region growing is the formulation of a stopping
rule
Æ ex) P: diff<3 P: diff<8
0 0 5 6 7 a a b b b a a a a a
1 1 5 8 7 a a b b b a a a a a
0 1 6 7 7 a a b b b a a a a a
2 0 7 6 6 a a b b b a a a a a
0 1 5 6 5 a a b b b a a a a a
Region Growing
Region Splitting and Merging
Æ An alternative is to subdivide an image initially into a set
of arbitrary, disjointed regions and then merge and/or split
the regions to satisfy the conditions
Æ Algorithm
(1) We start with the entire region R
(2) If P(Ri)=FALSE, split into four disjoint quadrants
(3) Merge any adjacent regions Rj , Rk for which P(Rj U Rk)=TRUE
(4) Stop when no further merging or splitting is possible
1-Segmentation (Cont.)
2-Color Image Processing
Region-Oriented Segmentation
• Basic formulation
is a connected region
Region Growing by Pixel Aggregation
• Region growing is a procedure that groups
pixels or sub-regions into larger regions.
• Simplest approach is pixel aggregation
• Pixel aggregation needs a seed point
Region Growing Problems
• Selecting initial seed
• Selecting suitable properties for including
points
– Example: In military applications using infra red
images, the target of interest is slightly hotter than
its environment
Example : Weld defects
Region Splitting and Merging
• Divide the image into a set arbitrary disjoint
regions.
• Merge/split the regions
Quad-Tree
The Use of Motion in Segmentation
• Compare two image taken at time t1 and t2
pixel by pixel (difference image)
• Non-zero parts of the difference image
corresponds to the non-stationary objects
CS-293
Compiled by:
Siddharth Dhakad
Chirag Sethi
Nisarg Shah
Problem Definition
• Image processing is a field of signal
processing in which input and output signals
are both images (2D matrices).
• Edge Detection:
– Sobel’s algorithm
– Canny’s algorithm
• Circle Detection:
– Hough Transform
• Line Detection:
– Hough Transform
• Corner Detection:
– Trajkovic’s 8-neighbour algorithm
Solution Design &
Implementation
Image
• Grayscale
• Crop
Picture Class
FILE
2D
SHOW
ARRAY
IMAGE
IMAGE
EDIT
GRAYSCALE
PIXELS
CROP
Edge Detection
• Edge detection is a terminology which aim at
identifying points in a digital image at which the
image brightness changes sharply or more
formally has discontinuities.
Input Image
Gray-Scaled Image
Masking
Threshold
Edge Detected
Canny Edge Detector
Input Image Gray-Scaled Image
Detected Threshold
Path Traversal
Lines/Circles
Input Image
Original Image
Cornerness of
each pixel
Threshold
• Automatic:
– By experimentation, we have found a
heuristic to select a suitable threshold for
any input image.
The Hard Part
• Selecting suitable threshold for any input
image
Our Output
Original Image Standard Output
Our Output
Original Image Standard Output
Our Output
Future Possibilities
• Generalized Curve Detection
• Higher Order Edge Detection
• Some more shape based feature
detection
• Optimizations in current algorithms
• Handling large size images
• Pattern recognition
• Face recognition
What we learnt
• Feature Extraction Algorithms
• Limitations of algorithms when applied to
real life problems
– Image Size
– Selecting Threshold
– Noise
• Handling Images
– Image types : RGB, ARGB, Raster, Vector
• Java/Swing
• Time Management
• Working as a team
COMS30121 | Department of Computer Science | University of Bristol
LECTURE 3:
EDGE DETECTION
AND BEYOND
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide1/15
Recap – Edge Detection by Filtering
• Detection of Edges
by using Edge-like
Æ
Filter Kernels
• Roberts, Kirsch,
Prewitt and Sobel Operators
• Estimation of
Gradients
• Considering Noise…
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide2/15
Second Derivative Methods
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide3/15
Laplacian Operator
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide4/15
Example of Laplacian Filtering
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide5/15
Laplacian of Gaussian (LoG)
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide6/15
Difference of Gaussian (DoG)
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide7/15
Scale in Image Processing
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide8/15
Scale Space
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide9/15
Diffusion as an Operator
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide10/15
Scale Space Generation via Diffusion
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide11/15
Advanced Diffusion Techniques
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide12/15
Canny Edge Detection
• Gaussian Smoothing
• Gradient Estimation
• Non-maximal Suppression
• Thresholding with Hysteresis
• Feature Synthesis
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide13/15
Approaches to Thresholding Edges
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide14/15
Outlook
Dr Tilo Burghardt | Image Processing & Computer Vision , COMS30121 | Dept of Computer Science, University of Bristol | L1 - Slide15/15