05 Image Segmentation (Chapter 10)
05 Image Segmentation (Chapter 10)
Image Segmentation
2
3
Image Segmentation – Point Detection
This is not a mathematically
This filter gives highest response
proven filter, this is just made
only for my required detection, and
for the context of the current
can give smaller responses
situation... �ﻫﻠﻴﻬ.
� Matches the
otherwise, so I can just threshold
point that is white surrounded
the result to eliminate them. The
by all black. If it's continuous,
HPs are the threshold and filter size
all weights are fired and so we
get 8 * (-1)*8 = 0. Otherwise 8
4
Image Segmentation – Line Detection
Max response = indeed a line = 6 * 255, so let's apply a threshold on that value.
5
Image Segmentation – Edge Detection
7
Apply threshold to detect edges. But this thing stays
constant for a while, are these multiple edges?
12
(-1, 1) implies that when you see a transition from 0 to 255
the result is white, which means the beginning of an edge
will be white, and the end will be black... (2nd order)
triangle means 1st order, superscript
Image Gradient means further order (so a superscript
of 2 means 2nd order, 3 = 3rd, etc...)
13
Designing an Edge Detector
This kernel is of a
smoothing filter
15
As I was saying, 2nd O.D.'s zero crossing will counteract
the widening of the ramp, and since noise was removed
due to blurring, not much of an issue to actually use 2nd
O.D., an additional bonus is that we can get the direction
of the edge by getting the slope at the zero-crossing. In
Laplacian of Gaussian 1st O.D., the response would've been negative or
positive based on direction (which means the threshold
in that scenario should've been applied on absolute vals)
17
2D Edge Detection Filters
16
Smoothing with a Gaussian equivalent to the amount of smoothing
21
Edge Detection
• Examples:
2
• Compute x and y derivatives
T
S S S Sx Sy
T
x y
• Compute gradient magnitude and orientation
S S x2 S y2
Sy
tan 1
Sx
23
Canny Edge Operator
S G * I G * I
T
G G
G
x y
T
G G
S *I *I
x y
24
Now that's what's new about CannyBoii
Source: D. Forsyth 26
And so after you're done doing thinning at that point, to
Edge linking get to the following point simply move in the direction
of the edge, which is the tangent... �ﻤﻞ ﻗﺮا�ﺔ
Assume the marked point
is an edge point. Then we
construct the tangent to the
edge curve (which is
normal to the gradient at
that point) and use this to
predict the next points We use it to predict which of
the already-existing points to
(here either r or s). go to next, that is expected to
be part of the thinner edge.
Source: D. Forsyth 27
Non‐Maximum Suppression Examples
Source: D. Forsyth 28
The second additional step that CannyBoii did
was this "Hysteresis Thresholding" thing...
Thresholding
Source: D. Forsyth High Threshold (Strong Edges) Small Threshold (Weak Edges) 29
Hysteresis thresholding
• Use a high threshold
Start
to start edge curves
and a low threshold
Connects
to continue them. strong edges
Source: S. Seitz 30
Hysteresis Thresholding
31
Hysteresis Thresholding
Source: L. Fei-Fei 32
Canny Edge Detector
Sx
Sy
25
Canny edge detector
0. Pre-processing: Smoothen w/ Gaussian
1. Filter image with x, y derivatives of Gaussian
2. Find magnitude and orientation of gradient
3. Non‐maximum suppression:
• Thin multi‐pixel wide “ridges” down to single pixel width
4. Thresholding and linking (hysteresis):
• Define two thresholds: low and high
• Use the high threshold to start edge curves and the low threshold to continue them
Source: L. Lazebnik
35
Thresholding
42
Global Thresholding
43
The Role of Illumination
Global Thresholding
It is bound to fail. Always.
Because just cutting off at a
certain color, no matter what
color you choose, will take out
part of the object, because it
shares part of the spectrum
with the background.
46
Adaptive Thresholding
Yay more hyper-parameters :) ! The new one is the size of grid cells based on which
you want to do your histogram thresholding. The purpose of the grid is to localize
parts (adapt within the image). It's still failing though, so let's try and fix it up.
Decent background
w.r.t. foreground
Small background
w.r.t. foreground
Optimal Global Adaptive Thresholding
Histogram plot of overlapping regions p1 and p2, where
would the threshold be? So far we've been analyzing if
regions are separated (in fact that's how we detected
that they are separate regions in the first place...)
So, we want to maximize this function. Let's call the function e(T), where it
is a function in terms of T (not z, because z does not change!). So, simple
maxima and minima tells you get the derivative = 0 and voila.