Professional Documents
Culture Documents
Sergi Pujades
• Aggregation / segmentation
▪ Graph cut
Filters
Problem: the noise
σ=1 σ=16
Noise in 1D (and consequences)
f(x)
f’(x)
Noise in 2D (and consequences)
• Problem:
▪ noise and high frequencies
▪ derivative computations get problematic
• Solution:
▪ remove the hight frequencies
(𝑓 ∗ 𝑔)(𝑚) = ∑𝑛 𝑓(𝑛)𝑔(𝑚 − 𝑛)
Solution: first smooth
(low-band Gaussian filter)
𝑔∗𝑓
𝜕
𝑔∗𝑓
𝜕𝑥
Theorem of the derivatives of a convolution
𝜕𝑔
𝜕𝑥
𝜕 𝜕𝑔
𝑔∗𝑓= ∗𝑓
𝜕𝑥 𝜕𝑥
Noise in 2D
Noyau
lissage
Benefits of the smoothing
2D convolutions
• Continuous case:
• Discrete case:
(𝑚 ∗ 𝑓)(𝑥)
𝑤
= ∑𝑖=−𝑤 𝑚(𝑖)𝑓(𝑥 − 𝑖)
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
1 1 1 1
0 0 0 90 90 90 90 90 0 0
9 1 1 1
0 0 0 90 0 90 90 90 0 0
1 1 1
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0
𝐻[𝑢, 𝑣]
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝐹[𝑥, 𝑦]
Mean filter
Smoothing with a 2D Gaussian filter
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 90 90 90 90 90 0 0
0 0 0 90 90 90 90 90 0 0
1 1 2 1
0 0 0 90 90 90 90 90 0 0
16 2 4 2
0 0 0 90 0 90 90 90 0 0
1 2 1
0 0 0 90 90 90 90 90 0 0
0 0 0 0 0 0 0 0 0 0 𝐻[𝑢, 𝑣]
0 0 90 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
𝐹[𝑥, 𝑦]
1 −𝑢 + 𝑣 2 2
h(𝑢, 𝑣) = 𝑒 𝜎 2
2𝜋𝜎 2
Gaussian filter
Edge detection
Edge detection
Why do we care about edges?
Depth discontinuity
Illumination discontinuity
Actual exemples
Ideal edge
f(x) = edge
f’(x)
f’’(x)
Real edges
Real edges
• Position
• Intensity (contrast)
quantity of change on the edge
• Compact description:
▪ Normal with Intensity as vector length (2D)
▪ Position (2D)
Image as a 3D surface
Gradient image
[ 𝜕𝑥 𝜕𝑦 ]
𝜕𝑓 𝜕𝑓
𝛻𝑓 = ,
( 𝜕𝑥 ) ( 𝜕𝑦 )
2 2
( 𝜕𝑥 𝜕𝑦 )
𝜕𝑓 𝜕𝑓 𝜕𝑓 𝜕𝑓
▪ Direction: 𝜃 = 𝑡𝑎𝑛−1 / Intensity: 𝛻𝑓 = +
[ 𝜕𝑥 ] [ 𝜕𝑦 ] [ 𝜕𝑥 𝜕𝑦 ]
𝜕𝑓 𝜕𝑓 𝜕𝑓 𝜕𝑓
𝛻𝑓 = ,0 𝛻𝑓 = 0, 𝛻𝑓 = ,
Geometric interpretation
Edge:
"high variation in the signal”
Look for:
“high value in the first derivative”
Finite differences (1D)
1 2 1
Sx[u,v] ∝ 2 4 2 * -1 0 1
1 2 1
1 2 1 -1
Sy[u,v] ∝ 2 4 2 * 0
1 2 1 1
• Can be generalized for arbitrary size smoothing kernels
Influence of the scale of the filtering
kernel
It affects the derivatives computation, and the scale (and semantics) of the
detected contours
Laplace operator (or Laplacian) Discrete
approximation
2 2
• In 2D 2 𝜕 𝑓 𝜕 𝑓 0 1 0
𝛻 𝑓= 2 + 2
▪ scalar magnitude 𝜕𝑥 𝜕𝑦 1 -4 1
▪ invariant to rotation 0 1 0
• Find the maximum gradient value:
▪ find where the Laplace operator is =0
2 2
LoG ∗ 𝐼 = 𝛻 ∗ 𝐺 ∗ 𝐼 = 𝛻 𝐺 ∗ 𝐼
𝜋𝜎 ( )
𝑥2 + 𝑦2
LoG(𝑥, 𝑦) = −
1 𝑥2 + 𝑦2
− 2𝜎2
4 1 − 𝑒
2𝜎 2
0 1 1 2 2 2 1 1 0
1 2 4 5 5 5 4 2 1
1 4 5 3 0 3 5 4 1
2 5 3 −12 −24 −12 3 5 2
2 5 0 −24 −40 −24 0 5 2
2 5 3 −12 −24 −12 3 5 2
1 4 5 3 0 3 5 4 1
1 2 4 5 5 5 4 2 1
0 1 1 2 2 2 1 1 0
Discrete approximation(σ=1.4)
LoG shape
(upside down Mexican hat)
Common heuristic is to choose 5*σ
as filter size
Log at different scale values
sigma=2 sigma=4
Edge detection
3 problems :
1. Intensity of the gradient is scale dependent: which scale should we use?
∇f
Approach:
Hough transform
Line detection
Line detection
• Problems with the noise: continuity of the filter outputs is not granted
How to merge points into a line?
𝑐𝑜𝑠𝜃 𝑟
𝑦=− 𝑥+
𝑠𝑖𝑛𝜃 𝑠𝑖𝑛𝜃
𝑟 = 𝑥𝑐𝑜𝑠𝜃 + 𝑦𝑠𝑖𝑛𝜃
How to merge points into a line?
• Compute the histogram h(r,θ), each observation adds one point to the line
How to merge points into a line?
• Compute the histogram h(r,θ), each observation adds one point to the line
Hough transform
Approach generalizes to other shapes: “Generalizing the Hough transform to detect arbitrary shapes”, Ballard 1981
Segmentation
Segmentation
source : studyblue.com
Principle of characterization
• Element = pixel
• Each pixel corresponds to a point in the RGB color space
Similarity in the color space
• Clustering by subdivision
▪ divide the groups in sub-groups according to the best boundary
▪ boundary defined with a similarity criteria
▪ iterate
Algorithm K-Means
• Initialization
▪ Given K, the number of target groups, and N the number of elements in
the characteristic space (ex. color, could be different)
▪ Randomly select K elements among the possible N
▪ These elements are now the centers m1, ..., mK of the K groups
• Iteration
▪ Assign each of the N points xi to the closest group center mi
▪ Re-compute the mean mi of each group
▪ If no change, stop
K-Means
Better clusters?
Generalization: GMM
Gaussian Mixture Models
αb mixing coefficients
Solving GMM: Expectation Maximization (EM)
• Goal, find the parameters Θ of the blobs that maximize the probability:
P(X | Θ) = ∏x P(x | Θ)
Algorithm:
1. Expectation step: knowing the current
estimates of the blobs, compute the
probabilities of the points to belong to them
2. Maximization step: knowing the
probabilities of the point to belong to the
blobs, recompute the blobs parameters to
maximize the total probability
3. iterate until convergence
EM details
• E-step :
▪ probability of a point to belong to a blob b (current estimation)
αb P(x | μb, Vb)
P(b | x, μb, Vb) =
∑i=1 αi P(x | μi, Vi)
• M-Step
▪ Update of the mixture weights αbnew 1 N
αbnew = N
∑i=1 P(b | xi, μb, Vb)
N
∑i=1 (xi − μbnew)(xi − μbnew)T P(b | xi, μb, Vb)
Vbnew = N
∑i=1 P(b | xi, μb, Vb)
Generalization : EM
• Radhakrishna Achanta, Appu Shaji, Kevin Smith, Aurelien Lucchi, Pascal Fua, and Sabine Süsstrunk, SLIC
Superpixels Compared to State-of-the-art Superpixel Methods, IEEE Transactions on Pattern Analysis and
Machine Intelligence, vol. 34, num. 11, p. 2274 – 2282, May 2012.
Superpixels : example SLIC
Segmentation using a graph
partitioning strategy: principle
𝑎𝑓𝑓(𝑥, 𝑦) = 𝑒
−1 2
2𝜎𝑑2
𝑥−𝑦
2𝜎𝑖2 (
− 𝐼(𝑦))
2
−1
𝑎𝑓𝑓(𝑥, 𝑦) = 𝑒
𝐼(𝑥)
• Sub-graphs:
▪ remove the edges of low similarity