Computer Graphics and Image Processing (CIS-601).

37
Computer Graphics Computer Graphics and Image Processing and Image Processing (CIS-601) (CIS-601)

Transcript of Computer Graphics and Image Processing (CIS-601).

Page 1: Computer Graphics and Image Processing (CIS-601).

Computer Graphics Computer Graphics and Image and Image Processing Processing

(CIS-601)(CIS-601)

Page 2: Computer Graphics and Image Processing (CIS-601).

Image Segmentation by Clustering Image Segmentation by Clustering (Using Mahalanobis Distance)(Using Mahalanobis Distance)

- Manjit Chintapalli- Manjit Chintapalli

Page 3: Computer Graphics and Image Processing (CIS-601).

What is Image What is Image Segmentation ?Segmentation ?

To humans, an image is not just a random collection of pixels; it is a meaningful arrangement of regions and objects.

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.

Page 4: Computer Graphics and Image Processing (CIS-601).

Image Segmentation ? Image Segmentation ? (Contd..)(Contd..)

Image segmentation is the first step in image analysis and pattern recognition.

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.

Page 5: Computer Graphics and Image Processing (CIS-601).

The Process…The Process…

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

Page 6: Computer Graphics and Image Processing (CIS-601).

Image Segmentation Image Segmentation methodsmethods

Page 7: Computer Graphics and Image Processing (CIS-601).

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

Histogram thresholding Edge-based approaches Region-based approaches Hybrid: consider both edges and

regions.

Page 8: Computer Graphics and Image Processing (CIS-601).

Continued…Continued…

Segmentation of texture by PCA Segmentation of texture with

moments

Page 9: Computer Graphics and Image Processing (CIS-601).

Color Image Color Image SegmentationSegmentation

Image segmentation based on Image segmentation based on colorcolor

We use clustering to segment an We use clustering to segment an image according to color featuresimage according to color features

Page 10: Computer Graphics and Image Processing (CIS-601).

Clustering ?Clustering ?

Clustering is a common step to get a segmentation

In the data space, clusters are regarded as regions of similar data points

Page 11: Computer Graphics and Image Processing (CIS-601).

Clustering….Clustering….

Similar data points grouped together into clusters.

Page 12: Computer Graphics and Image Processing (CIS-601).

Clustering…Clustering…

Most popular clustering algorithms suffer from two major drawbacks

First, the number of clusters is predefined, which makes them inadequate for batch processing of huge image databases

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.

This is especially true in the case of color clustering where clusters are arbitrarily shaped

Page 13: Computer Graphics and Image Processing (CIS-601).

Clustering AlgorithmsClustering Algorithms

K-meansK-means K-medoidsK-medoids Hierarchical ClusteringHierarchical Clustering There are many other algorithms There are many other algorithms

used for clustering.used for clustering.

Page 14: Computer Graphics and Image Processing (CIS-601).

K-means Clustering K-means Clustering AlgorithmAlgorithm

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 relationfor all x in S(j), if |x – Cj (k)| < |x – Cj (k)|

Step 3: Compute the new cluster centers

Page 15: Computer Graphics and Image Processing (CIS-601).

Algorithm continued …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 S(j): contains data points in RGB spacespace

x: is the data point in an iterationx: is the data point in an iteration

C(j): is the center of the clusterC(j): is the center of the cluster

Page 16: Computer Graphics and Image Processing (CIS-601).

How the problem was How the problem was approached ?approached ?

First the images are read from the First the images are read from the directory.directory.

Then each image is transformed Then each image is transformed into a 3-D RGB space.into a 3-D RGB space.

K-means clustering using K-means clustering using Mahanalobis distance and Mahanalobis distance and Euclidean distance was applied.Euclidean distance was applied.

Page 17: Computer Graphics and Image Processing (CIS-601).

Continued…..Continued…..

Next, the mean color of each Next, the mean color of each cluster is calculated.cluster is calculated.

Then it is transformed back from Then it is transformed back from 3-D space.3-D space.

Result : Segmented imageResult : Segmented image

Page 18: Computer Graphics and Image Processing (CIS-601).

Mahalanobis DistanceMahalanobis Distance

M.D. is a very useful way of M.D. is a very useful way of determining the ”similarity” of a set of determining the ”similarity” of a set of values from an ”unknown”: sample to values from an ”unknown”: sample to a set of values measured from a a set of values measured from a collection of ”known” samplescollection of ”known” samples

Superior to Euclidean distance Superior to Euclidean distance because it takes distribution of the because it takes distribution of the points (correlations) into accountpoints (correlations) into account

Traditionally to classify observations Traditionally to classify observations into different groupsinto different groups

Page 19: Computer Graphics and Image Processing (CIS-601).

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

average value but also its average value but also its variance and the covariance of variance and the covariance of the variables measuredthe variables measured

It compensates for interactions It compensates for interactions (covariance) between variables(covariance) between variables

It is dimensionlessIt is dimensionless

Page 20: Computer Graphics and Image Processing (CIS-601).

Mahalanobis DistanceMahalanobis Distance

DDtt((xx) = () = (xx – – mmtt) ) SS-1-1t t ((xx – – mmtt)`)`

Mahalanobis Distance

Page 21: Computer Graphics and Image Processing (CIS-601).

Euclidean DistanceEuclidean Distance

The Euclidean distance is the The Euclidean distance is the straight-line distance between straight-line distance between two pixels two pixels

Euc dist = √((x1 - x2)² + (y1 - Euc dist = √((x1 - x2)² + (y1 - y2)²) , where (x1,y1) & (x2,y2) are y2)²) , where (x1,y1) & (x2,y2) are two pixel points or two data two pixel points or two data pointspoints

Page 22: Computer Graphics and Image Processing (CIS-601).

After executing the After executing the program…program…

Original ImagesOriginal Images

Page 23: Computer Graphics and Image Processing (CIS-601).

More images…More images…

Page 24: Computer Graphics and Image Processing (CIS-601).

During execution…During execution…

The images are transformed into 3-D RGB The images are transformed into 3-D RGB spacespace

K-means clustering is applied which groups K-means clustering is applied which groups data points with similar color into clustersdata points with similar color into clusters

ExampleExample::

Page 25: Computer Graphics and Image Processing (CIS-601).

Continued…Continued…

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

After grouping into clusters, the After grouping into clusters, the mean color of the cluster is taken mean color of the cluster is taken and mapped back into the imageand mapped back into the image

Page 26: Computer Graphics and Image Processing (CIS-601).

The program was executed with The program was executed with different number of clustersdifferent number of clusters

The same program was run with The same program was run with Euclidean distance for distance Euclidean distance for distance between data pointsbetween data points

Continued…Continued…

Page 27: Computer Graphics and Image Processing (CIS-601).

Segmented ImagesSegmented Images

Page 28: Computer Graphics and Image Processing (CIS-601).

Segmented with 4 clustersSegmented with 4 clusters

Original Original ImageImage

Segmented with 6 Segmented with 6 clustersclusters

Page 29: Computer Graphics and Image Processing (CIS-601).

Original Original ImageImage 2 2

clustersclusters

4 Clusters4 Clusters 6 Clusters6 Clusters

Page 30: Computer Graphics and Image Processing (CIS-601).

Original Original ImageImage

4 4 ClustersClusters

2 2 ClustersClusters

6 6 ClustersClusters

Page 31: Computer Graphics and Image Processing (CIS-601).

Mahalanobis vs. Mahalanobis vs. EuclideanEuclidean

Page 32: Computer Graphics and Image Processing (CIS-601).

4 clusters 4 clusters MahalanobisMahalanobis

4 clusters 4 clusters EuclideanEuclidean

Original Original ImageImage

Page 33: Computer Graphics and Image Processing (CIS-601).

OriginaOriginal Imagel Image

6 Clusters 6 Clusters MahalanobisMahalanobis

6 Clusters Euclidean6 Clusters Euclidean

More More detailed detailed description description using using MahalanobiMahalanobiss

Page 34: Computer Graphics and Image Processing (CIS-601).

OriginaOriginal Imagel Image

6 Clusters 6 Clusters MahalanobisMahalanobis

6 Clusters 6 Clusters EuclideanEuclidean

Image more Image more clear than clear than EuclideanEuclidean

Page 35: Computer Graphics and Image Processing (CIS-601).

Mahalanobis vs. Mahalanobis vs. EuclideanEuclidean

Result :Result :• Using Mahalanobis distance in the Using Mahalanobis distance in the

k-means clustering proved to be k-means clustering proved to be better than Euclidean distance. better than Euclidean distance.

• This is because the Mahalanobis This is because the Mahalanobis considers the covariance between considers the covariance between variables. variables.

Page 36: Computer Graphics and Image Processing (CIS-601).

ConclusionConclusion

The program runs with all jpeg images The program runs with all jpeg images and takes a lot of time to run for larger and takes a lot of time to run for larger images.images.

This is due to the calculation of the This is due to the calculation of the inverse of the covariance matrix for the inverse of the covariance matrix for the Mahalanobis distance.Mahalanobis distance.

The results show that Image The results show that Image segmentation using Mahalanobis distance segmentation using Mahalanobis distance works and is better than Euclidean works and is better than Euclidean distance.distance.

Page 37: Computer Graphics and Image Processing (CIS-601).

The EndThe End