7
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072 © 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1787 Image Segmentation using K-means clustering and Thresholding Preeti Panwar 1 , Girdhar Gopal 2 , Rakesh Kumar 3 1 M.Tech Student, Department of Computer Science & Applications, Kurukshetra University, Kurukshetra, Haryana 2 Assistant Professor, Department of Computer Science & Applications, Kurukshetra University, Kurukshetra, Haryana 3 Professor, Department of Computer Science & Applications, Kurukshetra University, Kurukshetra, Haryana ------------------------------------------------------------***------------------------------------------------------------ Abstract - Image segmentation is the division or separation of an image into regions i.e. set of pixels, pixels in a region are similar according to some criterion such as colour, intensity or texture. This paper compares the color- based segmentation with k-means clustering and thresholding functions. The k-means used partition cluster method. The k-means clustering algorithm is used to partition an image into k clusters. K-means clustering and thresholding are used in this research for the comparison. The comparisons of both techniques are based on segmentation parameters such as mean square error, peak signal-to-noise ratio and signal-to-noise ratio. MSR and PSNR are widely used to measure the degree of image distortion because they can represent the overall gray- level error contained in the entire image. Keywords: Image segmentation, k-means clustering, thresholding, MSR, PSNR 1. INTRODUCTION Image segmentation is one of the most important techniques in image processing. It is a pre-processing step in the area of image analysis, computer vision, and pattern recognition [1]. The process of dividing a digital image into multiple regions (sets of pixels) is called image segmentation. Image segmentation is commonly used to determine objects and boundaries (lines, curves, etc.) in images. The result of image segmentation is a set of segments that include the entire image, or a set of contours extracted from the image (edge detection). All pixels in a region is related with respect to some features or computed property, such as color, intensity or texture [2]. Adjacent regions are significantly different with respect to the same characteristics. Some of applications of image segmentation are: digital libraries, imageprocessing, medical imaging, computer vision, face recognition, image and video retrieval etc[3]. Image segmentation is a low-level image processing task that aims at dividing an image into homogenous regions. Segmentation algorithms are based on one of the two basic properties of intensity, discontinuity and similarity. First category is to partition an image based on small changes in intensity, like edges in an image. Second category is based on partitioning an image into regions that are similar according to some predefined criterion. Threshold approach comes under this category [4]. Image segmentation methods fall into different categories: Region based segmentation, Edge based segmentation, and Clustering based segmentation, Thresholding, Artificial neural network, feature-based segmentation. Clustering of an image is one of the good techniques, which is used for segmentation of images. After extraction of features, these features are put together into well-separated clusters based on each class of an image. The clustering algorithm aim is to develop the partitioning decisions based on initial set of clusters that is updated after each iteration[5]. This paper focused on k-means clustering, thresholding and their procedures. Section 2 describes the K-means clustering method in detail. In section 3, thresholding function is described. Section 4 details about the comparison formation. Section 5 illustrates the experiment setup and results. The analysis of results is provided in section 6, and finally section 7 presents the conclusions of the study. 2. K-MEANS CLUSTERING Currently the clustering method often used for segmenting large-scale images. Clustering is one of the unsupervised learning method in which a set of essentials is separated into uniform groups. There are different types of clustering: hierarchical clustering, Fuzzy C-means clustering, K-means clustering. The K- means method is one of the most generally used clustering techniques for various applications [6]. K-means clustering is a partition-based cluster analysis method. The K-means clustering technique is a widely used approach that has been applied to solve low-level image segmentation tasks. The choosing of initial cluster centers is very important since this prevents the clustering algorithm to producing incorrect decisions. The most common initialization procedure chooses the

Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

Embed Size (px)

Citation preview

Page 1: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1787

Image Segmentation using K-means clustering and Thresholding

Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department of Computer Science & Applications, Kurukshetra University, Kurukshetra,

Haryana 2Assistant Professor, Department of Computer Science & Applications, Kurukshetra University,

Kurukshetra, Haryana 3Professor, Department of Computer Science & Applications, Kurukshetra University, Kurukshetra, Haryana

------------------------------------------------------------***------------------------------------------------------------

Abstract - Image segmentation is the division or separation of an image into regions i.e. set of pixels, pixels in a region are similar according to some criterion such as colour, intensity or texture. This paper compares the color-based segmentation with k-means clustering and thresholding functions. The k-means used partition cluster method. The k-means clustering algorithm is used to partition an image into k clusters. K-means clustering and thresholding are used in this research for the comparison. The comparisons of both techniques are based on segmentation parameters such as mean square error, peak signal-to-noise ratio and signal-to-noise ratio. MSR and PSNR are widely used to measure the degree of image distortion because they can represent the overall gray-level error contained in the entire image.

Keywords: Image segmentation, k-means clustering, thresholding, MSR, PSNR

1. INTRODUCTION

Image segmentation is one of the most important techniques in image processing. It is a pre-processing step in the area of image analysis, computer vision, and pattern recognition [1]. The process of dividing a digital image into multiple regions (sets of pixels) is called image segmentation. Image segmentation is commonly used to determine objects and boundaries (lines, curves, etc.) in images. The result of image segmentation is a set of segments that include the entire image, or a set of contours extracted from the image (edge detection). All pixels in a region is related with respect to some features or computed property, such as color, intensity or texture [2]. Adjacent regions are significantly different with respect to the same characteristics. Some of applications of image segmentation are: digital libraries, imageprocessing, medical imaging, computer vision, face recognition, image and video retrieval etc[3].

Image segmentation is a low-level image processing task that aims at dividing an image into homogenous regions. Segmentation algorithms are based on one of the two basic properties of intensity, discontinuity and similarity. First category is to partition an image based on small

changes in intensity, like edges in an image. Second category is based on partitioning an image into regions that are similar according to some predefined criterion. Threshold approach comes under this category [4].

Image segmentation methods fall into different categories: Region based segmentation, Edge based segmentation, and Clustering based segmentation, Thresholding, Artificial neural network, feature-based segmentation. Clustering of an image is one of the good techniques, which is used for segmentation of images. After extraction of features, these features are put together into well-separated clusters based on each class of an image. The clustering algorithm aim is to develop the partitioning decisions based on initial set of clusters that is updated after each iteration[5].

This paper focused on k-means clustering, thresholding and their procedures. Section 2 describes the K-means clustering method in detail. In section 3, thresholding function is described. Section 4 details about the comparison formation. Section 5 illustrates the experiment setup and results. The analysis of results is provided in section 6, and finally section 7 presents the conclusions of the study.

2. K-MEANS CLUSTERING Currently the clustering method often used for segmenting large-scale images. Clustering is one of the unsupervised learning method in which a set of essentials is separated into uniform groups. There are different types of clustering: hierarchical clustering, Fuzzy C-means clustering, K-means clustering. The K-means method is one of the most generally used clustering techniques for various applications [6].

K-means clustering is a partition-based cluster analysis method. The K-means clustering technique is a widely used approach that has been applied to solve low-level image segmentation tasks. The choosing of initial cluster centers is very important since this prevents the clustering algorithm to producing incorrect decisions. The most common initialization procedure chooses the

Page 2: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1788

initial cluster centres randomly from input data[5]. The procedure of K-means clustering is given below:

2.1 Procedure

K-means is an efficient clustering technique. Based on initial centroids of cluster it is used to separate similar data into groups. According to this algorithm, firstly it chooses k data value as initial cluster centers, then finds the distance between each cluster center and each data value and assign it to the nearest cluster, update the averages of every clusters, repeat this process until the criterion is not match. K-means clustering aims to divide data into k clusters in which each data valuebelongs to the cluster with the closest mean[7]. Fig 1. Shows the process of basic k-means.

Fig 1: K-means Algorithm Process

K-Means Algorithm: The algorithm for k-means, where each cluster’s center is represented by mean value of objects in the cluster[8]. Input: k: the number of clusters. D: a data set containing n objects. Output: A set of k clusters. Method:

1. Randomly select k objects from D as the initial cluster centers.

2. Repeat 3. (re) assign each object to the cluster to which

the object is mainlyrelated using given below

formula, based on the mean value of the objects in the cluster.

4. Update the cluster means, i.e. determine the mean value of the objects for each cluster

5. Until no change.

Where is a selected distance (intra) calculate between a data point xi and the cluster centre cj, is an indicator of the distance of cluster center from their n data points. The term intra is used to measure the compactness of the clusters. The inter term is the minimum distance between the cluster centroids. One of the main disadvantages of k-means is the fact that there is a need to specify the number of clusters as an input to the algorithm. As designed, the algorithm is not able of finding the appropriate number of clusters and depends upon the user to identify this in advance[8].

3. THRESHOLDING

Image thresholding is an important technique for image processing and pattern recognition. Several methods have been proposed to choose the thresholds automatically. Thresholding is one of the most commonly used image segmentation technology[9].Its characteristics are simple operation, and the segmentation results are of series of continuous regions. Thresholding based image segmentation requires finding a threshold value T that establishes the “border” among graylevel image range corresponding to objects and a range equivalent to background. After thresholding the graylevel image is changed to binary. There exist algorithms that use more than one threshold value, which enables to assign pixels to one of a few classes instead of just two. Threshold value may be entered manually or automatically [10]. The procedure of thresholding is given below:

3.1 Procedure The process of threshold segmentation is as follows: first, find out a threshold T, for every pixel in the image, if the gray value is greater than T, then set it’s the target point (the value is 1), otherwise locate it as the background point (the value is 0), or vice versa, so the image is divided into background region and target region. Similarly, in programming, the target pixel can also be set as 255, background pixel 0, or vice verso, so the image is partition into the target region and background region. The formula can be represented as follows: [9]

Page 3: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1789

4. PROPOSED WORK

This paper compares the performance of various segmentation techniques for color images. Two techniques are used for the comparison i.e., k-means clustering and thresholding. Segmentation by K-means clustering and thresholding techniques are compared by their performance in segmentation of color images. Segmentation of an image entails the division or separation of the image into regions of relatedcharacteristic. In this four images are taken for the segmentation. These four images are: - onion.png, peppers.png, hestain.png, fabric.tif.

Fig 2(a) Peppers.png

Fig 2(b) Fabric.png

Fig 2(c) Hestain.png

Fig 2(d) Onion.png Fig 2. Original Images We perform the k-means clustering and adaptive thresholding to obtain the result. The performance of these techniques is measured using segmentation parameters peak signal-to-noise ratio,mean square error, signal-to-noise ratio.

5. EXPERIMENTAL RESULT Comparative evolution of various images has been done. The comparison of various images is done in MATLAB. Five different images are used for this experiment because the images have different color regions. The result of experiment is used to find the MSE, PSNR and SNR value. The results that are obtained by using k-means clustering and thresholding shown in below figures.

5.1 Segmentation by k-means

1. First image is peppers.png

Fig 3.1 (a) segmentation using 1 cluster

Fig 3.1 (b) segmentation using 2 cluster

Page 4: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1790

Fig 3.1(c) Segmentation using 3 cluster Fig 3 segmented image of peppers.png

2. Second image is Fabric.png

Fig 3.2 (a) Segmentation using 1 cluster

Fig 3.2 (b) Segmentation using 2 cluster

Fig 3.2(c) Segmentation using 3 cluster

3. Third image is Hestain.png

Fig 3.3 (a) Segmentation using 1 cluster

Fig 3.3 (b) Segmentation using 2 cluster

Fig 3.3(c) Segmentation using 3 cluster

4. Fourth image is Onion.png

Fig 3.4 (a) Segmentation using

1 cluster

Page 5: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1791

Fig 3.4 (b) Segmentation using 2 cluster

Fig 3.4(c) Segmentation using 3 cluster Fig 3. Shows the segmented image after clustering 5.2 Segmentation by thresholding:

Fig 4(a) Peppers

Fig 4(b) Fabric

Fig 4 (c) Hestain

Fig 4(d) Onion Fig 4. Shows segmented image after thresholding 6. PERFORMANCE ANALYSIS The performance of these techniques is measured using segmentation parameters: Mean Square Error, Peak-to-Signal-Noise, Signal-to-Noise. 1. Mean square error is an average of the squares of the difference between the predicated observations and actual. For an m*n image the MSE can be calculated as

2. Peak signal to noise ratio term for ratio between the maximum possible power of a signal and the power of corrupting noise that affects the fidelity of its representation. Because many signals have an extremely large dynamic range. PSNR is commonly used as measure of quality reconstruction of image. High value of PSNR indicates the high quality of image. PSNR is usually expressed in terms of the logarithmic scale.

Page 6: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1792

3. Signal to noise ratio is a measure used to compare the level of a required signal to the level of background noise. It is defined as the ratio of signal power to the noise power.

Thresholding table Table1. Results of thresholding

Method

Peppers

Fabric

Hestain Onion

PSNR

5.055261 5.189725 5.253498 5.055261

SNR -1.460402e+000

-1.2434501e+000

-1.208172e+ooo

-1.460402e+000

MSE

20302.723090

196830.751299

19396.822960

20302.723096

Table 1 represent the value of thresholding for four images using different parameters. The three parameters PSNR, SNR and MSE show the value of four images.

K-means clustering table

1. Table of first image Peppers.png

Table2: Results of peppers.png Method

Cluster1 Cluster2 Cluster3

PSNR

6.163616 6.334647 6.234241

SNR

-9.062239e-001

-8.207084e-001

-8.709114e-001

MSR

15729.638889

15722.223234

15475.911406

Table 2 shows the value of peppers.png image for three different clusters. The values are represented using parameters PSNR, SNR and MSE.

2. Table of second image Fabric.png

Table3: Results of fabric.png

Method

Cluster1 Cluster2 Cluster3

PSNR

6.695774 6.577087 7.838629

SNR -4.904765e-001

-5.498203e-001

8.095071e-002

MSE

13915.632381

14301.174402

10695.904239

Table 3 shows the value of fabric.png image for three different clusters. The values are represented using parameters PSNR, SNR and MSE.

3. Table of third image Hestain.png

Table4: Results of hestain.png

Method

Cluster1 Cluster2 Cluster3

PSNR

5.569623 6.581611 4.536970

SNR 1.366225e+00

1.872229e+000

8.499088e.001

MSE

18035.078166

14286.284638

22876.170837

Table 3 shows the value of hestain.png image for three different clusters. The values are represented using parameters PSNR, SNR and MSE.

4. Table of fourth image Onion.png

Page 7: Image Segmentation using K-means clustering and … Segmentation using K-means clustering and Thresholding Preeti Panwar1, Girdhar Gopal2, Rakesh Kumar3 1M.Tech Student, Department

International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 05 | May-2016 www.irjet.net p-ISSN: 2395-0072

© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 1793

Table5: Results of onion.png

Method

Cluster1 Cluster2 Cluster3

PSNR

4.307503 4.196357 4.431204

SNR -1.349676e+000

-1.405249e+000

-1.332826e+000

MSR

24117.375159

24742.559858

23930.952450

Table 5 shows the value of onion.png image for three different clusters. The values are represented using parameters PSNR, SNR and MSE.

7. CONCLUSION A comparative study of two segmentation techniques has been performed in this study. The K-means clustering and thresholding techniques were chosen for segmentation. Using these two techniques, the performance for different images were segmented by using the parameters like MSE, PSNR, and SNR. From observations shown in this paper, one can conclude that the thresholding technique gives an output of two segments. However, in k-means techniques, output is of various segments according to cluster size. Performance improves according to cluster sizes. More is the cluster size more is the accuracy percentage. MSR and PSNR are used to measure the quality of reconstruction. PSNR value of four images in k-means clustering is higher than thresholding and MSE value is lower.

REFERENCES

[1] R. R. N. Senthilkumaran, “A Study on Rough Set Theory for Medical Image Segmentation,” International Journal of Recent Trends in Engineering, vol. 2, november 2009.

[2] S. k. A. P. Prasad Dakhole, “Fabric Fault Detection Using Image Processing Matlab,” International Journal For Emerging Trends in Engineering and Management Research (IJETEMR), vol. 2, no. 1, 21 january 2016.

[3] C. R. Tippana, “Homogeneous Regions for Image Segmentation Based on Fuzzy,” international journal & magazine of engineering, technology,

management and research.

[4] O. Singh, “New Method of Image Segmentation for Standard Images,” IJCST , vol. 2, no. 3, september 2011.

[5] S. panda, “Color Image Segmentation Using K-means Clustering and Thresholding Technique,” IJESC, march 2015.

[6] L. H. a. J. Y. Lihua Tian, “Research on Image Segmentation based on Clustering Algorithm,” International Journal of Signal Processing, Image Processing and Pattern Recognition, vol. 9, pp. 1-12, 2016.

[7] B. T. Sachin Shinde, “Improved K-means Algorithm for Searching Research Papers,” International Journal of Computer Science & Communication Networks, vol. 4, pp. 197-202.

[8] A. S. B. M. a. H. K. S, “Dynamic Clustering of Data with Modified K-Means Algorithm,” International Conference on Information and Computer Networks, vol. 27, 2012.

[9] L. H. a. L. Shengpu, “An Algorithm and Implementation for Image Segmentation,” International Journal of Signal Processing, Image Processing and Pattern Recognition, vol. 9, pp. 125-132, 2016.

[10] W. B. a. S. Grabowski, “Multi-pass approach to adaptive thresholding based image segmentation,” 26 feb 2005.