Image Processing Using Morphology on Support Vector Machine Classiﬁcation Model for Waste Image

Sorting waste has always been an important part of managing waste. The primary issue with the waste sorting process has been the discomfort caused by prolonged contact with waste odor. A machine-learning method for identifying waste types was created to address this issue. The study’s goal was to create machine learning to solve waste management challenges by applying the most accurate categorization model available. The research approach was the quantitative analysis of the classiﬁcation model accuracy. The Kaggle dataset was used to collect and curate data, which was subsequently preprocessed using the morphology approach. Based on picture sources, the data was trained and used to classify waste. The Support Vector Machine model was used in this investigation and feature extraction via the Convolutional Neural Network. The results showed that the system categorized waste successfully, with an accuracy of 99.30% and a loss of 2.47% across all categories. According to the ﬁndings of this study, SVM combined with morphological image processing functioned as a strong classiﬁcation model, with a remarkable accuracy rate of 99.30%. This study’s outcomes contributed to waste management by giving an efﬁcient and dependable waste classiﬁcation solution compared to many previous studies.

cation. This research aims to determine the most effective classification model with the best accuracy by evaluating each model classification and its combination with the image processing done to it. Furthermore, these models seek to provide practical solutions to continuing waste management issues that contribute to garbage accumulation in the real world. The distinction between this study and prior studies is that it will produce a more accurate and unique approach based on its model classification and image processing. The difference can be explained by the accuracy produced, which is higher in our study than in earlier experiments employing alternative combinations. Despite advances in SVM-CNN morphological image processing algorithms for waste classification, recognizing their constraints is crucial for increasing waste classification system accuracy and dependability. This research focuses on the limits of these techniques and their performance in garbage classification tasks. In addition, this research plan to uncover and compare the novel contributions of SVM-CNN morphological approaches to previous work in the field.
The following is the study's contribution based on previous research. Accuracy Rate: The SVM-CNN morphological image processing methods utilized in garbage classification achieved an astonishing 99.30% accuracy rate. This high accuracy indicates that these solutions are effective in accurately categorizing diverse types of rubbish. Loss Rate: The 2.47% loss rate achieved demonstrates the robustness of the SVM-CNN morphological technique in reducing misclassifications and improving waste classification accuracy. Comparative Analysis: This study compares SVM-CNN morphological image processing methodologies to previous works in garbage categorization. By considering performance parameters such as accuracy and loss rates, we can assess the improvements and limitations of SVM-CNN morphological techniques. SVM and CNN model integration: When SVM and CNN models are combined in waste categorization, their complementing strengths can be used. SVM is great for feature selection and classification, whereas CNN is great at capturing spatial relationships in rubbish pictures, resulting in higher classification accuracy. Morphology-Based Image Processing: Incorporating morphology-based techniques into the SVM-CNN architecture further improves the garbage categorization system. Morphology techniques like erosion and dilation help to reduce noise and refine object boundaries, improving waste categorization accuracy. Computational Complexity: SVM-CNN morphological techniques necessitate computationally expensive operations, particularly during the CNN model training phase. Because of its complexity, real-time applications may be constrained or require massive processing resources.
The paper's restrictions are data variability and computational complexity. Variability in data: The SVM-CNN morphology algorithms may struggle to recognize trash objects when presented with considerable differences in lighting, image quality, and occlusions. The resistance of waste classification systems to such unpredictability remains a problem. While SVM-CNN morphological techniques achieve great accuracy rates, they may be limited in their ability to generalize to previously encountered trash objects or categories. The models may have difficulty classifying garbage objects that differ significantly from the training data distribution. This study is notable for combining two complex machine learning approaches, Support Vector Machine (SVM) and Convolutional Neural Network (CNN), to classify waste images. In contrast to previous studies that used various image processing techniques to prepare the dataset, this study only uses morphological image processing techniques. Furthermore, the study uses a dataset offered by Kaggle that contains waste images from various sources. The use of SVM and CNN in conjunction with morphological image processing distinguishes this study. This study's findings can shed insight into the efficacy of combining SVM and CNN for waste classification and how morphology image processing techniques can be used to generate datasets for waste classification. This study aims to improve waste management systems to make waste classification more precise, allowing for more effective and sustainable waste treatment strategies.

RESEARCH METHOD
This study mostly uses quantitative methodologies. The classification model's accuracy is quantitative, meaning the data is numerical. The researchers will examine the data and draw findings using mathematical and statistical approaches. The researchers may also utilize qualitative approaches such as observation or interviews to acquire information on the waste management process. However, the primary focus of the research is on the quantitative analysis of classification model accuracy. The research was carried out systematically, starting with collecting data for the dataset needed to test the system implemented to classify garbage images [20]. Figure 6 explains the complete research flowchart.

Data Collection
Data that contained waste images were taken from the Kaggle website [21]. The data collected is managed by many people involved so that a dataset is formed and ready to be managed in machine learning as research material and training data that is feasible to use. The data collected by Kaggle is downloaded and imported into a Python-based programming application. The data collected consists of training and validation data with a total of 25,077 data [21]. The dataset is formed with two categories, commonly called Image Processing Using . . . (Miftahuddin Fahmi) ISSN: 2476-9843 binary categories [22]. The two categories are waste categories based on their type, namely organic and inorganic waste [23]. This study's training and validation data ratio is 85% and 15%. The data is then entered into the Python system. Figure 1 and Figure 2 is one of the images from the original dataset. The dataset is imported into the array using NumPy, available in Python [24]. Labels containing waste categories based on type are converted into numbers so that the machine can understand the categories that have been determined [25]. The original image uses a red, green, and blue (RGB) color scale. The image pixels are uniformized by resizing them to a predetermined size, namely 64x64. Because the color scale of the original image is RGB, the input format for each image is 64x64x3 [26]. After that, regularization was carried out using the L2 method [27,28]. Morphology is another tool used in this study. Morphology in image processing is a technique for processing images that is based on a mathematical formula known as morphology [29,30,13]. Morphology is a fundamental image processing technique that is used to process the shapes and structures of images. This study's morphological method aims to improve the performance of the CNN-SVM classification model on garbage photos. The morphology process employs mathematical morphology operators such as erosion, dilation, opening, and closure to remove noise and unnecessary objects in each image. This study uses Python with the TensorFlow package to create the morphology method, which provides methods for applying morphology equations to photos. The morphological process improves the picture dataset's quality by strengthening its features and reducing its complexity, hence improving the accuracy of the CNN-SVM classification model. Morphology is included in the preprocessing stage of the flowchart Figure 6 using the following syntax.
for the label in labels: path = os.path.join(train data, label) for img in os.listdir(path): img array = cv2.imread(os.path.join(path, img)) kernel = np.ones((5,5),np.uint8) gradient = cv2.morphologyEx(img array, cv2.MORPH GRADIENT, kernel) In this syntax, the overall operation is carried out as follows. It loops through a list of labels. It builds a path for each label by linking the train data directory with the current label. It then uses os.listdir() to run through the files in the supplied directory. It reads the picture from each image file using cv2.imread(), which provides an image array. It uses np.ones() to define a kernel as a 5x5 matrix of ones. It uses cv2.morphologyEx() to perform the morphological gradient operation on the picture array. The morphological gradient is computed by subtracting the results of erosion and dilation operations. It is safe to assume that the morphology formula employed is the gradient morphology formula. The morphological gradient is calculated mathematically by subtracting the result of an erosion operation from the result of a dilation operation. In image processing and computer vision, erosion and dilation are important morphological procedures. They entail changing the shape and structure of objects inside a picture based on their spatial interactions with nearby pixels. These techniques are frequently used for applications including noise removal, feature extraction, segmentation, and morphological analysis [31][32][33].
Erosion aids in the removal of small or thin structures, noise, or solitary pixels from images. It can also be used to separate close-together things or smooth off objects' edges. Erosion erodes or reduces the size of things while darkening the image [31]. Dilation aids in the filling of gaps or holes inside objects, the joining of disconnected structures, and the enlargement of items in a picture. It can be used to recreate objects, smooth out boundaries, and highlight or thicken structures. Dilation tends to magnify things and brighten the image [32]. Denote the input image as A, the erosion operation as E, and the dilation operation as D. The morphological gradient G is calculated using Equation (1). D(A) denotes dilation of the input picture A, and E(A) denotes erosion of the input image A. The morphological gradient image G that results emphasizes the boundaries and edges of objects in the original image A. The dilation formula can be used to calculate D(A). Dilation is the process of expanding or thickening the shapes or objects in an image. The dilation formula is calculated using Equation (2).
The input image is represented by variable A in the dilation formula. The letter B denotes the structural element or kernel utilized for dilation. Moreover, it denotes the dilation operator. Dilation involves placing the structuring element B at each pixel of the input image A and assigning the maximum value within the neighborhood defined by B to the associated output pixel. The erosion formula can be used to generate E(A). Erosion causes the shapes or objects in an image to decrease or thin. The erosion formula is calculated using Equation (3). The input image is represented by variable A. The structural element or kernel utilized for the erosion operation is denoted by the letter B. representing the operator for erosion.
In erosion, the structuring element B is placed at each pixel of the input image A, and the associated output pixel is assigned the minimum value within the neighborhood defined by B. The dilation and erosion operations entail inspecting the surrounding area of each pixel in the image and changing its value based on specified criteria. Depending on the application and desired result, these processes' specific criteria and structure elements can vary. Figure 3 depicts the output of the plt. show function from the preceding code. Testing of the SVM model is based on the results of accuracy and loss tests that occur when training, validation, and test data are carried out. The training data will be compared with the validation data to conclude whether the training data is overfitting or not. If there is no overfitting, the test is continued by analyzing the results of the accuracy and loss percentages that occur in the test data. Testing test data can be calculated using the confusion matrix or simply with the results of the graphical analysis produced by matplotib [34].

CNN
CNN is a deep learning technique that has transformed the field of computer vision. They are mostly used for image recognition and categorization. CNNs are modeled after the structure of the human visual cortex and have numerous layers of filters or kernels that learn to extract various features from images, such as edges, forms, textures, and patterns. These filters are applied to the input image and generate feature maps, which are then passed via activation functions to add nonlinearity. The output feature maps of one layer are used as the input for the following layer, producing a feature extraction hierarchy. This procedure enables the network to learn complicated features and accurately categorize images [9].

SVM
SVM is a classification and regression analysis supervised learning technique. By maximizing the gap between the hyperplane and the nearest points in each class, SVM attempts to discover a hyperplane that optimally separates data points into various classes. The hyperplane is defined as the line that divides the data into the best possible classes. The data points closest to the hyperplane are referred to as support vectors in SVM and are utilized to define the hyperplane. SVM can handle nonlinear data by mapping it into a higher-dimensional space where it can be separated using a linear hyperplane. SVM is widely utilized in various applications, including image and text classification and bioinformatics [35].

CCN and SVM Combination
In this combination, the CNN first processes the input image to extract features. The SVM classification model is then given these features for final classification. Based on the features collected by the CNN, the SVM model makes the ultimate decision on the label of the input image [36]. The anticipated label of the input image is the model's output. A simplified block diagram of the CNN-SVM combo is shown in Figure 4. This research builds the system from the block diagram based on the following scheme. The first convolutional layer consists of a convolutional filter: of 32, convolutional kernel size: of 3x3, input shape: of 64x64 pixels with 3 color channels (RGB), activation function: of ReLU, and no dropout. The first convolutional layer uses MaxPooling2D with a pooling kernel size: of 2x2 and pooling strides: 2. Second convolutional layer consists of a convolutional filter: of 32, convolutional kernel size: of 3x3 input shape: output from the previous layer, which is 32x32 pixels with 32 channels. The activation function it used is ReLU with no Dropout. The second convolutional layer also uses MaxPooling2D with pooling kernel size: 2x2 and pooling strides: 2. The next layer is the normalization layer which consists of Flattening the output from the previous layer to a 1D vector. The next layer is a fully-connected layer which consists of several units: 128 and the activation function: ReLU. The last layer is the output layer which consists of several units: 1, kernel regularization: l2, optimizer: Adam, and the loss function is Hinge which is typically used for multi-class classification, which in this case is SVM-CNN model classification.
The metrics used are accuracy, and several batches are 64. The transfer function (activation function) used in the convolutional layers and fully connected layer is ReLU (Rectified Linear Unit). In contrast, the output layer uses the hinge activation function, which is commonly used for multi-class SVM (Support Vector Machine) classification. The output shape of the first convolutional layer is 32x32 pixels with 32 channels, and the output shape of the second convolutional layer is 16x16 pixels with 32 channels. The following Figure 5 is the SVM-CNN architecture based on the scheme from

Test and Evaluation
This study employs the morphological image processing method. The CNN-SVM combination is a machine learning methodology combining the strengths of two algorithms: Convolutional Neural Networks (CNN) and Support Vector Machines (SVM). The CNN technique extracts relevant features from raw picture data and reduces the input data's dimensionality. The SVM technique is then utilized to solve the classification problem by generating a hyperplane in the feature space that optimally separates the different classes. The CNN-SVM combo also includes using morphological image processing techniques to improve the classification model's accuracy. Morphology is an image processing method that involves applying a collection of operations to a picture to reduce noise, improve contrast, and emphasize the edges of objects in the image. Combining CNN, SVM, and morphological approaches enables more accurate waste image classification. This approach first utilizes the CNN algorithm to extract features from the input waste photos. The features are then sent into a pre-trained SVM classifier that has been tailored for waste image categorization. The morphological image processing method is then used for the garbage photos to improve the classification model's accuracy. The combined CNN-SVM and morphological image processing method produces a waste classification model that can accurately identify different types of waste based on their photographs. This model can be used to assist in the improvement of waste management procedures and the facilitation of more sustainable waste management practices.

RESULT AND ANALYSIS
Images that have been preprocessed to form a morphological image from the original image are entered into a classification system using Python with the SVM classification model. Python has a library called TensorFlow which can be used to build SVM models with the convolution layer as feature extraction. Data augmentation is carried out before the data is trained in a classification model to avoid overfitting the training data [37]. Overfitting is a condition where the training data continues to experience performance improvements every iteration while the validation data stops at a certain percentage [38]. This shows that the training data is too rigid, so testing with data other than training data is ineffective [28]. If the training data is not detected overfitting, then it can be tested on the test data how much the percentage of accuracy and loss that occurs in the test data. The model used is two layers in deep learning as feature extraction using the convolution layer and the pooling layer in deep learning. The feature extraction results are rendered in one-dimensional form using flatten normalization. After that, each feature extraction is performed with a full connection with a dense unit 128. After that, an output layer is created, which contains a hyperplane as an SVM model for classifying junk images.   Figure 8 shows that the comparison of the percentage of accuracy and loss between training data and validation data is not overfitting. The biggest difference between training and validation data occurs in the 4th iteration, with a percentage difference of around 6.35%. Figure 8 describes everything that happens in the 4th iteration. Until now, there is still no constant variable that determines the percentage difference between training data and validation as limiting data which is said to be overfitting. However, 6.35%, in general, is a small percentage to be categorized as overfitting training data. The results of accuracy and loss when tested using test data are 99.30% and 2.47%. Figure 10 is the result of tests carried out using machine learning that has been trained with training data and tested with test data. The results of this study compared to previous studies by Leonardo and Chu have several differences [10,11]. The first difference is that the data collection used is a dataset collected on Kaggle [21]. The second difference is that this study uses SVM combined with CNN as its classification model. SVM is used as a decision boundary (hyperplane) between predetermined categories to classify waste types, and CNN is used for feature extraction. The third difference is from the stages of image processing using the morphology method to determine the effectiveness of morphology on the performance of SVM image classification combined with CNN. In terms of the effectiveness of the overall performance compared to experiments that have been carried out without using morphology, it only shows that the performance results have not changed too much. The results of the performance accuracy of the SVM image classification model combined with CNN without morphology was 96.16%, while the morphology image processing showed only a change of around 3.14% in the experiment with the highest performance of 99.30%. Only the image processing is changed between the results of 96.16% and 99.30%. For other parameters, there is no change. Figure 11 is the result of research using the same test data but not using morphology image processing. For comparison, Table 2 explains the comparison with a parameter of model classification used, image processing method, similar dataset or not, accuracy result, and source of the research.  Waste classification by image processing has been an increasingly attractive study area in waste management. Two classification models have been frequently employed among the different approaches and methodologies available: Support Vector Machine (SVM) and Convolutional Neural Network (CNN). Furthermore, image processing techniques such as Local Binary Pattern (LBP), thresholding, and HSV color model with morphology have improved waste categorization accuracy. One study by Fahmi and Lubis [14] utilized the CNN algorithm to classify various types of waste, achieving an accuracy rate ranging from 60% to 99%. The most accurately classified waste type using CNN was bottles, with a 99% accuracy rate, followed by grass, which produced no read errors in the limited system tested in this study. These findings suggest the potential of CNN algorithm-based waste classification and management approaches. Another study by Musliman et al. [13] utilized the HSV color scale and morphology techniques in combination with K-NN, Naive Bayes, and MLP classification models to accurately identify and classify white blood cells, achieving an accuracy rate of 94%. This demonstrates the effectiveness of the proposed approach in accurately identifying and classifying objects of interest. Compared to this research, which used an SVM-CNN classification model with morphology for waste classification and achieved an accuracy rate of 99.30% with a waste dataset, it is evident that the latter strategy delivers superior results. The combination of SVM and CNN allows for a more accurate and comprehensive waste categorization, while the incorporation of morphology increases classification accuracy even more. This method could be especially useful in waste management systems where exact classification is required for effective recycling and disposal.
However, this approach has some general limits and considerations, such as complexity and computing requirements. SVMs can be computationally expensive, especially when dealing with CNN-extracted high-dimensional feature vectors. Training an SVM model on such data might consume substantial computer resources and time, limiting scalability for real-time applications [39]. The quality of the features extracted by the CNN also significantly impacts the performance of SVMs. The SVM's classification performance will suffer if the CNN fails to extract useful and discriminative features from the input images. SVMs are recognized for their black-box character, which means they are difficult to interpret. Understanding the decision-making process underlying SVM models can be difficult, especially when combined with complicated feature extraction methods like CNNs [40]. Because of the increasing processing needs for training and inference, SVMs may face difficulties when used in large-scale datasets. This shortcoming may limit the SVM's utility in real-world settings with enormous volumes of data [41].
SVM necessitates careful consideration of hyperparameters such as kernel type and regularization parameter. Choosing adequate hyperparameters can be a time-consuming and difficult operation, and poor choices may result in poor classification results [42]. Similar to the black-box nature of SVMs, morphological operations lack interpretability. It can be challenging to understand and explain the decision-making process behind the morphological transformations or the reasoning behind the resulting image changes. Morphology is based on simple shape-based operations such as dilation, erosion, opening, and closing [43]. While these operations work well for simple structures, they may struggle to handle complex or irregular shapes. Defining structuring elements or designing appropriate operations for complex structures can be challenging. While previous studies have demonstrated the effectiveness of SVM and CNN classification models and various image processing techniques, the use of a combined SVM-CNN model with morphology for waste classification has shown superior accuracy results. Further research in this area may lead to development of more effective and efficient waste management systems.

CONCLUSION
Based on the preceding comparison, it is possible to infer that both SVM and CNN classification models can be employed effectively for trash classification using image processing. Previous studies proved the efficacy of employing morphological techniques for image processing, reaching a high accuracy rate of 99.30% in garbage classification. This high accuracy rate is equivalent to, if not higher than, that of previous studies that used SVM or CNN models. The innovative aspect of this study is the use of morphological techniques that have not been widely investigated in earlier studies. According to the findings, these techniques could be a viable alternative to conventional image processing methods such as local binary pattern, thresholding, and multilayer hybrid feature extraction. The study's findings are important for waste management and classification processes, as precise and efficient waste categorization can lead to more successful waste management techniques. Waste management operations can be automated and optimized using image processing techniques like the ones utilized in this work, resulting in more efficient and cost-effective waste management systems. Despite the potential benefits of using image processing techniques for trash classification, there appears to be a lack of research in this field. This could be due to a lack of understanding of waste classification and management's possible benefits and complexities. However, the study's findings suggest that additional research in this area could result in substantial breakthroughs in waste management systems. There are various suggestions for future studies based on existing research, such as investigating the use of a mix of multiple image processing approaches. Future research could look into the usage of hybrid image processing approaches to improve waste classification accuracy. Other machine learning techniques, such as Random Forest, Decision Tree, and K-means clustering, could be used in future studies to increase trash classification accuracy. Future research could concentrate on establishing real-time trash categorization systems that can classify waste as it is generated. More study is needed to enhance waste classification accuracy using image processing and machine learning techniques. Previous study findings provide a solid foundation for future research on this topic, with potential implications including improved waste management systems, reduced environmental contamination, and promotion of sustainable development.

DECLARATIONS
AUTHOR CONTIBUTION The first author acts as the corresponding author, seeking funding for research, originator of ideas, and primary author. The second author is a theory and research activity supervisor for image processing. The third author is a supervisor in theory and research activity for image classification and editing.

FUNDING STATEMENT
The funding of this research is from the Muhammadiyah Lumajang Scholarship, which fully supports this research in improving the quality of education in Lumajang, East Java, Indonesia.