International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 Comparison between Edge Detection and K-Means Clustering Methods for Image Segmentation and Merging Hnin Mar lar Win, Nang Aye Aye Htwe Department of Information Technology Mandalay Technological University Abstract – Color based image segmentation techniques can be differentiated into the following basic concepts: pixel oriented Contour-oriented, region-oriented, modeloriented, colour oriented and hybrid. Segmentation of color image is a crucial operation in image analysis and in many computer vision, image interpretation, and pattern recognition system, with applications in scientific and industrial field(s). Color Image Segmentation is the partition of an image into a set of non-overlapping regions whose union to the entire image. Merging is combining stage for segmented regions of an image. This system is to compare segmentation time and image quality after merging based on two approaches: Edge Detection and K-Means. Edge Detection aims at identifying points in a colour image. These points based on the image brightness changes sharply or, more formally, has discontinuities. Edge detection is faster than K-Means in processing time and computation time. Edge detection used only gradient lines to segment. KMeans clustering used L*a*b color format. This system can be used in large image transmission, that purpose is faster in large image transmission speed. Keywords - Image Segmentation, Sobel Edge Detection, Gradients, K-Means, L*a*b. I. INTRODUCTION For image segmentation, the images that need to be classified are segmented into many homogeneous areas with similar spectrum information firstly, and the image segments’ features are extracted based on the specific requirements of ground features classification. The colour homogeneity is based on the standard deviation of the spectral colours, while the shape homogeneity is based on the compactness and smoothness of shape. Digital image processing has many advantages over analog image processing. Digital image processing allows a much wider range of algorithms to be applied to the input data and can avoid problems such as the build-up of noise and signal distortion during processing. Digital image processing is commonly used in large image transmission. In an image: pixels, boundary and edges are included. These pixels, boundary and edges are convert to segment region are called image processing. In imaging science, image processing is any form of signal processing for which the input is an image, such as a photograph or video frame; the output of image processing may be either an image or a set of characteristics or parameters related to the image. Most image-processing techniques involved treating the image as a two-dimensional signal and applying standard signalprocessing techniques to it. Image processing referred to digital image processing, but optical and analog image processing also are possible. In this system, two image processing techniques (edge detection and K-Means Clustering) are used to system implementation. The propose system will use two image processing methods: Edge Detection and K-Means. The edges identified by edge detection method. To segment an object from an image, requirement is edge between closed region boundaries. Edge Detection method find these edges. Segmented images are not same and similar. K-Means method is also used for image segmentation. KMeans method reads an image and converts it in L*a*b format. These segmented images are showed as outputs, and then merge segmented images into original image. II. RELATED WORKS Image segmentation based on K-Means clustering and edge detection techniques were described by Nassir Salman, computer science department in Zarqa Private University. Nassir Salman described to perform image segmentation and edge detection tasks [1]; there are many methods that incorporate region- growing and edge detection techniques. For example, it is applying edge detection techniques to obtain Difference In Strength (DIS) map. In combining both special and intensity information in image segmentation approach based on multi-resolution edge detection, region selection and intensity threshold methods to detect white matter structure in brain. [4] But Nassir Salman desired that edge detection and K-means are good to use in image segmentation and merging. DR. S.K. KATIYAR presents a novel image segmentation based on color features with K-means clustering unsupervised algorithm. In this we did not used any training data. The entire work is divided into two stages. First enhancement of color separation of satellite image using de-correlation stretching is carried out and then the regions are grouped into a set of five classes using K-means clustering algorithm. Using this two-step process, it is possible to reduce the computational cost avoiding feature calculation for every pixel in the image. Although the color is not frequently used for image segmentation, it gives a high discriminative power of regions present in the image. Edge strength technique to obtain accurate edge maps of images was presented by Gullanar M.Hadi and Nassir H.Salman. [3] In this technique: problem of undesirable over segmentation results produced by the other algorithms (not contain edge detection and K-Means), when used directly with raw data images. Also, the edge maps obtained have no broken lines on entire image.[6] This paper describes the comparison between edge detection and K-Means. These two methods are also used in image segmentation and merging. The system also compared in processing time, image quality, decrease All Rights Reserved © 2014 IJSETR 1 International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 over segmentation and others. The system also presented how to segment and how to merge in image processing. III. BACKGROUND THEORY Image segmentation and merging is made by image processing. Image segmentation is one of the important steps in image processing. It is based on input image and then it worked for segment and merge. This paper describes about K-Mean algorithm and edge detection algorithm in details. Both two algorithms are server for image processing. Image processing means for the proposed system is image segmentation and merging. The goal of segmentation is to simplify and change the representation of an image into something that is more meaningful and easier to analyze. A. Edge Detection Algorithm Edge detection referred to the process of identifying outlines in an image. Edge detection detected these outlines of an object and boundaries between objects and the background in the image. In edge detection, sobel operator is used to image segmentation. The process of partitioning a digital image into multiple regions or sets of pixels using outlines is called image segmentation. Edge is a boundary between two regions with relatively distinct gray level properties. This gray level calculated by gradient operator. This system is used sobel operator techniques in edge detection. The gradient of an image f(x,y) at location (x,y) is the vector: Figure 2. Block Diagram for Image Segmentation using Edge Detection with Sobel Edge detection using sobel procedure illustrates with the following figure 3. (a) (b) (1) The gradient vector points in the direction of maximum rate of change of f at (x,y). Gradient direction of can be calculated as: (2) In this equation,‘a’ means different distance from edge endpoint. The computation of the partial derivation in gradient may be approximated in digital images. Sobel operator is shown in the masks below. Mx My Figure 1. The Sobel Masks Sobel operator found sobel values (X and Y). Purpose of this case is to generate edge map. Gradient operator used in finding sobel value X and Y. Then, generate gradient value from sum of root sobel values. And then, sobel operator generated edge map of input image. Finally, sobel operator makes subtraction in original image (OI) to edge map and generate segmented images. The following block diagram showed image segmentation using edge detection with sobel. (c) Figure 3. (a) Input Image. (b) Sobel Operator Detects Edge. (c) Output Generated as Segmented Images. The result of merging stage is also based on segmentation result; because merging is work by the reverse the segmentation steps. In image segmentation, an input image is segmented as many images for foregrounds and background. For merging, results of segmentation (foreground images and background image) must combine as an image. This merged image is become an image but quality is different from original image. In my opinion, the result of edge detection segmentation is simply, but segmentation accuracy is fewer than K-Mean segmentation. Therefore, the user should choice K-Mean technique for image processing. B. K-Means Clustering Algorithm There are many methods of clustering developed for a wide variety of purposes. Clustering algorithms used for unsupervised classification of remote sensing data vary according to the efficiency with which clustering takes place-means is the clustering algorithm used to determine the natural spectral groupings present in a data All Rights Reserved © 2014 IJSETR 2 International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 set. This accepts from analyst the number of clusters to be located in the data. The algorithm then arbitrarily seeds or locates, that number of cluster centers in multidimensional measurement space. Each pixel in the image is then assigned to the cluster whose arbitrary mean vector is closest. The procedure continues until there is no significant change in the location of class mean vectors between successive iterations of the algorithms. As K-means approach is iterative, it is computationally intensive and hence applied only to image subareas rather than to full scenes and can be treated as unsupervised training areas. Color-Based Segmentation Using K-Means Clustering describes in the following steps. The basic aim is to segment colors in an automated fashion using the L*a*b* color space and K-means clustering. The entire process can be summarized in following steps Step 1: Read the image Read the image from mother source which is in .JPEG format, which is a fused image of part of Bhopal city of Madhya Pradesh, India with DWT fusion algorithm of Cartosat-1 and LISS-IV of Indian satellite IRS-P6 and IRS-1D. Step 2: For color separation of an image apply the Decor relation stretching Step 3: Convert Image from RGB Color Space to L*a*b* Color Space How many colors do we see in the image if we ignore variations in brightness? There are three colors: white, blue, and pink. We can easily visually distinguish these colors from one another. The L*a*b* color space (also known as CIELAB or CIE L*a*b*) enables us to quantify these visual differences. The L*a*b* color space is derived from the CIE XYZ tristimulus values. The L*a*b* space consists of a luminosity layer 'L*', chromaticity-layer 'a*' indicating where color falls along the red-green axis, and chromaticity-layer 'b*' indicating where the color falls along the blue-yellow axis. All of the color information is in the 'a*' and 'b*' layers. We can measure the difference between two colors using the Euclidean distance metric. Convert the image to L*a*b* color space. Step 4: Classify the Colors in 'a*b*' Space Using KMeans Clustering Clustering is a way to separate groups of objects. K-means clustering treats each object as having a location in space. It finds partitions such that objects within each cluster are as close to each other as possible, and as far from objects in other clusters as possible. K-means clustering requires that you specify the number of clusters to be partitioned and a distance metric to quantify how close two objects are to each other. Since the color information exists in the 'a*b*' space, your objects are pixels with 'a*' and 'b*' values. Use K-means to cluster the objects into three clusters using the Euclidean distance metric. Step 5: Label Every Pixel in the Image Using the Results from K-MEANS For every object in our input, K-means returns an index corresponding to a cluster. Label every pixel in the image with its cluster index. Step 6: Create Images that Segment the Image by Color. Using pixel labels, we have to separate objects in image by color, which will result in five images. Step 7: Segment the Nuclei into a Separate Image Then programmatically determine the index of the cluster containing the blue objects because K- means will not return the same cluster_idx value every time. We can do this using the cluster center value, which contains the mean 'a*' and 'b*' value for each cluster. The results of K-Means clustering methods describes by using the following figures 4. Figure 4. Steps by Steps of K-Means Clustering Method C. Differences of Edge Detection and K-Means Clustering Methods Table I: Differences of Edge Detection and K-Means Edge Detection K-Means Input Image JPEG and JPEG, BITMAP, Type BITMAP GIF, PSD (RGB Format) Resolution should be should be 150px 300 px and 400 px Method for Sobel gradient line Contour Normal Closed To decrease used gradient used L*a*b over lines format segmentation Method for only gradient using clustering detect image lines % of oversegmentation Processing Time All Rights Reserved © 2014 IJSETR 2.6% Fast 1.5% Fast 3 International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 In my opinion upon in these differences, both detection and K-Means Clustering methods advantages and differences. But, processing computation time of edge detection is faster processing time of K-Means Clustering Method. edge have and than The segmentation and merging window is shown by the following figure 7. In this window, the user can load an image that want to segment and merge. IV. DESIGN AND IMPLEMENTATION OF THE SYSTEM The following section describes about the design and the implementation of the proposed system. The implemented system used edge detection and K-Means clustering methods for image segmentation. A. Design of the Proposed System The propose system is used to compare between edge detection and K-Means clustering. methods for image segmentation and merging. If the system is start, the input image is income. This image will be segment by two methods: edge detection and K-Means clustering. The system shows the segmented result and then merges the segmented images. The system also compares the results of two methods: edge detection and K-Means clustering. Figure 7. Segmentation and Merging window The input image from user is shown the following figure 8. Start Input Image Segment image using Sobel Segment image using K-Mean Generate segmented images Generate segmented images Merge segmented images Merge segmented images Compare two results YES Figure 8. Input an Image More NO END Figure 5. Block Diagram The design of comparison between edge detection and K-Means clustering for image segmentation and merging is shown in the figure 5. After user give an image in the algorithm, the user can make segmentation and merging by using the input image. The system is also calculated describes segmentation time, merging time and image quality. The segmentation time and quality of edge detection about sobel edge detection algorithm is shown by the following figure 9. B. Implementation The main window of implemented system is shown by the following figure 6. This main window include main menu button and exit button. Figure 9. Segmentation using Sobel Edge Detection Segmentation using K-Means clustering window is shown by the following figure 10. Figure 6. Main Window of Implemented System All Rights Reserved © 2014 IJSETR 4 International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 Figure 13: Total Time and Total Quality Figure 10. Segmentation using K-Means Clustering The system will show the segmetation results for two methods: Edge detection and K-Means clustering. In figure 10: the system also shows and compare the segmetation time, segmentation quality. Therefore the user can decide which method is more better than another method. The merging using edge detection form is shown in the following figure 11: include time and quality. The comparison of edge detection and K-Means clustering is shown by the table II. Both two algorithms have advantages and disadvantages in time and quality of segmentation and merging. Processing time of edge detection is faster than the processing time of K-Means clustering. But the segmentation quality and merging quality of K-Means clustering is better than edge detection. Therefore, user can be used by choosing in these two algorithms. Table II : Comparison of Edge detection and K-Means clustering. Figure 11 : Merging using Edge Detection The merging using K-Means clustering. is shown by the following figure 12. Figure 12: Merging using K-Means clustering. The total time and total quality of the system is shown by the following figure 13. V. CONCLUSION The proposed system is used edge detection technique and K-Means clustering. technique for image segmentation and merging. In K-Means clustering, accept RGB format and convert to L*a*b format and working by the clustering procedures to detect foreground and background. The result of K-Means clustering is better and accurate than edge detection. The processing time of edge detection method is faster than K-Means clustering. method. But, the merged image quality of K-Means clustering is better than merged image quality of edge detection. ACKNOWLEDGMENT I am highly grateful to Dr. Myint Thein, Pro-Rector of Mandalay Technological University for his permission to write this paper. I would like to express deepest gratitude and special thanks to, Dr. Nang Aye Aye Htwe, Department of Information Technology, Mandalay Technological University, for her supervising, enthusiastic and suggestion. I would like to thank to all All Rights Reserved © 2014 IJSETR 5 International Journal of Science, Engineering and Technology Research (IJSETR) Volume 1, Issue 1, June 2014 teacher from Department of Information Technology, Mandalay Technological University, who give suggestions and advices for submission of paper. [1] [2] [3] [4] [5] [6] REFERENCES Nassir Salman, computer science department, Zarqa Private University of Jordan: Image Segmentation Based on K-Means clustering. and Edge Detection Techniques, 2006. ANIL Z CHITADE and DR. S.K. KATIYAR, Department of civil Engineering, MANIT, Bhopal, International Journal of Engineering Science and Technology Vol. 2(10), 2010, 5319-5325 Gullanar M.Hadi and Nassir H.Salman, Department of Software Engineering, Salahaddin University, Erbil, Iraq: A Study of Analysis of Different Edge Detection Techniques, 2010. Salem Saleh Al-amri, Dr.N.V.Kalyankar and Dr.Khamitkar S.D, Research Student Computer Science Department, Yeshwant Colledge: Image Segmentation by using Edge Detection. International Journal on Computer Science and Engineering, 2010. Yining Deng, B.S. Manjuanth and Hyundoo Shin, Department of Electrical and Computer Engineering, University of California, Santa Barbara, CA 931069560: Color Image Segmentation. Takumi Uemura, Gou Koutaki and Kelichi Uchimura, Graduate School of Science and Technology, Kumamoto University, Image Segmentation based on edge detection using boundary code, International Journal Innovative Computing, Volume 7, 2011. All Rights Reserved © 2014 IJSETR 6