CLASSIFICATION OF MANGO FRUIT QUALITY BASED ON TEXTURE CHARACTERISTICS OF GLCM (GRAY LEVEL CO-OCCURRENCE MATRICES) WITH ALGORITHM K-NN (K-NEAREST NEIGHBORS)

Proses klasifikasi kualitas mutu buah mangga dengan cara konvensional menggunakan mata manusia memiliki kelemahan di antaranya membutuhkan tenaga lebih banyak untuk memilah, anggapan mutu kualitas buah mangga antar manusia yang berbeda, tingkat konsistensi manusia dalam menilai kualitas mutu buah mangga yang tidak menjamin valid karena manusia dapat mengalami kelelahan. Penelitian ini bertujuan untuk klasifikasi kualitas mutu buah mangga ke dalam tiga kelas mutu yaitu kelas Super, A, dan B dengan computer vision dan algoritma k-Nearest Neighbor. Hasil pengujian menggunakan jumlah k tetangga 9 menunjukan tingkat akurasi sebesar 88,88%.Kata-kata kunci— Klasifikasi, GLCM, K-Nearest Neighbour, Mangga


INTRODUCTION
Mango is one of the fruits that are popular in Indonesia and the mangoes are a type of fruit that has many varieties because it is currently cultivated. Some of the superior varieties of mango fruit include Arumanis, Gedong, Golek, and Manalagi Mangoes (Anonim1, 2015). In addition to having a sweet and refreshing taste, it turns out the mango fruit contains many nutrients that are beneficial to the health of the body. This fruit is also rich in vitamin E which makes the body more healthy and prevents various diseases. Sometimes mango farmers still use manual methods to distinguish the quality of the quality of the mango's maturity, while the methods carried out by human labor are often inaccurate and different in their determination. This difference is caused by different perceptions in everyone. Mango is included in tropical fruit, the maturity condition of tropical fruit will be very visible from the color, whether the fruit is still raw, half cooked, ripe or ISSN: 1410-8607 Techno Vol. 20, No. 1, April 2019 : 31 -40 already rotten. Therefore color feature extraction from tropical fruit will be used to determine the maturity level of the fruit for industrial purposes (Noviyanto, 2009).
The need for mangoes for export purposes requires handling quality so that they can compete with mango producers from other countries. One of the problems in handling quality is postharvest problems. Postharvest includes cleaning, sorting, storing, packaging and marketing. The sorting process is one of the processes that greatly determines the quality of the mangoes to be released to consumers. So far the quality identification in the mango sorting process is still done conventionally using human eyes that have limitations. The process of identifying quality in this way has several disadvantages including requiring more energy to sort, the level of human perception in terms of different fruit bleaching, the level of human consistency in assessing fruit quality does not guarantee because humans can experience fatigue (Syaefullah et al. 2011).

Texture Characteristics Analysis
Texture can be defined as a mutual relationship between the value of the intensity of repetitive neighboring pixels in an area wider than the distance of the relationship (Kadir and Susanto, 2013). In general, applications with texture characteristics can be divided into two categories, namely applications for the sake of segmentation and applications for texture classification, which use texture features for object classification. The method used to obtain texture characteristics can be divided into three groups, namely statistical methods, structural methods, and spectral methods. According to Kadir and Susanto (2013) Statistical methods use statistical calculations to form traits. An example that is included as a statistical method is GLCM (Gray Level Counseling Matrices). The structural method describes the arrangement of de elements in texture, an example of a structural method is shape grammar. The spectral method is a method based on the spatialfrequency domain, an example of a spectral method is the flourier domain energy distribution. Ahmad's (2002) study states that texture analysis is quite useful for detecting the presence of defects in mango skin. Texture analysis can be used in conjunction with examining the size of the mango through the area of the projection on the flat plane, to do the screening of Arumanis mangoes based on their size and the presence of defects on their skin. There are several texture traits including energy and entropy descriptors. An energy descriptor is a measure that states the intensity distribution of pixels against the range of gray levels. Entropy indicates the complexity of the image, the higher the entropy value in an image, the more the image complex will be. The definition of energy and entropy as shown in equation (1) and equation (2) below: Other characteristics of texture include contrast, homogeneity, inverse difference moment (idm), variance, and dissimilarity shown in equations (3) to (7) below: Texture characteristics to be sought are based on the intensity matrix gray level coefficient of matrix (GLCM). The cooccurrence matrix is defined by two steps, the first is to determine the distance between points in a vertical and horizontal direction, the second step is to calculate pairs of pixels that have the same intensity value according to the distance between predetermined Techno ISSN: 1410-8607 33

Classification Of Mango Fruit Quality Based On Texture…( Wahyu Wijaya Widiyanto)
points. The results of the calculation of each pair of intensity values are arranged on the matrix according to the coordinates (Ahmad, 2005).

Research Flow
This study focuses on digital image processing and the K-Nearest Neighbor algorithm. The input data is in the form of mango image data which amounts to 192 image data. The flow of research carried out in this study are as follows: 1. Collect data in the form of 192 image mango image data. 2. The process flow of the quality class quality classification system which includes several processes, namely the image acquisition process, then the digital image processing which includes preprocessing, segmentation, and feature extraction processes, then the characteristic data is stored in the database. Characteristic data will be used as input data during the classification process of quality class quality using the K-Nearest Neighbor algorithm. The design process flow of the classification system is shown in Figure 1: The image acquisition process is carried out on the mangoes that have been picked from the tree. The acquisition process is carried out on the mangoes that have been classified according to the quality class, namely the Super class, class A, and class B. The quality classification process is carried out by mango farmers who are experts in assessing the quality of mangoes. 1. The preprocessing process is carried out with the aim of increasing the likelihood of success at the stage of further processing of an image. Operations performed at the preprocessing stage include resizing and gray scaling operations. Resizing is the process of changing resolution or changing the horizontal and vertical size of an image. The resizing operation is done is to change the size of the image from its original size, which is 3264 x 1836 pixels to 1024 x 575 pixels with the aim of speeding up the processing of digital images, because the larger the size of the image it will affect the time needed for digital image processing. 2. Image segmentation is a process that is intended to get objects contained in the image or divide the image into several regions with each object or region having similar attributes. In objects that contain only one object, the object is distinguished or separated from its background, so that what is to be processed in the next stage is the part of the image that includes the object image only. Segmentation by selecting the threshold value automatically can be done using the Otsu method. This method determines the threshold value by distinguishing two groups, namely objects and backgrounds, which have parts overlapping, based on histograms (Kadir and Susanto, 2013). 3. GLCM texture feature extraction to be searched uses distance (1.0), which means one pixel to the right and zero pixels to the bottom, or pixel pairs that must be calculated are those that are one pixel apart from the angle of 00, as shown in Figure 2: In Figure 5a, the image is 5x5 in size and has three intensity values, namely 0, 1 and 2, then the GLCM will be 3x3. The distance between the specified pixels is d = (1, 0), which means one pixel to the right and zero pixels down. Then count the number of pairs of pixels, where the first pixel has an intensity value of i1 and the pair spaced d has an intensity value of i2, and is entered into column i1 and row ke-i2 on GLCM. For example, in the first pixel pair which has an intensity value (2, 1), there are 2 pairs so that the value 2 is entered into column 2 row 1 on the GLCM. Figure 5b. shows the GLCM resulting from calculating the entire pixel pair. After the GLCM matrix is formed, texture characteristics can be calculated based on the matrix. 4. The process of estimating or classifying the quality grade of mangoes using the k-Nearest Neighbor algorithm will be carried out several times using a variable k value to determine the best value of accuracy.

K-Nearest Neighbour(K-NN)
KNN is a classification method that determines categories based on the majority of categories in the nearest k-neighbor. If D is a set of training data then when the test data d is presented, the algorithm will calculate the distance between each data in D with test data d. distance calculation is done using the Euclidian distance. Then k the data in D which has the closest distance to do is taken. The set k is the k-nearest neighbor. Furthermore the category of test data d is determined based on the label of the majority of categories in the closest set of k-neighbors (Farsiah, et al, 2013). Or simply the steps of the KNN algorithm are as follows: 1. Determine k. 2. Calculate the distance between the new data to each labeled data. 3. Determine k labeled data that has the least distance. 4. Classify the new data into majority labeled data.
Calculation of distance can be searched using the euclidian distance shown in equation (8): Techno ISSN: 1410-8607 35

Classification Of Mango Fruit Quality Based On Texture…( Wahyu Wijaya Widiyanto)
3 SEARCH RESULT All quality class classification system processes that will be built include several processes, namely beginning with the image acquisition process, digital image processing that is equipped with pre-processing, segmentation, and feature extraction processes, then the data displayed is in accordance with the database. Characteristic data will be used as input data during the quality class classification process using the K-Nearest Neighbour algorithm. Image taking is done on the mangoes that have been picked from the tree. The acquisition process is carried out on mangoes that have been done based on the quality class in the Super class, class A, and class B. The process of quality classification is carried out by mango farmers who are experts in assessing the quality of mangoes.

A. Pre-processing
The prepossessing process is carried out with the aim of increasing the likelihood of success at the stage of further processing of an image. Operations performed at the prepossessing stage include resizing and grayscalee operations. Resizing is the process of changing resolution or changing the horizontal and vertical size of an image. The resizing operation is done is to change the size of the image from its original size, which is 3264 x 1836 pixels to 1024 x 575 pixels with the aim of speeding up during the process of digital image processing. The prepossessing stage is shown in Figure 4. below:

B. Segmentation
Image segmentation is a process that is intended to get objects contained in the image or divide the image into several regions with each object or region having similar attributes. In objects that contain only one object, the object is distinguished or separated from its background, so that what is to be processed in the next stage is the part of the image that includes the object image only. Segmentation by selecting the threshold value can automatically be done by the Otsu method. This method determines the threshold value by distinguishing two groups, namely objects and backgrounds, which have parts overlapping, based on histograms (Kadir and Susanto, 2013). The principle of the Otsu method to obtain a threshold value is shown by the flow diagram in Figure 5 below:

C. Extraction of GLCM texture features
GLCM texture feature extraction to be searched uses distance (1.0), which means one pixel to the right and zero pixel to the bottom, or pixel pairs that must be calculated are those that are one pixel apart from the angle of 00. The process of getting the GLCM is shown in Figure 6 below: Figure 6. GLCM Process After obtaining GLCM, the next step is to look for energy features, entropy, contrast, homogeneity, Idm, variance, and dissimilarity using equation (1) to equation (7). The process of obtaining the texture features obtained from the GLCM is shown in Figure 7

D. K -Nearest Neighbor
The classification process of the mango fruit quality class using the k-NearestNeighbour algorithm will be conducted several times using a variable k value to determine the best value of accuracy. The classification process with k-Nearest Neighbour is shown in Figure 9 below:

E. Results Of Implementation Of The Prototype Interface For Users
User interface prototype is the stage of making prototypes in the display section of the prototype, or in this case is the creation of a user interface that functions as a page to communicate between users and systems. Figure 9 shows the implementation of the prototype main interface page: The interface page of the testing process serves to display the testing process, from the test results it will be known how many percentages of success in the classification, it is known how many and in which mango quality class there is a classification failure. The interface page of the testing process is shown in Figure 10 below:

F. Feature Extraction Results
The feature extraction process will produce GLCM texture feature values including energy features, entropy, contrast, homogeneity, idm, variance, dissimilarity. Table 1 shows the average value of GLCM texture feature extraction for each class of mango qualityobtained from the feature extraction process through prototype experiments.

G. Test Results
Testing the quality classification system for mangoes is based on test data. The classification process of the mango fruit quality class using the k-Nearest Neighbour algorithm will be conducted several times using the k value varies for know the value of the best accuracy. The test data is 36 data consisting of 12 test data for each quality class.
The accuracy of the classification system of the mango quality class is calculated by equation (9). In Table 2 it can be seen the number of images recognized according to the class. It can be concluded that by using the number of k neighbors 9 produces the best accuracy value, namely 32 test image data identified and 4 test image data not recognized according to the quality class or an accuracy rate of 88.88%.

CONCLUSION
Based on the results of the research classification of the mango quality class based on the characteristics of the GLCM texture using the k-Nearest Neighbour algorithm can be concluded as follows: The classification process of the mango quality class was carried out using a prototype that had been successfully designed and made using digital image processing technology for extracting the GLCM texture features of mango images and the K-Nearest Neighbor algorithm for its classification method. homogenity, idm, variance and dissimilarity, GLCM texture features and k-Nearest Neighbor algorithm can be used to classify the quality of mangoes. The test results in Table 2 show the best accuracy value is the number of k Neighbor 9 with an accuracy value of 88.88%. Suggestion for the sake of further research is the classification process using other methods or algorithms in the hope that the results of the classification obtained will be better and more accurate, Trying to extract other features from form features, texture features or color features, in the hope of getting discriminatory features the high for each quality class and the time in the required image feature extraction process is faster.