Three Machine Learning Techniques for Melanoma Cancer Detection

Document Type : Research Paper


1 UNITAR Graduate School, UNITAR International University, Malaysia.

2 Universiti Kuala Lumpur (UniKL) Business School, Malaysia.



The application of machine learning technologies for cancer detection purposes are rising due to their ever-increasing accuracy. Melanoma is one of the most common types of skin cancer. Detection of melanoma in the early stages can significantly prevent illness and fetal death. The application of innovative machine learning technology is highly relevant and valuable due to medical practitioners' difficulty in early-stage diagnoses. This paper provides an open-source tutorial on the performance of an algorithm that helps to diagnose melanoma by extracting features from dermatoscopic images and their classification. First, we used a Dull-Razor preprocessing method to remove extra details such as hair. Next, histogram adjustments and lighting thresholds were used to increase the contrast and select lesion boundaries. After using a threshold, a binary-classified version of image was obtained, and the boundary of the lesion was determined. As a result, the features from skin tissue were extracted. Finally, a comparative study was conducted between three methods which are Artificial Neural Network (ANN), Support Vector Machine (SVM) and K-Nearest Neighbor (KNN). The results show that ANN could achieve better accuracy (83.5%). In order to mitigate the biases in existing studies, the source code of this research is available at to serve aspiring researchers for improvement, correction and learning and provide a guideline for technology manager practitioners.



Skin cancer is one of the most common cancer and is projected to increase in incidence over the coming decades. Melanoma is the most dangerous type of skin cancer, and with the growth of the lesion, the chances of treatment are significantly reduced. Diagnosis of melanoma in the early stages can reduce or prevent mortality; however, diagnosis is fraught with severe technicality. It is fallen on technology management specialists to get to know the latest technology development in a hands-on capacity to unleash the potential of artificial intelligence in health sectors. Adopting and managing technologies requires a comprehensive understanding of how these technologies can contribute to solving problems that otherwise were not feasible to overcome. Skin cancer detection is one prime example due to the severe challenge exposed to human experts for early-stage diagnosis. Since diagnosing the disease in the first stages is complex, even by expert specialists, providing an effective method for diagnosing melanoma's early stages is highly beneficial and valuable (Leiter, Keim, & Garbe, 2020). The analysis of damaged skin tissue is considered one of the non-native techniques for diagnosing skin complications. The traditional cancer diagnosis methods involve a dermatoscopy of skin tissue images, which requires experience. The problem arises when the accuracy of diagnosis in the dermatoscopic setting is heavily correlated with human experts who are not prone to error. Therefore, the machine learning-aided approach emerges as a reliable alternative to mitigate such a risk (Rigel, Russak, & Friedman, 2010).

The research on skin cancer detection has been ongoing, and various state-of-the-art solutions have been introduced in recent years. However, this study focuses on technology management awareness by providing an open-source and reproducible implementation that has not been associated with the majority of recent years' research. This study has been designed to examine and introduce the performance of contemporary machine learning classification in an open-source contribution. Typically, the intelligent skin detection system operates within four main stages: 1. Image preprocessing, 2- Image segmentation, 3- Feature extraction and selection, and 4- Images feature classification using machine learning. This process has illustrated in Fig 1 as illustrated below:



Figure 1. Four stages of Intelligent Skin Cancer Diagnosis

The most crucial step for diagnosing skin cancer from the images is the area of skin lesions and their boundaries. However, noises such as hair, skin lines and air bubbles make it difficult to correctly detect the lesion boundary. Several methods have been proposed to determine the boundary of skin lesions in dermatoscopic images that can be referred to some other research (Emre Celebi et al., 2007; Emre Celebi et al., 2008; Emre Celebi, Wen, Hwang, Iyatomi, & Schaefer, 2013; Sayed, Soliman, & Hassanien, 2021). In the following sections of this article, the background of the study with a focus on the methodology, results and discussion, future works and conclusion are included respectively.  

Literature Review 

After the diagnosis of the lesion of the skin, the stage of extracting the features related to skin lesions is located. Determining the exact characteristics will significantly influence the efficiency of the skin cancer detection system; therefore, if the input characteristics are incomplete, the diagnostic system may not function properly. The ABCD method, one of the most basic and effective extraction techniques for dermatoscopic images, was developed by a group of researchers at the University of New York in 1985. This method is derived from the characteristics of A = Asymmetry, B = Border, C = Color, and D = Diameter, respectively (Stolz, 1994). Most automated diagnostic algorithms extract a feature based on this rule  (Cheng et al., 2008; Christensen, Soerensen, Linghui, Chen, & Jensen, 2010). Accordingly, the symmetry index evaluates the results of the symmetry of the lesions. The boundary index is used to estimate the boundary of the waste. The colour index determines the number of colours in the studied lesion, and the diameter index that for melanoma, a diameter larger than 6 mm is considered. Among these four features, symmetry is considered the most critical indicator in the description of lesions and is based on two parameters of shape and colour.

The proposed method in this study consists of three steps: preprocessing, segmentation for lesion separation, attribute extraction and classification. In the first step, image preprocessing is performed to improve the image quality and eliminate the effects of hair by the famous Dull Razor technique (Lee, Ng, Gallagher, Coldman, & McLean, 1997). In the second step, the segment separates the lesion from other regions (background regions). Histogram modulation and lightning thresholds were used to isolate the lesion area in order to increase the contrast and choose the lesion boundaries, respectively. After determining the boundaries of the lesion, various features such as gradient cooccurrence matrix extract the skin tissue features in terms of shape and colour properties of the RGB space. Finally, the classical accuracy for the intended features is obtained by comparing the three classifiers: the Multilayer Artificial Neural Network (MANN), the Support Vector Machine (SVM), and the Neighbouring.

A.     Image Repository and Preprocessing

The input data are dermatoscopic images of skin lesions derived from the PH2 dataset provided by Universidade do Porto, Lisboa T'ecnico and the Dermatological Service of Hospital Pedro Hispano in Matosinhos (Mendonça, Ferreira, Marques, Marcal, & Rozeira, 2013). In Fig. 2, examples of these images are shown. The image  data set is presented in a dimension of 560 × 768 and interpreted into three different classes: common lesion, unusual lesion and lesion of the lumen. The total numbers of images taken are 200, including  80 images of typical lesions, 80 images of unusual lesions, and 40 images of melanoma lesions. The first stage in the detection process to ensure that picture does not contain extra elements, such as noise and hair, that may critically impact diagnoses. Therefore, the Dull Razor  filter was used to remove hair. This filter replaces the pixel containing hair with its neighbouring pixels. Figure 3 shows the effect of applying this filter on one of the images.

Figure 2. Mammography images of skin lesions



Figure 3. Apply a Dull Razor removal filter

In order to diagnose melanoma skin disease, skin lesions should be resolved into machine-understandable elements by image processing methods that make it ready for considering features, such as skin tissue, shape, and colour properties of skin lesions. The extraction of these features is considered in this study. In this section, we first describe the method of dissociation of the lesion from the skin, and then, the properties extracted from the skin lesions are explained. The following steps for selecting and distinguishing the lesion from the marginal skin were initially imaged and resized into 256 × 256 resolution to increase the image's clarity. Moreover, histogram equalization (Lim, Mat Isa, Ooi, & Toh, 2015) was used to enhance the contrast of the lesion's resolution from the marginal skin. Next,  The threshold method was adopted for selecting the lesion from the main images and extracting skin tissue, colour and shape of the area. The following sections briefly explain the histogram equalization method and the threshold method.

B.     Histogram and Threshold Method

In order to facilitate the interpretation of images for automated processing systems, an image enhancement technique that involves changes in the image intensity is used. The existing literature  (Vyas, Yu, & Paik, 2018) highlighted the "contrast" as one of the critical qualitative factors in processing images, which can contribute to all the rest features involved in the processing. Histogram equalization is the most common method for enhancing contrast, which is used for almost all types of images due to its simplicity and relatively good performance. The main idea of this method is to re-map the grey levels of the input image based on the uniform expansion of the Probability Density Function (PDF). Meanwhile, the dynamic range of the image's histogram flattens the image and allows the contrast of the input image to increase as much as possible. Figure 4 shows the difference in skin lesions before and after the contrast enhancement by the histogram equalization method.

The threshold is a critical method for image segmentation. The main objective of the threshold- methods is to find a threshold value. In order to achieve this objective, the image pixels are divided into two groups. The two-level thresholding is usually straightforward, and the thresholds are usually at the edge between the two peaks of the grey-level histogram. The Fig. 5 shows the process of segmentation in below.

Figure 4. Improves image quality by Histogram Equalization


Figure 5. Split skin lesions through a two-level threshold method


C.     Image Segmentation and Feature Extraction 

ABCD law, the characteristics of the lesion, such as symmetry, boundary, colour, and diameter of the area, are considered for assessing the condition of the lesion. According to this approach, the extracted properties of skin images are divided into three parts: border or shape properties, skin tissue properties, and colour properties (Senan & Jadhav, 2021; Stolz, 1994).  

The skin tissue properties that distinguish tissue quality, such as thin, rough and irregular, have been extracted in this study. The extracted tissue properties derived from the Gray Level Co-occurrence Matrix (GLCM) are expressed in Table 1 (Maurya, Singh, Maurya, & Kumar, 2014). Other features that have been used in this study are shape characteristics. Characteristic features are area, perimeter, major axis length, Minor axis length, compactness, eccentricity, asymmetry, rectangularity, solidity, elongation, convexity, orientation, convex area, and equiv diameter. In addition to the skin tissue and shape features, colour properties are derived as the third group of features in this study. In this category of features, taking into account the colour space of RGB, the values of red, yellow and green layers were extracted, and each of these layers was calculated from the statistical parameters of variance and mean.

In total, it is possible to state that in this study, 27 features were considered for each photograph, 7 of which have skin tissue characteristics, 14 feature properties and six features related to colour properties, as detailed in Table 1 below.

Table 1. Definition of Skin tissue properties


Skin tissue feature


Energy feature


Entropy feature


Contrast feature


Homogeneity feature


Correlation feature


Shade feature


Prominence feature


Pij= Element i,j of the normalized symmetrical GLCM

N= number of grey levels in the image as specified by the number of levels in under quantization on the GLCM skin tissue page of the variable properties dialogue box.

μ = The GLCM, an estimate of the intensity pixels in the relationships, is calculated in Equation (1) as follows.


The variance of the intensities of reference pixels related to GLCM is calculated in Equation (2) as follows.


The rest of ABCD law such as A, C (Correlation feature) and B are detailed in the following Equation (3), (4) and (5) as detailed in follows:



The early stage of this study was devoted to describing the image processing techniques that are needed to quantify the images into numerical features for classification purposes. The imperative role of ABCD laws, along with other processing techniques, is to extract numerical features from images that can be used for classification into two primary cancer and none cancerous categories. This research classified the characteristics using three classifiers: multilayer perceptron artificial neural network, support vector machine, and K-nearest neighbour. Each of the classes is described in succinct fashions in the followings.


A.    Artificial Neural Network

The human brain has many neurons processing various information and recognizing the world around them. The artificial neural network was invented to simulate the structure of neurons in the brain. In this algorithm, the general model of an artificial neuron (perceptron) can be expressed, as seen in figure 6. Each artificial neuron is composed of several parts. The first part of the neuron input is shown in figure 6. The next part is the weights of each input which is shown respectively. Every entry to the neuron is multiplied by its weight. After multiplying each input by its own weight, the values are entered into the block and accumulated together. Then the sum of the results is entered into an activation function. If the input value to the activation function is greater than the threshold (0.5) of the nerve, the neuron is activated. The most commonly used functions, which are used as activation functions, are the logical signal function (logistic), which is expressed in Equation 6 (Maier, Syben, Lasser, & Riess, 2019).

Figure 6. Model of an artificial neuron (Proceptron)



In this Equation, values   are equal to . In the face of complex problems, one can no longer solve a problem with a simple perceptron, as it has illustrated in figure 6. An artificial neural network uses a multilayer perceptron in this situation, which is represented in figure 7. In order to create a multilayer perceptron, the neurons must be placed in different layers and their output from a layer to the input of later layer neurons.

Figure 7. Multilayer Proceptron Neural Network

 Various mathematical processes use a set of data to adjust parameters in an artificial neural network of weight that somehow are experiment-driven, which makes machine learning an art in many cases not only scientific principles but also contributes to its sophistication.

B.     Support Vector Machine

Support Vector Machines are one of the supervisory learning methods used for classification and regression. The initial algorithm was developed by V Pnick in 1963 and generalized by him and his colleague for nonlinear mode in 1995. The main idea of this method is that assuming that the categories are linearly separable, they obtain super-margins with a maximum margin that separates the classes. Supported vectors in plain language are a set of points in the n-dimensional data that define the boundaries of the categories where the bounding and classification are defined based id categories. On that basis by moving boundaries, the output of the classification may change (Alquran et al., 2017). Assume that we have the set of data points , and we want to divide them into two categories . Every  is a p-dimensional vector of real numbers. Linear classification methods try to separate the data by constructing an abstraction (which is a linear equation). The method of classifying a backup vector machine, which is one of the linear classification methods, finds the best substrate that separates the data from the two classes with the maximum margin (Alquran et al., 2017). In order to better understand the issue, in Figure 8, an image of a dataset belonging to two classes is shown, which selects the best-case backup vector machine to separate them.

Figure 8. Eclipse with maximum separator boundary along with separator boundaries for classifying sample data for two different classes.

In figure 8, the mathematical relations of these two parallel eclipses that form the boundary of the separator are expressed. In these terms, w and b must be selected to create the greatest distance between the parallel clouds separating the data.

C.    K-Nearest Neighbour (KNN)

Another efficient classification method is the K-nearest neighbour (KNN), a simple and effective method for classifying data according to the closest training examples in the feature space. Assume that the xi sample is considered a test sample. Based on the K nearest neighbour's performance, K is the instruction sample, the closest samples of which are xi test samples. Then, the class of the closest samples is used to estimate the type of test sample class. In other words, the K-nearest neighbour method receives a test sample and performs classification by using the K-nearest neighbour sample in the training data. The nearest neighbour is shown in the form of a sample of the classification based on the K method. As shown in the figure, the value of the variable K is considered to be four. Therefore, four sample data were used to estimate the type of test sample class.

Figure 9. An example of a K-closest neighbour-based classification


In order to calculate the distance between the two samples, xi and xj, a Euclidean distance is used. This problem is shown in Equation (7). In this regard, d represents the dimension of the data space and represents the number of data attributes in the data set (Linsangan & Adtoon, 2018).


The choice of the K value in the K-nearest neighbour method is very important. If this is too small, the algorithm becomes sensitive to noise. In fact, the noise near that record may make a mistake. On the opposite side, if this large amount is selected, there may be cases of other classes among the neighbours nearest to them.

Results and Discussion

According to the discussed methods, out of 200 input data, 160 were used for training, and 40 were used for the test. The results of data categorization for three different classes of lesion, an unusual lesion and melanoma lesions, are presented in Table 2. In this table, the accuracy of each class is expressed by the training or test data. Also, the average values of classification percentages for test data and for each of the categories are shown in Table 3.

Table 2. The Percentile Multivariate Percentage Accuracy Percentile, Support Vector Machine, and K-nearest Neighborhood for Training and Test Data.

Accuracy (%)


































Table 3. Average values of test data categorization percentages

Classification Accuracy (%)







The results of Table 3 show that according to the attribute vector considered for each image, which includes the characteristics of the tissue, the shape and colour of each lesion. The results apparently indicate that a multilayer neural network (MLP) with a percentage accuracy of 83.6 is more suitable than other classifications and a k-nearest neighbour to the support vector machine with an accuracy of 13.3%. Table 2 shows that the neural network performs better in each class than the other classifiers. The complete sets of training and code explanations are accessible via.

Future Works

The results of this study indicate that the accuracy of having said techniques is inextricably linked with the data quality. Therefore, hybrid soft computing techniques  (H. Naghavipour et al., 2021) that leverage granular computing techniques for reduction purpose is in our research agenda to improve the accuracy of machine learning algorithm by feeding optimized data. The application of rough set theory (Hadi Naghavipour, Idris, Soon, Salleh, & Gani, 2022) has shown promising results in hybrid soft computing techniques in preprocessing stages to enhance the performance of main soft computing techniques. In the context of medical image analysis, the preprocessing approach, such as rough set theory shown to be a potent remedy to improve the accuracy of the image processing unit. Moreover, the time complexity of existing machine learning was not explored in the existing literature, creating promising research directions.


This study explores the performance of machine learning techniques for melanoma detection. The cancer classification has done within four stages. First, Dull razor software has been used in preprocessing to eliminate hair and noises from the images. Second, image segmentation techniques based on the ABCD method divide the properties of images to different parts in which skin tissue properties are the prominent ones. Third Gray-level cooccurrence matrix GLCM is used to extract the shape and colours from skin tissue. Finally, machine learning techniques applied to classify the cancerous image from normal ones. This study clearly indicated that an artificial neural network is better than two other classifiers: the k-nearest neighbour and the supporting vector machine.

Conflict of interest

The authors declare no potential conflict of interest regarding the publication of this work. In addition, the ethical issues including plagiarism, informed consent, misconduct, data fabrication and, or falsification, double publication and, or submission, and redundancy have been completely witnessed by the authors.


The author(s) received no financial support for the research, authorship, and/or publication of this article.

Alquran, H., Qasmieh, I. A., Alqudah, A. M., Alhammouri, S., Alawneh, E., Abughazaleh, A., & Hasayen, F. (2017). The melanoma skin cancer detection and classification using support vector machine. Paper presented at the 2017 IEEE Jordan Conference on Applied Electrical Engineering and Computing Technologies (AEECT).
Cheng, Y., Swamisai, R., Umbaugh, S. E., Moss, R. H., Stoecker, W. V., Teegala, S., & Srinivasan, S. K. (2008). Skin lesion classification using relative color features. Skin Research and Technology, 14(1), 53-64.
Christensen, J. H., Soerensen, M. B., Linghui, Z., Chen, S., & Jensen, M. O. (2010). Pre‚Äźdiagnostic digital imaging prediction model to discriminate between malignant melanoma and benign pigmented skin lesion. Skin Research and Technology, 16(1), 98-108.
Emre Celebi, M., Alp Aslandogan, Y., Stoecker, W. V., Iyatomi, H., Oka, H., & Chen, X. (2007). Unsupervised border detection in dermoscopy images. Skin Research and Technology, 13(4), 454-462.
Emre Celebi, M., Kingravi, H. A., Iyatomi, H., Alp Aslandogan, Y., Stoecker, W. V., Moss, R. H., . . . Rabinovitz, H. S. (2008). Border detection in dermoscopy images using statistical region merging. Skin Research and Technology, 14(3), 347-353.
Emre Celebi, M., Wen, Q., Hwang, S., Iyatomi, H., & Schaefer, G. (2013). Lesion border detection in dermoscopy images using ensembles of thresholding methods. Skin Research and Technology, 19(1), e252-e258.
Lee, T., Ng, V., Gallagher, R., Coldman, A., & McLean, D. (1997). Dullrazor®: A software approach to hair removal from images. Computers in biology and medicine, 27(6), 533-543.
Leiter, U., Keim, U., & Garbe, C. (2020). Epidemiology of skin cancer: update 2019. Sunlight, Vitamin D and Skin Cancer, 123-139.
Lim, S. H., Mat Isa, N. A., Ooi, C. H., & Toh, K. K. V. (2015). A new histogram equalization method for digital image enhancement and brightness preservation. Signal, image and video processing, 9(3), 675-689.
Linsangan, N. B., & Adtoon, J. J. (2018). Skin cancer detection and classification for moles using k-nearest neighbor algorithm. Paper presented at the Proceedings of the 2018 5th International Conference on Bioinformatics Research and Applications.
Maier, A., Syben, C., Lasser, T., & Riess, C. (2019). A gentle introduction to deep learning in medical image processing. Zeitschrift für Medizinische Physik, 29(2), 86-101.
Maurya, R., Singh, S. K., Maurya, A. K., & Kumar, A. (2014). GLCM and Multi Class Support vector machine based automated skin cancer classification. Paper presented at the 2014 International Conference on Computing for Sustainable Global Development (INDIACom).
Mendonça, T., Ferreira, P. M., Marques, J. S., Marcal, A. R., & Rozeira, J. (2013). PH 2-A dermoscopic image database for research and benchmarking. Paper presented at the 2013 35th annual international conference of the IEEE engineering in medicine and biology society (EMBC).
Naghavipour, H., Idris, M. Y. I. B., Soon, T. K., Salleh, R. B., & Gani, A. (2022). Hybrid Metaheuristics Using Rough Sets for QoS-Aware Service Composition. Ieee Access, 10, 112609-112628.
Naghavipour, H., Soon, T. K., Idris, M. Y. I. B., Namvar, M., Salleh, R. B., & Gani, A. (2021). Hybrid Metaheuristics for QoS-Aware Service Composition: A Systematic Mapping Study. Ieee Access, 10, 12678-12701. doi:10.1109/ACCESS.2021.3133505
Rigel, D. S., Russak, J., & Friedman, R. (2010). The evolution of melanoma diagnosis: 25 years beyond the ABCDs. CA: a cancer journal for clinicians, 60(5), 301-316.
Sayed, G. I., Soliman, M. M., & Hassanien, A. E. (2021). A novel melanoma prediction model for imbalanced data using optimized SqueezeNet by bald eagle search optimization. Computers in biology and medicine, 136, 104712.
Senan, E. M., & Jadhav, M. E. (2021). Analysis of dermoscopy images by using ABCD rule for early detection of skin cancer. Global Transitions Proceedings, 2(1), 1-7.
Stolz, W. (1994). ABCD rule of dermatoscopy: a new practical method for early recognition of malignant melanoma. Eur. J. Dermatol., 4, 521-527.
Vyas, A., Yu, S., & Paik, J. (2018). Fundamentals of digital image processing. In Multiscale Transforms with Application to Image Processing. 3-11.