L21 ImageSegmentation 1
L21 ImageSegmentation 1
Anoop M. Namboodiri
Biometrics and Secure ID Lab, CVIT,
IIIT Hyderabad
Three “Urges” on seeing a Picture*
1. To group proximate and similar parts of the image into
meaningful “regions”.
Called segmentation in computer vision.
2. To connect to memory to recollect previously seen
“objects”.
Called recognition in computer vision.
3. To measure quantitative aspects such as number and sizes
of objects, distances to/between them, etc.
Called reconstruction in computer vision.
*Jitendra Malik; Mysore Park, Dec. 2011
Urge to Group
3000
2500
Pixel count
2000
1500
T = 125
1000
500
0
0 50 100 150 200 250 300
Gray-level
Grayscale Image Histogram
Thresholded Image
2. Segment the image using T. Compute the mean gray values of the
two regions, µ1 and µ2
• Multi-spectral Thresholding
• In color images, one could use different thresholds for each of
the color channels
One might set all the background pixels to black, while leave the
foreground at the original value so that the information is not lost.
Multiple Thresholds
1000
900
800
97 170
700
600
500
400
300
200
100
0
0 50 100 150 200 250 300
Histogram
Original Thresholded
Multi-spectral Thresholding
1500
1000
500
140
0
0 50 100 150 200 250 300
1600
1400
1200
1000
800
600
150
400
200
0
0 50 100 150 200 250 300
0002
Original 0081
0061
Thresholded
0041
0021
130
0001
008
006
004
002
0
003 052 002 051 001 05 0
Histograms
Adaptive Thresholding
• Adaptive thresholding changes the threshold dynamically
over the image. This can accommodate strong illumination
gradients and shadows
http://www.dai.ed.ac.uk/HIPR2
Adaptive Thresholding
• Set the threshold as mean of pixels (gray values) in a
neighborhood (say 7x7)
C.K. Chow and T. Kaneko Automatic Boundary Detection of the Left Ventricle
from Cineangiograms, Comp. Biomed. Res.(5), 1972, pp. 388-410.
Adaptive Thresholding
Chow & Kaneko Thresholding:
• 𝑃! 𝑘 is probability of 𝐶! occurring
(
𝑃# 𝑘 = * 𝑝% , 𝑘 = 0,1,2, … , 𝑘
*+# %&'
𝑃" 𝑘 = * 𝑝% = 1 − 𝑃# 𝑘 , 𝑘 = 0,1,2, … , 𝑘
%&()#
∑(%&' 𝑖 𝑝% ∑*+#
%&()# 𝑖 𝑝%
𝑚# 𝑘 = 𝑚" 𝑘 =
𝑃# 𝑘 𝑃" 𝑘
Otsu’s Method
T = 181
Otsu’s Method
Handling Noise
Otsu’s method: Main Limitation
Filtering out Shadows: Homomorphic Filtering
• One can also think of the image containing a high-frequency reflectance
component and a low-frequency illumination component.
𝑓 𝑥, 𝑦 = 𝑖 𝑥, 𝑦 . 𝑟(𝑥, 𝑦)
Homomorphic Filtering
• Separate illumination (low frequency) and reflectance (high
frequency) components and remove the low frequencies to
suppress the effects of illumination.
• Circular symmetric filter in the frequency domain:
𝐻(𝑢, 𝑣)
𝛾,
𝛾*
𝐷(𝑢, 𝑣)
Homomorphic Filtering
Optimal Thresholding
• The graylevel histogram is approximated using a mixture of two
gaussian distributions and set the threshold to minimize the
segmentation error
3500
3000
2500
2000
1500
1000
500
0
20 40 60 80 100 120 140 160 180 200 220
(#$%' )'
! .
• Bkg: 𝑁 𝜇" , 𝜎" = , 𝑒 '(' '
' "-
0.035
0.03
k=2
0.025
0.02
0.015
0.01
0.005
0
0 50 100 150 200 250