360 likes | 593 Views
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.
E N D
Image Segmentation by ClusteringusingMoments 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.
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.
Clustering • Clustering is a classification technique. It involves grouping similar data together. Given a vector of N measurements describing each pixel or group of pixels (i.e., region) in an image, a similarity of the measurement vectors and therefore their clustering in the N-dimensional measurement space implies similarity of the corresponding pixels or pixel groups. Therefore, clustering in measurement space is an indicator of similarity of image regions, and is used for segmentation purposes
Techniques used for clustering Kmeans Kmediods Hierarchical Here we use the KMeans algorithm.
Abstract Texture 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.
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. .
Step 4: Perform an unsupervised clustering of the image. • Step 5: Classify every pixel in the image according to its features
Techniques Used • For computing texture features Moments Nonlinear Transformation • For clustering KMeans
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)
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.
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.
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
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.
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.
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
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
where, m is the total number of pixels in the image n is the corresponding moment values to each pixel.
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
However it is observed that using Euclidean distance yields better results than Mahalanobis.
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.
Results The segmentation has been performed on various images both gray and color.
original 4 clusters 4 clusters
original block size 5 block size 10
original 3 clusters 2 clusters
original 4 clusters
original • 5 clusters
original • 4 clusters
orignal • 4 clusters
orignal 4 clusters diff window
Original 4 clusters 5 clusters
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
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.
3. The output is dependent on the efficiency of the clustering algorithm and the number of clusters are to be given before hand.
References • http://www.cs.iupui.edu/~tuceryan/research/ComputerVision/moment-paper.pdf • http://documents.wolfram.com/applications/digitalimage/UsersGuide/7.5.html