Lecture 19 Segmentation I
Lecture 19 Segmentation I
Lecture 19
15
Inference car
Higher level
Low level features
inference
11/16/2021 CAP5415 - Lecture 15 Image Segmentation - I 9
Thresholding
Machine Region based
Learning methods
based (region
methods growing,..)
Image
Segmentation Clustering
Energy
Methods
minimization (k-means,
methods mean
(MRF,..) shift,..)
DIFFICULTIES
Darker objects
1. The valley may be so broad that it is difficult
to locate a significant minimum
2. Number of minima due to type of details in
the image
3. Noise
4. No visible valley
5. Histogram may be multi-modal
11/16/2021 CAP5415 - Lecture 15 Image Segmentation - I 17
Thresholding Example
where P1 and P2 denote class probabilities, and μi the means of object and
background classes.
u=p1u1+p2u2
p1+p2=1
where P1 and P2 denote class probabilities, and μi the means of object and
background classes.
• Let be the relative cumulative histogram of an image I, then P1 and P2 are
approximated by and , respectively.
• u is assumed to be the chosen threshold.
11/16/2021 CAP5415 - Lecture 15 Image Segmentation - I 26
Otsu Thresholding Algorithm
Closed boundaries
Computation of regions is
based on similarity
• Region splitting:
• Unlike region growing, which starts from a set of seed points, region splitting
starts with the whole image as a single region and subdivides it into
subsidiary regions recursively while a condition of homogeneity is not
satisfied.
• Region splitting:
• Unlike region growing, which starts from a set of seed points, region splitting
starts with the whole image as a single region and subdivides it into
subsidiary regions recursively while a condition of homogeneity is not
satisfied.
• Region merging:
• Region merging is the opposite of splitting, and works as a way of avoiding
over-segmentation
• Region splitting:
• Unlike region growing, which starts from a set of seed points, region splitting
starts with the whole image as a single region and subdivides it into
subsidiary regions recursively while a condition of homogeneity is not
satisfied.
• Region merging:
• Region merging is the opposite of splitting, and works as a way of avoiding
over-segmentation
• Start with small regions (2x2 or 4x4 regions) and merge the regions that have
similar characteristics (such as gray level, variance).
• RAG: region
adjacency graph
• Quadtree for
splitting (top-down)
procedure
2 2 2 2 1 1 1 1
2 2 3 3 2 2 2 2
2 2 3 3 3 2 2 2
1 1 1 1 2 2 2 2
1 1 1 1 2 2 2 2
1 1 1 1 2 2 2 2
1 1 1 1 2 2 2 2
• Finding the class labels and the number of classes directly from the
data (as opposed to classification tasks)
Clustering is subjective
• Color
• Intensity
• Location
• Texture
• ….
Peter Piotr
0.23 3 342.7
Iterate:
• Assign/cluster each example to closest center
• Recalculate centers as the mean of the points in a cluster
No changes: Done
11/22/2021 CAP5415 - Lecture 16 Image Segmentation - II 29
K-means
Iterate:
• Assign/cluster each example to closest center
• Recalculate centers as the mean of the points in a cluster
How do we do this?
11/22/2021 CAP5415 - Lecture 16 Image Segmentation - II 30
K-means
Iterate:
◼ Assign/cluster each example to closest center
iterate over each point:
- get distance to each cluster center
- assign to closest center (hard cluster)
◼ Recalculate centers as the mean of the points in a cluster
n
d(x, y) = å i=1(xi - yi ) 2
11/22/2021
Where are the cluster centers?
CAP5415 - Lecture 16 Image Segmentation - II 34
K-means
Iterate:
• Assign/cluster each example to closest center
• Recalculate centers as the mean of the points in a cluster
11/22/2021
How do we calculate these?
CAP5415 - Lecture 16 Image Segmentation - II 35
K-means
Iterate:
• Assign/cluster each example to closest center
• Recalculate centers as the mean of the points in a cluster
1
m (C) = å
|C | xÎC
x
where:
x xi
å i=1 C
n
å
n
x+y= x + yi =
11/22/2021
i=1 i
CAP5415 - Lecture 16 Image Segmentation - II
C 36
K-means loss function
K-means tries to minimize what is called the “k-means”
loss function:
n
loss = å d(x , m )
i k
2
where mk is cluster center for xi
i=1
Iterate:
◼ Assign/cluster each example to closest center
◼ Recalculate centers as the mean of the points in a cluster
Convergence
• A fixed number of iterations
• partitions unchanged
• Cluster centers don’t change
11/22/2021
Seed selection ideas?
CAP5415 - Lecture 16 Image Segmentation - II 40
Seed choice
Results can vary drastically based on random seed selection
Common heuristics
• Random centers in the space
• Randomly pick examples
• Points least similar to any existing center (furthest centers
heuristic)
• Try out multiple starting points
• Initialize with the results of another clustering method
11/22/2021 CAP5415 - Lecture 16 Image Segmentation - II 41
SLIC (Achanta et al. PAMI 2012)
1. Initialize cluster centers on pixel
grid in steps S
- Features: Lab color, x-y position
2. Move centers to position in 3x3
window with smallest gradient
3. Compare each pixel to cluster
center within 2S pixel distance
and assign to nearest
4. Recompute cluster centers as + Fast 0.36s for 320x240
mean color/position of pixels + Regular superpixels
+ Superpixels fit boundaries
belonging to each cluster - May miss thin objects
- Large number of superpixels
5. Stop when residual error is
11/22/2021 small CAP5415 - Lecture 16 Image Segmentation - II 42
Slide Credits and References
• Ulas Bagci
• David Kauchak (k-means)
• R.Klette, Concise Computer Vision, 2014.
• Y. Ukrainitz & B. Sarel, Weizmann
• Thu Huong Nhuyen, TU Dresden
• Jens N. Kaftan and Andr`e A. Bell and Til Aach . Mean Shift Segmentation Evaluation of Optimization Techniques
• Cheng, Y. (1995). Mean Shift, Mode Seeking, and Clustering. IEEE Transactions on Pattern Analysis and Machine
Intelligence, 17(8):790–799.
• KEINOSUKE FUKUNAGA, AND LARRY D. HOSTETLER. The Estimation of the Gradient of a Density Function, with Applications
in Pattern – Recognition. IEEE TRANSACTIONS ON INFORMATION THEORY, VOL. IT-21, NO. 1, JANUARY 1975
• Comaniciu, D. and Meer, P. (1997). Robust Analysis of Feature Spaces: Color Image Segmentation.
• In IEEE Conference on Computer Vision and Pattern Recognition. CVPR 1997, pages 750–755.
• Comaniciu, D. and Meer, P. (1999). Mean Shift Analysis an Applications. In International Conference on Computer Vision.
ICCV 1999, volume 2, pages 1197–1203.
• Comaniciu, D. and Meer, P. (2002). Mean Shift: A Robust Approach Toward Feature Space Analysis. IEEE Transactions on
Pattern Analysis and Machine Intelligence, 24(5):603–619.
• K. Fukunaga, L.D. Hostetler, The estimation of the gradient of a density function, with applications in pattern recognition,
IEEE Trans. Inf. Theory 21 (1975) 3240.
• Yiping Hong , Jianqiang Yi and Dongbin Zhao . Improved mean shift segmentation approach for natural images
11/16/2021 CAP5415 - Lecture 15 Image Segmentation - I 54