Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Segmentation:

Otsu’s method

Dr. Tushar Sandhan

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 1


Introduction
▪ Variance
o intraclass
o interclass

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 2


Introduction

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 3


Otsu’s thresholding
▪ Global: adaptive Otsu’s threshold
o exhaustively searches ∀ 𝑇 that minimizes intra-class variance
o min. intra-class var. is equivalent to max. inter-class var.

𝜎𝑟2 (𝑇) = 𝑃1 𝑇 𝜎12 𝑇 + 𝑃2 𝑇 𝜎22 𝑇

𝑇−1 𝐿−1

𝑃1 𝑇 = ෍ 𝑝 (𝑡) 𝑃2 𝑇 = ෍ 𝑝(𝑡)
𝑡=0 𝑡=𝑇

𝑇−1 𝐿−1
𝑡⋅𝑝 𝑡 𝑡⋅𝑝 𝑡
𝜇1 𝑇 = ෍ 𝜇2 𝑇 = ෍
𝑃1 𝑇 𝑃2 𝑇
𝑡=0 𝑡=𝑇

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 4


Otsu’s thresholding
▪ Global: adaptive Otsu’s threshold
o exhaustively searches ∀ 𝑇 that minimizes intra-class variance
o min. intra-class var. is equivalent to max. inter-class var.

𝜎𝑟2 (𝑇) = 𝑃1 𝑇 𝜎12 𝑇 + 𝑃2 𝑇 𝜎22 𝑇

𝑇−1 𝐿−1 𝑇−1 𝐿−1


𝑡⋅𝑝 𝑡 𝑡⋅𝑝 𝑡
𝑃1 𝑇 = ෍ 𝑝 (𝑡) 𝑃2 𝑇 = ෍ 𝑝(𝑡) 𝜇1 𝑇 = ෍ 𝜇2 𝑇 = ෍
𝑃1 𝑇 𝑃2 𝑇
𝑡=0 𝑡=𝑇 𝑡=0 𝑡=𝑇

𝜎 2 = 𝜎𝑒2 𝑇 + 𝜎𝑟2 𝑇 𝑇−1 2 𝐿−1 2


𝑡 − 𝜇1 𝑇 ⋅𝑝 𝑡 𝑡 − 𝜇2 𝑇 ⋅𝑝 𝑡
𝜎12 𝑇 = ෍ 𝜎22 𝑇 = ෍
𝑃1 𝑇 𝑃2 𝑇
𝑡=0 𝑡=𝑇
𝜎𝑒2 (𝑇) = 𝜎 2 − 𝜎𝑟2 𝑇

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 6


Otsu’s thresholding
▪ Global: adaptive Otsu’s threshold
o exhaustively searches ∀ 𝑇 that minimizes intra-class variance
o min. intra-class var. is equivalent to max. inter-class var.

𝜎𝑟2 (𝑇) = 𝑃1 𝑇 𝜎12 𝑇 + 𝑃2 𝑇 𝜎22 𝑇

𝑇−1 𝐿−1 𝑇−1 𝐿−1


𝑡⋅𝑝 𝑡 𝑡⋅𝑝 𝑡
𝑃1 𝑇 = ෍ 𝑝 (𝑡) 𝑃2 𝑇 = ෍ 𝑝(𝑡) 𝜇1 𝑇 = ෍ 𝜇2 𝑇 = ෍
𝑃1 𝑇 𝑃2 𝑇
𝑡=0 𝑡=𝑇 𝑡=0 𝑡=𝑇

𝑇−1 2 𝐿−1 2
𝑡 − 𝜇1 𝑇 ⋅𝑝 𝑡 𝑡 − 𝜇2 𝑇 ⋅𝑝 𝑡
𝜎𝑒2 (𝑇) = 𝜎 2 − 𝜎𝑟2 𝑇 𝜎12 𝑇 = ෍ 𝜎22 𝑇 = ෍
𝑃1 𝑇 𝑃2 𝑇
𝑡=0 𝑡=𝑇
2
𝜎𝑒2 (𝑇) = 𝑃1 𝑇 𝑃2 𝑇 𝜇1 𝑇 − 𝜇2 𝑇

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 7


Otsu’s thresholding
2
▪ Global: adaptive Otsu’s threshold 𝜎𝑒2 (𝑇) = 𝑃1 𝑇 𝑃2 𝑇 𝜇1 𝑇 − 𝜇2 𝑇

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 8


Otsu’s thresholding
▪ Variance variation 𝜎𝑒2 (𝑇) = 𝑃1 𝑇 𝑃2 𝑇 𝜇1 𝑇 − 𝜇2 𝑇
2

o inter-class var
maximization

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 9


Otsu’s thresholding
▪ Global: iterative adapting threshold: TH = 125

▪ Global: Otsu’s thresholding: TH = 125

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 10


Otsu’s thresholding
▪ Example
o microscopic image (polymer cells)

Input Hist Global: iterative adaptive TH Global: Otsu’s TH

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 11


Otsu’s thresholding
▪ Example
o noisy input as it is

Input Hist Global: Otsu’s TH

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 12


Otsu’s thresholding
▪ Example
o noisy input after minor smoothing

Input Hist Global: Otsu’s TH

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 13


Otsu’s thresholding
Input Hist Global: Otsu’s TH
▪ Example
o small object’s
noisy image
o smoothing
degrades the
performance
o what caused
the problem?
o how to solve
the problem?

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 14


Otsu’s thresholding
Input Hist Edge gradients with TH
▪ Example
o small object’s
noisy image
o edge masks

Edge masked input image

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 15


Otsu’s thresholding
▪ Example
o small object’s noisy image
o Otsu’s TH obtained via edge masked image but
that TH is applied on the original input image

Edge masked input image Hist Global: Otsu’s TH

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 16


Improving Otsu for underwater imaging
▪ SONAR
o Sound Navigation And Ranging

Underwater plank (by ECA group company) Stockholm sea image

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 17


Improving Otsu for underwater imaging
▪ SONAR
o Sound Navigation And Ranging

o area size of the background spots is < 30 pixels


o 𝑁30 : # contours to be found with an area of 30 pixels

X. Yuan et al. “An Improved Otsu Threshold Segmentation Method for Underwater SLAM Navigation”,
Sensors, 2016

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 18


Improving Otsu for underwater imaging

Input Local TH Otsu Underwater Otsu

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 19


Improving Otsu for underwater imaging
Input Local TH

Otsu Underwater Otsu

EE604: IMAGE PROCESSING sandhan@iitk.ac.in 20


❑ Global optimal

❑ Global Otsu’s method


▪ Input image histogram processing
▪ Noise handled via smoothing
▪ Small object issues handled via edge masks

Conclusion
Threshold the Otsu’s paper via Otsu’s method:
- Segmentation via
thresholding (Otsu)

EE604: IMAGE PROCESSING


21

You might also like