Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

36
Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla

Transcript of Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Page 1: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Image Segmentation by ClusteringusingMoments by,

Dhiraj Sakumalla

Page 2: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

What is segmentation?

It is to distinguish objects from background

Types of segmentation edge based region based

In the present project we use region based segmentation.

Page 3: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Region based Segmentation A region-based method usually proceeds as

follows: the image is partitioned into connected regions by grouping neighboring pixels of similar intensity levels. Adjacent regions are then merged under some criterion involving perhaps homogeneity or sharpness of region boundaries. Overstringent criteria create fragmentation; lenient ones overlook blurred boundaries and overmerge.

Page 4: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Clustering

Clustering is a classification technique. It involves grouping similar data together.

Given a vector of N measurements describing eachpixel or group of pixels (i.e., region) in an image, asimilarity of the measurement vectors and thereforetheir clustering in the N-dimensional measurementspace implies similarity of the corresponding pixels orpixel groups. Therefore, clustering in measurementspace is an indicator of similarity of image regions, andis used for segmentation purposes

Page 5: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Techniques used for clustering

Kmeans

Kmediods

Hierarchical

Here we use the KMeans algorithm.

Page 6: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

AbstractTexture segmentation is one of the early steps towards identifying surfaces and objects in an image. In this paper a moment based texture segmentation algorithm is presented. The moments in small windows of the image are used as texture features which are then used to segment the textures. The algorithm has successfully segmented binary images as well as a number of gray level texture images.

Page 7: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

The basic algorithm.

Step 1: To break the image into blocks.

Step 2: Compute moments for each block.

Step 3: Obtain texture feature by applying a transformation..

Page 8: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Step 4:

Perform an unsupervised clustering of the image.

Step 5:

Classify every pixel in the image according to its features

Page 9: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Techniques Used

For computing texture features

Moments

Nonlinear Transformation

For clustering

KMeans

Page 10: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Computing the Moments Our algorithm uses the moments of an image

to compute texture features. The (p+q)th order moments of a function of two variables f(x,y) with respect to the origin (0,0) are defined as :Σµ

mpq = Σx Σy f(x,y) xp yq

The central moments are defined as

µpq = Σx Σy (x-x’)p(y-y’) f(x,y)

Page 11: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

where,

x’ = m10/m00 and y’ = m01/m00

And the normalized moments are given by

ŋpq = µpq /µ00

In this way seven 2D moments are calculated

and are applied to each block of the image.

Page 12: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Thus each block now has seven values in the output matrix.

The moments alone are not sufficient to obtain good texture features in certain images.

For this we apply a non-linear transformation function on each output.

Page 13: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

which is given by,

abs(tanh(Mk(a,b) – M’))

where Mk is the kth moment of a,b

and M’ is the mean of the moments

Page 14: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Implemantation First the image is broken into blocks.

The size of the block is important. As the

window size gets larger, more global features

are detected. This suggests that the choice of

window size could possibly be tied

to the contents of the image. The images with

larger texture tokens would require larger

window sizes whereas finer textures would

require smaller windows.

The size of the block taken here ranges between

3 and 8.

Page 15: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Kmeans Kmeans clustering finds a grouping of the

measurements that minimizes the within-cluster sum-of-squares. In this method, each measurement, represented by a vector of length N, is grouped so that it is assigned to one of a fixed number of clusters. The number of clusters is determined by the number of seeds given as the second argument of KMeans. Measurements are transferred from one cluster to another when doing so decreases the within-cluster distances. The algorithm stops when no more transfers can occur. Here we will demonstrate the application of KMeans clustering to a simple image segmentation problem. Consider the problem of programmatically manipulating individual red beans in a fragment of the "beans" image.

Page 16: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Matlab function used for breaking into blocks is im2col

We use sliding window as an option here.what this does is rather than take distinct wiindows of size m*n it takes in each pixel individually and and takes in the pixels around it.

Each block thus obtained are processed by function

Page 17: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

The second step is to compute the moments.

The function mention above does this.

It takes in each block and computes the seven moments of this.

Then to this the non linear transformation is applied.

the output of this would then be a matrix with dimensions m*n

Page 18: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

where,

m is the total number of pixels in the image

n is the corresponding moment values to each pixel.

Page 19: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

The third step is to cluster the output matrix from the above step.

the clustering algorithm used here is the Kmeans algorithm.

this algorithm requires us to specify the number of clusters required.

the distance calculations between the centriod and the points are done using euclidean and mahalanobis distance

Page 20: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

However it is observed that using Euclidean distance yields better results than Mahalanobis.

Page 21: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

The final step in this project is to classify the pixels according to its cluster.

This is done assigning a particular graylevel to each cluster and then remapping it to the original image.

The matlab function used here is col2im which reconstructs the matrix from the blocks obtained from im2col.

Page 22: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Results

The segmentation has been performed on various images both gray and color.

Page 23: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original 4 clusters

Page 24: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

4 clusters 4 clusters

Page 25: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

block size 5 block size 10

Page 26: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

3 clusters 2 clusters

Page 27: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

4 clusters

Page 28: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

5 clusters

Page 29: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

original

4 clusters

Page 30: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

orignal

4 clusters

Page 31: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

orignal

4 clusters diff window

Page 32: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Original

4 clusters 5 clusters

Page 33: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

Conclusions This project dealt with segmenting an image

based on texture using moments.

From the results of this project three things could be observed

1. The size of the initial block of image. The image initial block should be smaller for images with finer textures and bigger for images with coarse textures

Page 34: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

2. The number of moments to be considered.

In this projects seven moments were taken

and the results were not very satisfactory.

May be fewer moments like 5 or 6 would give a better result.

Page 35: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

3. The output is dependent on the efficiency of the clustering algorithm and the number of clusters are to be given before hand.

Page 36: Image Segmentation by Clustering using Moments by, Dhiraj Sakumalla.

References

http://www.cs.iupui.edu/~tuceryan/research/ComputerVision/moment-paper.pdf

http://documents.wolfram.com/applications/digitalimage/UsersGuide/7.5.html