Presentation on theme: "CMPUT 615 Applications of Machine Learning in Image Analysis"— Presentation transcript:
1 CMPUT 615 Applications of Machine Learning in Image Analysis K-Means ClusteringCMPUT 615Applications of Machine Learning in Image Analysis
2 K-means Overview A clustering algorithm An approximation to an NP-hard combinatorial optimization problemIt is unsupervised“K” stands for number of clusters, it is a user input to the algorithmFrom a set of data points or observations (all numerical), K-means attempts to classify them into K clustersThe algorithm is iterative in nature
3 K-means Details X1,…, XN are data points or vectors or observations Each observation will be assigned to one and only one clusterC(i) denotes cluster number for the ith observationDissimilarity measure: Euclidean distance metricK-means minimizes within-cluster point scatter:wheremk is the mean vector of the kth clusterNk is the number of observations in kth cluster
4 K-means AlgorithmFor a given assignment C, compute the cluster means mk:For a current set of cluster means, assign each observation as:Iterate above two steps until convergence
5 Image Segmentation Results An image (I)Three-cluster image (J) ongray values of IMatlab code:I = double(imread(‘…'));J = reshape(kmeans(I(:),3),size(I));Note that K-means result is “noisy”
6 SummaryK-means converges, but it finds a local minimum of the cost functionWorks only for numerical observations (for categorical and mixture observations, K-medoids is a clustering method)Fine tuning is required when applied for image segmentation; mostly because there is no imposed spatial coherency in k-means algorithmOften works as a staring point for sophisticated image segmentation algorithms
7 Otsu’s Thresholding Method (1979)Based on the clustering idea: Find the threshold that minimizes the weighted within-cluster point scatter.This turns out to be the same as maximizing the between-class scatter.Operates directly on the gray level histogram [e.g. 256 numbers, P(i)], so it’s fast (once the histogram is computed).
8 Otsu’s Method Histogram (and the image) are bimodal. No use of spatial coherence, nor any other notion of object structure.Assumes uniform illumination (implicitly), so the bimodal brightness behavior arises from object appearance differences only.
9 The weighted within-class variance is: Where the class probabilities are estimated as:And the class means are given by:
10 Finally, the individual class variances are: Now, we could actually stop here. All we need to do is just run through the full range of t values [1, 256] and pick the value that minimizesBut the relationship between the within-class and between-class variances can be exploited to generate a recursion relation that permits a much faster calculation.
12 After some algebra, we can express the total variance as... Within-class,from beforeBetween-class,Since the total is constant and independent of t, the effect of changing the threshold is merely to move the contributions of the two terms back and forth.So, minimizing the within-class variance is the same as maximizing the between-class variance.The nice thing about this is that we can compute the quantities in recursively as we run through the range of t values.
13 Result of Otsu’s Algorithm An imageBinary imageby Otsu’s methodMatlab code:I = double(imread(‘…'));I = (I-min(I(:)))/(max(I(:))-min(I(:)));J = I>graythresh(I);Gray level histogram
Your consent to our cookies if you continue to use this website.