Ab Dip 8 Segmentation Edge
Ab Dip 8 Segmentation Edge
Detection Of Discontinuities
Are based on detecting sharp changes in intensity in
neighbouring pixels
Discontinuities are
Edges
Intensity changes abruptly from current pixel to next pixels
along horizontal/ vertical/diagonal lines
Connected set of edge pixels belong to edge
Lines
Intensity of background on either side of the edge pixel is either
higher or lower than edge pixels
Isolated points
Intensity changes abruptly from current pixel to next pixel
Line whose length and width is 1 pixel
Detection of isolated points using Laplacian
Laplacian mask,wk
1 1 1
1 -8 1
Center pixel of filtered image, R(x, y)
1 1 1 If |R(x,y)| >= T then g(x,y) = 255
else g(x,y) = 0
For T = 15
image,gk Filtered image
4 4 4 4 4 4 4 4 4
3 10 1 3 -54 1 3 255 1
4 1 5 4 1 5 4 1 5
Isolated point
• Binary image
X-ray image of Result of point
• Threshold at 90%
a turbine blade detection of the highest
intensity
Edge Detection using gradient operators
The gradient of an image f(x,y) at location (x,y) is defined as the
vector:
g x fx
f f
g y y
The magnitude of this vector: f mag(f ) g g 2
x
2
y
1
2
gx
f f
g x f ( x 1) f ( x) g y f ( y 1) f ( y )
x y
Gradient Vector
gy
f mag(f ) g g
2
x
2
y
1
2
( x, y ) tan
1
gx
Points in the direction of the greatest rate of change
intensity at location (x,y)
Magnitude is the value of rate of change in the
direction of gradient vector
Direction is measured with respect to vertical axis
Direction of gradient vector is also called edge normal
Gradient angle
Gradient angle
1
f 2
f
2 2
x y
z1 z2 z3 -1 -2 -1 -1 0 1
z4 z5 z6 0 0 0 -2 0 2
z7 z8 z9 1 2 1 -1 0 1
g x z 7 2 z 8 z 9 z1 2 z 2 z 3
g y z 3 2 z 6 z 9 z1 2 z 4 z 7
M ( x, y ) g x g y
Sobel Operators for gradient vector
g x z 7 2 z 8 z 9 z1 2 z 2 z 3
g y z 3 2 z 6 z 9 z1 2 z 4 z 7
image Vertical mask, gy Horizontal mask, gx
10 10 50 10 10
-1 0 1 -1 -2 -1
10 10 50 10 10 0 0 0
-2 0 2
10 10 50 10 10 -1 0 1 1 2 1
10 10 50 10 10
gx gy+gx
gy
10 10 50 10 10 10 10 50 10 10 10 10 50 10 10
10 160 0 160 10 10 0 0 0 10 10 160 0 160 10
+ =
10 160 0 160 10 10 0 0 0 10 10 160 0 160 10
10 10 50 10 10 10 10 50 10 10 10 10 50 10 10
Edge detection
Edge detection
horizontal edges using sobel mask
Edge detection
horizontal edges using sobel mask
vertical edges using sobel mask Addition of vertical and horizontal edges
Edge Detection
Edge Detection
Edges & Derivatives
Edges & Derivatives
1st derivative
denotes the location
of edge
Edges & Derivatives
1st derivative
denotes the location
of edge
2nd derivative shows
location of edge and
its direction
Derivatives & Noise
Derivative based edge detectors are sensitive to noise
Image
with noise 1st derivative 2nd derivative
Image Image
with noise 1st derivative 2nd derivative with noise 1st derivative 2nd derivative
Std=0
Std=0
Std=1
Std=0
Std=0.1 Std=10
Derivatives & Noise
Derivative based edge detectors are extremely sensitive to
noise
Image Image
with noise 1st derivative 2nd derivative with noise 1st derivative 2nd derivative
Std=1
Std=0
Std=0.1 Std=10
Edge Detection of Noisy Images
M ( x, y ) M ( x0 , y0 ) E , E : a nonnegative threshold
f M ( x, y) g x2 g y2
g x x gy
f f ( x, y ) tan
1
g y gx
y
• Sxy is a set of neighboring pixels of (x,y)
• Compute M(a,b) for each pixel of Sxy
(a,b)
(x,y)
Edge Linking
1 1 0 1 0 1
1 0 0 0 1 0
0 0 0 1 1 1
Edge Linking
1 1 0 1 0 1
1 0 0 0 1 0
0 0 0 1 1 1
1 1 1 1 1 1
k=2 1 0 0 0 1 0
0 0 0 1 1 1
Edge detection
Sobel filter
Local Segmentation
Deals with segmenting sub-images which are small
windows on a whole image
The number of pixels available to local segmentation is
much lower than global segmentation
Global Segmentation
is concerned with segmenting a whole image
deals mostly with segments consisting of a relatively large
number of pixels
This makes estimated parameter values for global segments
more robust
Approaches for segmentation
1. Region approach
Regions in an image are a group of connected pixels with
similar properties
Each pixel is assigned to a particular object or region
2. Boundary approach
locates boundaries that exist between the regions.
3. Edge approach
edges are identified first, and then they are linked
together to form required boundaries
Intensity Thresholding for segmentation
• Based on histogram
• Depends on width and depth of the valleys
separating the modes in histogram
• Valleys depend on
o Separation between peaks
o Relative size of object against background
o Noise contents
o Uniformity of the illumination source
mode
Thresholding
histograms
For thresholding,
a if f(x, y) T2
1 if f ( x, y) T b if T f(x, y) T
g ( x, y ) g(x, y) 1 2
0 if f ( x, y) T c if f(x, y) T1
Effect of noise in image thresholding
Gaussian noise, std = 0
Image
histograms
Threshold can be
set as two modes
can be separated
easily
Effect of noise in image thresholding
Gaussian noise, std = 0 Gaussian noise, std 10
Image
histograms
Image
histograms
Image
Role of illumination in image thresholding
Image
histog
rams
L 1
p
k
P1 (k ) pi P2 (k ) i 1 P1 (k )
i k 1
i 0
1 L 1
k
1
m1 (k )
P1 (k ) i 0
ip i m2 (k ) ipi
P2 (k ) i k 1
m1(1) = (25/6){(0×4/25) +(1×2/25)} m2(1) = (25/19){(2×8/25) +(3×1/25)
= (1/3) +(5×5/25)+(6×2/25)
+(7×3/25)}
= (77/19)
Optimum global thresholding: Otsu’s method
p = {4,2,8,1,0, 5,2,3}/25
Average intensity upto k
k
m( k ) ip
i 0
i
L 1
mG ip i
Global mean of entire
image
i 0
L 1
Global variance G2 (i mG ) 2 pi
i 0
Between the
class variance
(k ) P1 (k ) P2 (k )(m1 m2 )
2
B
2
Metric for B2
2
thresholding G
Noisy image
Image smoothing to improve global thresholding
Histogram After threshoding
Noisy image
Image after
averaging
by 5x5 filter
Region based segmentation
What is a Region
• A group of connected pixels with similar
properties
• Connected pixels correspond to objects in a scene
• Region of connected pixels correspond to objects
or parts of an object
Region-based Approach
Predicate is a condition to define region
Pixels satisfying the condition of predicate are marked
Group of these pixels defines an object
Predicates are based on
1. Value similarity
-Gray value differences
-Gray value variance
2. Spatial Proximity
Euclidean distance
Example: Region Based Segmentation
• Region
• Growing
• Split
• Merge
• Split and Merge
Region Growing
• Region growing requires a seed to begin with
• Ideally, the seed would be a region, but it could be a single pixel
• A new segment is grown from the seed
• Resultant segment is then removed from the process
• A new seed is chosen from the remaining pixels
• This continues until all pixels have been allocated to a segment
• The resulting segmentation could
• depend on the initial seed chosen
• order in which neighboring pixels are examined
Region Growing
• Region growing offers several advantages over
conventional segmentation techniques
• The borders of regions found by region growing are
perfectly thin and connected
• The algorithm is also very stable with respect to noise
• based on predicate
• threshold
• constant
• variance
• color etc…
• first step is to choose a seed
Region growing Predicate: Example
Predicate: Difference between two consequtive pixels <= 5
10 10 10 10 10 10 10
10 10 10 10 10 10 10
10 10 10 69 70 10 10
10 10 10 69 70 10 10
59 10 60 64 59 56 60 59 10 60 64 59 56 60
10 59 10 60 70 10 62 10 59 10 60 70 10 62
10 60 59 65 67 10 65 10 60 59 65 67 10 65
10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10
Quadtre
e
R0
R1
R2 R3
Region Splitting: Example
Quadtre
e
R0
R1
R0
R1
R2 R3
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15
17 18 17 18 9 8 3 4
17 18 18 17 9 8 3 4
18 17 18 17 12 11 21 41
17 18 17 18 11 11 10 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
Results – Region Split
Splitting Ex: Condition: 𝜎 > 10 & 0 < 𝑚 < 125
σ is
variance
and m is Min size
mean 32x32
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15 Minimum
size 2x2
17 18 17 18 9 8 3 4
17 18 18 17 9 8 3 4
18 17 18 17 12 11 21 21
17 18 17 18 11 11 20 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
• Divide image into subimage of minimum size
Region Merge Example
• Divide image into subimage of minimum size
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15
Minimum
17 18 17 18 9 8 3 4 size 2x2
17 18 18 17 9 8 3 4
18 17 18 17 12 11 21 21
17 18 17 18 11 11 20 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
• Merge subimages if neighboring images satisfy the condition
Region Merge Example
• Divide image into subimage of minimum size
• Merge subimages if neighboring images satisfy the condition
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15
17 18 17 18 9 8 3 4
17 18 18 17 9 8 3 4
18 17 18 17 12 11 21 21
17 18 17 18 11 11 20 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
Split and Merge
• Split image
• Merge segments with similar predicate
Split and Merge: Example
Image after splitting
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15
17 18 17 18 9 8 3 4
17 18 18 17 9 8 3 4
18 17 18 17 10 9 21 21
17 18 17 18 8 10 20 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
Split and Merge: Example
Image after splitting followed by merging
10 11 10 11 15 16 15 15
10 10 10 11 15 15 16 15
11 11 10 11 16 15 15 15
11 10 11 10 16 15 16 15
17 18 17 18 9 8 3 4
17 18 18 17 9 8 3 4
18 17 18 17 10 9 21 21
17 18 17 18 8 10 20 20
Condition:
Pixel difference between two consecutive pixels (Separation Threshold) <=2
Split and Merge
Split
Original image