APPLICATION FUZZY MAMDANI TO DETERMINE THE RIPENESS LEVEL OF CRYSTAL GUAVA FRUIT

. Crystal guava is one of Indonesia's flora diversities. The rind of the unripe crystal guava fruit is green, and the rind of the ripe crystal guava fruit is yellowish green. However, it is difficult to determine the ripeness of crystal guava due to the similar color of the fruit skin. Determining fruit ripeness is uncertain and therefore requires a way to deal with this uncertainty. One of the methods you can use is fuzzy Mamdani. In this study, the ripeness level of crystal guava is determined using fuzzy Mamdani. Crystal guava fruits fall into four ripeness categories: raw, half ripe, ripe, and very ripe. The data used is in the form of an RGB image separated from the background so that only crystal guava fruit objects are captured. The image of the fruit object was then extracted by looking for the median red, green, and blue at each pixel of the image. This value is used as input for the fuzzy Mamdani process. The fuzzy set and fuzzy rules that have been formed can be applied to determine the maturity level of crystal guava fruit by validating the results of 140 image data with an accuracy of 83,5%.


INTRODUCTION
Indonesia is a country with a tropical climate that has a diversity of flora. Crystal guava is one of the diversities of flora in Indonesia. This type of guava has advantages such as the relatively small number of seeds ranging from 3% of the fruit size [1]. This fruit also has a crunchy flesh texture and a fresh sweet taste [2]. Farmers prefer this variety of guava because it is simple to grow and can produce fruit all year long [3]. This fruit has a high selling value compared to other varieties of guava [4]. People used to use crystal guava fruit from raw to ripe.
The process of determining the ripeness of crystal guava fruit is usually done manually by paying attention to the color of the fruit's skin. Crystal guava fruit that is still raw has green skin, while ripe fruit has yellowish green skin [5]. However, determining the ripeness of crystal guava fruit is difficult because of the similarity of color on the skin of the crystal guava fruit from raw to ripe. Determination of the ripeness of crystal guava fruit is uncertain because of the similarity of color on the skin of the fruit. This is why we need a method that can handle the uncertainty of determining the ripeness of crystal guava fruit. Fuzzy logic can solve problems that contain uncertainty [6].
A fuzzy Inference System is a rule system based on fuzzy logic. One method of fuzzy inference system is the Mamdani method. The Mamdani method or commonly known as the Min-Max method was first introduced by H. Mamdani in 1975. The Mamdani method is a method that uses the MIN implication function and the composition of the MAX rule. Fuzzy Mamdani is a fuzzy inference that is simple and easy to understand [7].
Many previous studies regarding the determination of fruit ripeness have been carried out, Mulato [8] conducted a study on the classification of red guava fruit ripeness using fuzzy Mamdani. The results obtained show a fuzzy accuracy of 83.3%. Lustini et al [9] also researched the classification of pineapple ripeness using fuzzy logic. The results obtained indicate an accuracy rate of 86.67%. Another study was conducted by Muthiati et al [10], who conducted a study on the detection of tomato ripeness. The ripeness level of the fruit is classified using fuzzy logic. Arief [11] conducted a study on the classification of citrus fruit ripeness. The fruits were classified based on color features using the SVM method. This research will determine the ripeness level of crystal guava fruit using fuzzy Mamdani. Crystal guava is categorized into four categories, namely raw, half ripe, ripe, and very ripe. It is hoped that by determining the ripeness of crystal guava fruit using fuzzy, the ripeness of the fruit can be more easily determined and more accurate.

Data Collection
The first stage in this research is data collection. The image data used is 140 data consisting of 35 image data of crystal guava fruit in each category of ripeness level. Image data was taken with the Vivo Y30 smartphone camera with a white background.

Pre-Processing Data
In this step, the object and background are separated so that only the crystal guava fruit object is taken.

Feature Extraction
Image is one of the multimedia components that play an important role as a form of visual information. Image has characteristics that are rich in information. A digital image is a collection of pixels arranged in a matrix form. Each element in a digital image (element matrix) is referred to as a pixel (pixel) [12]. A color image or RGB image is an image in which each pixel has three color components, namely red (red), green (green), and blue (blue) components. Each color component has a pixel intensity value starting from 0 to 255. For example, a pixel that has a color intensity value of 255 in the red layer, 255 in the green layer, and 0 in the blue layer will produce a yellow color [13]. An illustration of an RGB image can be seen in Figure 1.
In this step, the crystal guava object image obtained from the previous stage is extracted by finding the average Red (R) value, Green (G) average value, and Blue (B) average value for each image pixel. These values are used as inputs in the Mamdani fuzzy process.

Application of Fuzzy Mamdani
Fuzzy logic was first introduced by Prof. Lotfi Zadeh in 1965. Fuzzy logic is generally used to solve problems that contain an element of uncertainty. The level of true or false in fuzzy logic depends on the weight of the membership [14]. A fuzzy Inference System is a rule system based on fuzzy logic. One method of fuzzy inference system is fuzzy Mamdani. Fuzzy Mamdani or commonly known as the Min-Max method was first introduced by H. Mamdani in 1975. This method works based on linguistic rules.
In this step, fuzzy sets are formed and fuzzy rules are drawn up based on data training. The inputs used are Average Red, Average Green, and Average Blue variables, while the output used is ripeness level. There are four stages in the Mamdani fuzzy calculation, including:

a. Fuzzification
At this stage, the process of converting firm values (crisp) into fuzzy sets is carried out. The fuzzy set is grouped into a fuzzy variable based on its linguistic level. For each fuzzy set, the domain and membership function are determined which are then used to determine the membership value of each fuzzy set based on the input variables.

b. Application of The Implication Function
At this stage, the preparation of rules that state the relationship between input variables and output variables is carried out. The general form used to construct fuzzy rules can be written as follows [14], After forming the fuzzy rules, then determining the membership value based on the fuzzy rules that have been formed using the MIN implication function. By using AND operator, the results are obtained by taking the smallest membership value between elements in the set in question.

c. Composition of rules
At this stage, the process of merging the membership function from the applicable rules of the implication function is carried out. This merging process uses the MAX method. The fuzzy set solution is obtained by taking the maximum value of the rule, then using it to modify the fuzzy region and apply it to the output. If all the rules have been evaluated, then the output will contain a fuzzy set that describes the entire rule.

d. Defuzzification
Defuzzification is a process of converting fuzzy sets into crisp values. The input in the defuzzification stage is a fuzzy set obtained from the composition of the rules, while the output obtained is a number in the domain of the output variable fuzzy set. The method commonly used in the defuzzification stage is the centroid method (center point). In general, the centroid method can be written as Equation (2).

Result Analysis
In this step, the results are validated by comparing the results of determining the level of fruit ripeness by farmers and the fuzzy program. The level of fuzzy accuracy used can be calculated by validating the results using the following Equation (3).

Pre-Processing Data
The data that has been collected, then separated the image of the fruit from the background, so that only the image of the crystal guava fruit object is taken. An example crystal guava fruit of the results of preprocessing data before the background separation can be seen in Figure 2 (a) and after the background, separation can be seen in Figure 2

Feature Extraction
Feature extraction is done to obtain the characteristics or information contained in an image or image. The image of the crystal guava fruit object that has been separated from the background is then extracted so that 3 information is obtained in the form of an average value of Red, an average of Green, and an average of Blue. This information is used as input to the fuzzy process. The value of the Red average, Green average, and Blue average are obtained from the calculation of the average Red value for each image pixel, the average Green value for each image pixel, and the average Blue value for each image pixel. Example of feature extraction results in Figure 2

Fuzzy Set Formation
In this study, three inputs were used in determining the ripeness level of crystal guava fruit which included Red Average, Green Average, Blue Average, and one output in the form of fruit Ripeness Level. The formation of fuzzy sets is carried out on each variable. The Red Average variable is grouped based on its linguistic level into several fuzzy sets, namely low, medium, and high. Likewise for the Green and Blue variable average. Meanwhile, the Ripeness Level output variable is grouped into several fuzzy sets, namely raw, half ripe, ripe, and very ripe.
The fuzzy set that has been formed is then searched for the domain value in each fuzzy set. This domain contains values in the universe of speech, but can also be operated in fuzzy sets. Domains are determined based on training on the data used. In the data training process, the domain can be changed by shifting the domain value so that the correct domain is obtained for each fuzzy set used.  For each variable, its membership function is determined. The membership function is a curve that shows the mapping of input points into membership values with an interval of 0 to 1 [15]. The determination of the membership function in a fuzzy set can be different for each person. This is due to individual differences in expressing abstract concepts. However, the determination of the membership function must still reflect the issues discussed.
In this study, the membership function of the shoulder curve and the triangular curve were used to represent it. This form is suitable for representing fuzzy sets based on training on more accurate data. The Red Average variable consists of three low, medium, and high fuzzy sets. In the low and high Red Average variables, the left shoulder and right shoulder curve representations are used. The Red Average variable is being used as a triangular curve representation. The membership function for the Red Average variable is shown in Equations (4), (5), and (6). The membership function of the Red Average variable can be seen in Figure 2. The Green Average variable consists of three low, medium, and high fuzzy sets. The membership function for the Green Average variable is shown in Equations (7), (8), and (9). The membership function of the Green Average variable can be seen in Figure 3.   The Blue Average variable consists of three low, medium, and high fuzzy sets. The membership function for the Blue Average variable is shown in Equations (10), (11), and (12). The membership function of the Blue Average variable can be seen in Figure 4.  The Ripeness Level variable consists of four fuzzy sets: raw, half ripe, ripe, and very ripe. Raw and very mature Ripeness Level variables were used to represent the left and right shoulder curves. In the halfripe and ripe Ripeness Level variables, a triangular curve representation is used. The membership function for the Ripeness Level variable is shown in equations (13), (14), (15), and (16). The membership function of the Ripeness Level variable can be seen in Figure 5.

Fuzzy Rules
After forming a fuzzy set, then determine the fuzzy rules. Fuzzy rules are indicated by the presence of a set of linguistic statements. The formation of fuzzy rules is based on the relationship between one set and another [16]. Based on Equation (1) and the data training that has been carried out, there are 27 fuzzy rules used in this study. Determination of fuzzy rules can be written as follows: [R1] IF (Red Average is Low) AND (Green Average is Low) AND (Blue Average is Low) THEN (Ripeness Level is Raw), [R2] JIKA (Red Average is Low) AND (Green Average is Low) AND (Blue Average is Medium) THEN (Ripeness Level is Raw), etc. The overall rules used can be seen in Table 3.

Fuzzy Mamdani Calculation
Fuzzy sets and fuzzy rules have been formed based on data training, to make it easier to use using MATLAB software. The results obtained are then presented in the MATLAB GUIDE display. The program cannot directly determine the level of ripeness of crystal guava fruit. The user must input an image of a crystal guava fruit, then perform feature extraction, so that the Red Average (R), Green Average (G), and Blue Average (B) values are obtained as input in the Mamdani fuzzy process. After passing the Mamdani fuzzy process starting from fuzzification to defuzzification, the output level of crystal guava fruit ripeness will be obtained. The MATLAB GUIDE display can be seen in Figure 6.  In composition, at this stage, the membership function of each rule is combined at the evaluation stage using the MAX method. The MAX method is carried out by taking the maximum value of the results of the evaluation of the rules in each fuzzy set of output variables. The results of the composition of the rules can be seen in the graph in Figure 6. 4. Defuzzification, at this stage the fuzzy set resulting from the composition of the rules is converted into a crisp value using the centroid method based on Equation (2). In this image, the final defuzzification value is 32.4825. The value obtained is then adjusted to the output linguistic variable. The results showed that the fruit was in the half-ripe category.

Result Analysis
In this study, validation results were carried out on 140 image data used. Validation is done by comparing the determination of the level of fruit ripeness between farmers and whether the program is appropriate or not. The validation of the results that have been carried out can be seen in Table 4. Based on Table 4, the results obtained are 117 correct image data and 23 incorrect image data. The raw category of guava fruit image data that matched between farmers and the program amounted to 34 out of 35 raw category image data. The image data for the correct ripe category is 29. The image data for the ripe category is 27. The image data for the very ripe fruit category is 27. The fuzzy accuracy used can be calculated as follows: = 117 140 × 100% = 83.5% Determination of the level of ripeness of crystal guava fruit with four categories of ripeness levels raw, half ripe, ripe, and very ripe can be done using fuzzy Mamdani. The fuzzy set and fuzzy rules that have been formed can be applied to determine the ripeness level of crystal guava fruit with a fuzzy accuracy of 83.5%.

CONCLUSIONS
Determining the ripeness of crystal guava using fuzzy Mamdani is performed by extracting features on the fruit image and then forming fuzzy sets and fuzzy rules. The result of the feature extraction is in the form of a red, green, and blue average for each image pixel and is used as input for the fuzzy Mamdani process. The formed fuzzy sets are obtained through data training based on the results of feature extraction. 27 fuzzy rules are used. Verification of the results was performed with 140 test data, with 117 correct image data and 23 incorrect image data. As a result of the test, the fuzzy accuracy was 83.5%.