Computer Graphics and Image Processing CIS601 Image Segmentation

  • Slides: 37
Download presentation
Computer Graphics and Image Processing (CIS-601)

Computer Graphics and Image Processing (CIS-601)

Image Segmentation by Clustering (Using Mahalanobis Distance) - Manjit Chintapalli

Image Segmentation by Clustering (Using Mahalanobis Distance) - Manjit Chintapalli

What is Image Segmentation ? n To humans, an image is not just a

What is Image Segmentation ? n To humans, an image is not just a random collection of pixels; it is a meaningful arrangement of regions and objects. n There also exits a variety of images: natural scenes, paintings, etc. Despite the large variations of these images, humans have no problem to interpret them.

Image Segmentation ? (Contd. . ) Image segmentation is the first step in image

Image Segmentation ? (Contd. . ) Image segmentation is the first step in image analysis and pattern recognition. n It is a critical and essential component of image analysis system, is one of the most difficult tasks in image processing, and determines the quality of the final result of analysis. n

The Process… n Image segmentation is the process of dividing an image into different

The Process… n Image segmentation is the process of dividing an image into different regions such that each region is homogeneous.

Image Segmentation methods

Image Segmentation methods

Image segmentation methods can be categorized as follows (this is not an exhaustive list):

Image segmentation methods can be categorized as follows (this is not an exhaustive list): Histogram thresholding n Edge-based approaches n Region-based approaches n Hybrid: consider both edges and regions. n

Continued… Segmentation of texture by PCA n Segmentation of texture with moments n

Continued… Segmentation of texture by PCA n Segmentation of texture with moments n

Color Image Segmentation n Image segmentation based on color n We use clustering to

Color Image Segmentation n Image segmentation based on color n We use clustering to segment an image according to color features

Clustering ? n Clustering is a common step to get a segmentation n In

Clustering ? n Clustering is a common step to get a segmentation n In the data space, clusters are regarded as regions of similar data points

Clustering…. Similar data points grouped together into clusters.

Clustering…. Similar data points grouped together into clusters.

Clustering… Most popular clustering algorithms suffer from two major drawbacks n First, the number

Clustering… Most popular clustering algorithms suffer from two major drawbacks n First, the number of clusters is predefined, which makes them inadequate for batch processing of huge image databases n Secondly, the clusters are represented by their centroid and built using an Euclidean distance therefore inducing generally an hyperspheric cluster shape, which makes them unable to capture the real structure of the data. n This is especially true in the case of color clustering where clusters are arbitrarily shaped

Clustering Algorithms K-means n K-medoids n Hierarchical Clustering n There are many other algorithms

Clustering Algorithms K-means n K-medoids n Hierarchical Clustering n There are many other algorithms used for clustering. n

K-means Clustering Algorithm Step 1: Choose K cluster centers: c¹(1), c²(1), c³(1)…. . Step

K-means Clustering Algorithm Step 1: Choose K cluster centers: c¹(1), c²(1), c³(1)…. . Step 2: At the kth iterative step distribute the samples among the K cluster domains, using the relation for all x in S(j), if |x – Cj (k)| < |x – Cj (k)| Step 3: Compute the new cluster centers

Algorithm continued … Step 4: If the algorithm has converged and the procedure is

Algorithm continued … Step 4: If the algorithm has converged and the procedure is terminated. Otherwise go to Step 2 S(j): contains data points in RGB space x: is the data point in an iteration C(j): is the center of the cluster

How the problem was approached ? First the images are read from the directory.

How the problem was approached ? First the images are read from the directory. n Then each image is transformed into a 3 -D RGB space. n K-means clustering using Mahanalobis distance and Euclidean distance was applied. n

Continued…. . Next, the mean color of each cluster is calculated. n Then it

Continued…. . Next, the mean color of each cluster is calculated. n Then it is transformed back from 3 -D space. n Result : Segmented image n

Mahalanobis Distance n n n M. D. is a very useful way of determining

Mahalanobis Distance n n n M. D. is a very useful way of determining the ”similarity” of a set of values from an ”unknown”: sample to a set of values measured from a collection of ”known” samples Superior to Euclidean distance because it takes distribution of the points (correlations) into account Traditionally to classify observations into different groups

Mahalanobis vs. other classical statistical approaches It takes into account not only the average

Mahalanobis vs. other classical statistical approaches It takes into account not only the average value but also its variance and the covariance of the variables measured n It compensates for interactions (covariance) between variables n It is dimensionless n

Mahalanobis Distance n Dt(x) = (x – mt) S-1 t (x – mt)` Mahalanobis

Mahalanobis Distance n Dt(x) = (x – mt) S-1 t (x – mt)` Mahalanobis Distance

Euclidean Distance n The Euclidean distance is the straightline distance between two pixels n

Euclidean Distance n The Euclidean distance is the straightline distance between two pixels n Euc dist = √((x 1 - x 2)² + (y 1 - y 2)²) , where (x 1, y 1) & (x 2, y 2) are two pixel points or two data points

After executing the program… Original Images

After executing the program… Original Images

More images…

More images…

During execution… n n The images are transformed into 3 -D RGB space K-means

During execution… n n The images are transformed into 3 -D RGB space K-means clustering is applied which groups data points with similar color into clusters Example:

Continued… n The data points with minimum mahalanobis distance are grouped together into clusters.

Continued… n The data points with minimum mahalanobis distance are grouped together into clusters. n After grouping into clusters, the mean color of the cluster is taken and mapped back into the image

Continued… n The program was executed with different number of clusters n The same

Continued… n The program was executed with different number of clusters n The same program was run with Euclidean distance for distance between data points

Segmented Images

Segmented Images

Original Image Segmented with 4 clusters Segmented with 6 clusters

Original Image Segmented with 4 clusters Segmented with 6 clusters

Original Image 4 Clusters 2 clusters 6 Clusters

Original Image 4 Clusters 2 clusters 6 Clusters

Original Image 4 Clusters 2 Clusters 6 Clusters

Original Image 4 Clusters 2 Clusters 6 Clusters

Mahalanobis vs. Euclidean

Mahalanobis vs. Euclidean

Original Image 4 clusters Mahalanobis 4 clusters Euclidean

Original Image 4 clusters Mahalanobis 4 clusters Euclidean

Original Image 6 Clusters Mahalanobis 6 Clusters Euclidean

Original Image 6 Clusters Mahalanobis 6 Clusters Euclidean

Original Image 6 Clusters Mahalanobis 6 Clusters Euclidean

Original Image 6 Clusters Mahalanobis 6 Clusters Euclidean

Mahalanobis vs. Euclidean Result : Using Euclidean distance in the k-means clustering proved to

Mahalanobis vs. Euclidean Result : Using Euclidean distance in the k-means clustering proved to be better than Mahalanobis distance.

Conclusion n The program runs with all jpeg images and takes a lot of

Conclusion n The program runs with all jpeg images and takes a lot of time to run for larger images This is due to the calculation of the inverse of the covariance matrix for the mahalanobis distance The results show that Image segmentation using Mahalanobis distance works but, not better than Euclidean distance

The End

The End