1 Introduction

Sunlight encompasses a wide spectrum of electromagnetic energy, ranging from gamma and X-rays to ultraviolet (UV) rays, visible light, infrared (IR) rays, and large radio beams [1, 2]. The adverse effects of sunlight on the skin are widely recognized  [3]. This study particularly emphasizes the detrimental impacts of UV and IR rays on the skin [4]. Minimizing exposure to ultraviolet rays is crucial in preventing or reducing the risk of skin cancer.

Skin cancer, a malignant condition affecting the outer layers of the skin, serves various functions such as providing a protective barrier against heat, light, infection, and injury, and determining skin color through melanocytes [5]. It constitutes the most prevalent type of cancer globally, accounting for 75% of all cancers, with melanoma being the rarest and most perilous form  [6]. Factors such as fair skin and prolonged sun exposure increase susceptibility to this condition [7]. Early detection of melanoma is pivotal for effective treatment and reduction of mortality rates [8].

Recognition of melanoma skin cancer presents a significant challenge in medical settings, leading to the utilization of a Convolutional Neural Network and a combined method for rapid and accurate image classification. To solve problems involving complex patterns and prediction, the ANN was developed [9, 10]. The study aims to establish a high-accuracy boundary for melanoma skin cancer [11, 12]. DNNs or ANNs represent the most generalized neural networks in the realm of deep learning. These networks belong to a category of computing systems, drawing their primary inspiration from the structure and function of biological neural networks in animal brains [13,14,15]. The study presents an advanced sentiment analysis framework combining modified TF-IDF, pre-trained embeddings, CNNs, and LSTMs, showing improved performance across datasets, though requiring significant computational resources, hyperparameter sensitivity, and interpretational challenges, aiming to advance sentiment analysis and identify research directions [16, 17]. The framework presents a Hybridized Deep Neural Network approach for sentiment analysis, incorporating a modified NADFO algorithm and SentiWordNet-assisted objective function, surpassing baseline models, avoiding local optima, and offering scalability for diverse sentiment analysis tasks [18]. The research showcases a technique targeting syntactic negations in sentiment analysis, yielding enhanced accuracy across various datasets, aiming to develop and validate a customized method for negation resolution, thus boosting sentiment analysis performance [19]. In this paper, we apply the HHO algorithms to melanoma skin cancer images. The HHO algorithm has been applied to challenging problems in structural optimization [20]. The conversion of the RGB image to a grayscale image and the implementation of the method on the grayscale image are carried out in our implementation of the HHO algorithm. Morphological operators are used for post-processing to improve the results. Blurred noise, which poses a major challenge for classical image segmentation methods such as Otsu, is present in some melanoma skin cancer images [21, 22], K-means [23], Gradient Vector Flow (GVF) [24], Active Contour Models (ACM) [25], and the Asymmetry, Border Irregularity, Color Variation, and Diameter (ABCD) based on morphological operators’ method [26]. The effectiveness in addressing the identified problem is demonstrated by our proposed approach. The study introduces the HHO to optimize segmentation thresholds in melanoma images, addressing challenges such as blurred noise. This innovative approach surpasses previous research by employing an HHO-assisted CNN method for melanoma image analysis. By utilizing the ISIC databases, the study focuses on enhancing system accuracy and preserving image integrity. However, it is essential to note that smoothing the image may inadvertently damage its edges, presenting a significant challenge (Table 1).

Fig. 1
figure 1

Images from the dataset

1.1 Contributions and innovation

  • Novel Combination of Techniques: The study combines deep learning methods, specifically CNNs, with the Binary HHO algorithm. This fusion of advanced machine learning techniques provides a unique approach to the problem of melanoma skin cancer detection.

  • Addressing Image Segmentation Challenges: One significant challenge in melanoma detection is accurately delineating the boundaries of skin lesions in images. The study addresses this challenge by employing the HHO algorithm to determine optimal threshold values for segmenting melanoma images effectively, thereby enhancing the accuracy of boundary detection crucial for precise diagnosis.

  • Enhanced Performance Metrics: The work introduces performance metrics such as sensitivity, specificity, and accuracy to evaluate the effectiveness of the proposed method. These metrics provide a comprehensive assessment of the model’s ability to correctly classify melanoma and non-melanoma images, contributing to a deeper understanding of the model’s performance.

  • Comparison with Existing Methods: The study compares the proposed method with established melanoma detection techniques found in the literature. Through these comparisons, the researchers demonstrate the superiority of their approach in terms of accuracy, sensitivity, and specificity, highlighting the innovative nature of their methodology.

  • Utilization of Public Datasets: The researchers utilize publicly available datasets, namely ISIC 2016, ISIC 2017, and ISIC 2019, for training and testing their model. By leveraging these datasets, they ensure reproducibility and facilitate further research in the field by providing a benchmark for comparison with future studies.

Overall, the innovation of the work exists in its holistic approach to melanoma detection, combining cutting-edge machine learning techniques, addressing specific challenges in image segmentation, introducing comprehensive performance metrics, and benchmarking against existing methods using publicly available datasets.

2 Dataset

The proposed method utilizes the ISIC 2016, ISIC 2017, and ISIC 2019 databases [27], which are sourced from a hospital in Portugal and accessible for download from the ISIC archive website at (https://challenge.isic-archive.com/data/). Figure 1 depicts a subset of the dataset used in this study. The clinical data within these databases comprise over 4000 cases featuring dermoscopic images of various skin lesions, all captured under standardized conditions using the Tuebinger Mole Analyzer framework. A random selection of dermoscopy images, accompanied by their clinical diagnoses, was conducted, encompassing 35 melanocytic moles (common), 25 dysplastic moles, and 30 melanomas. These images are in 24-bit RGB format with a resolution of 768 x 560 pixels. Figure 1 showcases an example of the original and manually annotated melanoma image IMD002 from the ISIC 2019 dataset. The ISIC 2019 skin lesion dataset is employed for the classification of skin cancer images. This dataset was derived from the 2019 ISIC Skin Lesions Analysis for Melanoma Diagnosis and consists of 1000 melanoma and benign images. Access to the dataset is available via the following website: (https://challenge.isic-archive.com/data/#2019).

2.1 Harris Hawks optimization method

Swarm intelligence, inspired by collective animal behavior, such as group hunting, offers a solution to optimization problems [28]. The HHO algorithm, a representative of swarm intelligence [29], simulates the hunting behavior of hawks, circling a target before attacking  [30]. The algorithm’s behaviors, like “soft siege” and “quick dive” are modeled to guide the population toward the optimal solution. Through iterative updates of hawk and target positions, the algorithm converges to the desired outcome. our proposed algorithm demonstrates superior accuracy compared to other optimization techniques, as confirmed by testing and reviews. Figure 2 depicts the aggressive hunting behavior characteristic of the hard type in the HHO algorithm, where each hawk makes a direct dive toward an optimal solution or the rabbit.

Fig. 2
figure 2

The hard siege behavior in the HHO algorithm

2.2 Mathematical background

The process entails hawks encircling and assaulting a target, where each hawk symbolizes a prospective solution, striving to approach the assumed optimal position of the rabbit. Equation (1) to (9) delineate the stochastic and purposeful motion of hawks toward the target, incorporating factors like the energy coefficient E and a random variable J to govern their behavior, transitioning from exploration to pursuit. Hawks’ random and early search behavior can be modeled using equation (1) [31]:

$$\begin{aligned} X(t+1) = \left\{ \begin{matrix} X_{rand}(t) - r_{1}\left\| X_{rand}(t)-2r_{2}.X(t)\right\| & rand \ge 0.5 \\ (X_{rabbit}(t)- X_{M}(t))-r_3(LB-r_4(UB-LB)) & rand < 0.5 \end{matrix} \right. \end{aligned}$$
(1)
Table 1 List of Abbreviations
Table 2 List of Nomenclature

In this expression, X(t) represents the current position of a hawk or solution at the current iteration t, while \(X(t+1)\) denotes the position of a hawk in the subsequent iteration. Additionally, \(X_{rabbit}(t)\) signifies the position of the most optimal solution, and Xrand(t) represents a randomly chosen position within the problem space when \(X_{M}(t)\) indicates the center of gravity of the hawk population. Moreover \(r_1\), \(r_2\), \(r_3\), and \(r_4\) denote random numbers ranging between 0 and 1, with LB and UB indicating the lower and upper limits of the solutions, respectively, in the problem space. Equation (2) facilitates the calculation of \(X_{M}(t)\), representing the number of solutions for N hawks. In this context, \(X_{M}(t)\) denotes the center of gravity of the population, while \(X_{i}(t)\) indicates the position of a solution, such as the ith hawk. The energy coefficient, inherent in the HHO, gradually modifies the behavior of hawks from exploration to pursuit (Table 2).

$$\begin{aligned} X_{M}(t)=\frac{1}{N}\sum _{i=1}^{N}X_i(t) \end{aligned}$$
(2)

This trend is demonstrated in equation (3), where the parameter E decreases swiftly from an initial value, such as 2, to zero. Here, T represents the maximum iteration of the algorithm, \(E_0\) signifies the initial energy, and t denotes the current iteration number.

$$\begin{aligned} E=E_0(1-\frac{t}{T}) \end{aligned}$$
(3)

Equation (4) model soft siege, where hawks gradually approach the promising solution with influence from the energy coefficient.

$$\begin{aligned} X(t+1)=\Delta X(t) -E \left\| J.X_{rabbit}(t)-X(t) \right\| \Delta X(t) = X_{rabbit}(t)-X(t) \end{aligned}$$
(4)

Equation (5) defines a random movement step for the “rabbit” (solution). Within these equations, J is a stochastic variable varying from zero to two.

$$\begin{aligned} J = 2(1-rand(0,1)) \end{aligned}$$
(5)

Equation (6) models hard siege, where hawks directly attack the rabbit based on the energy coefficient.

$$\begin{aligned} X(t+1) = X_{rabbit}(t)-E\left\| \Delta X(t) \right\| \end{aligned}$$
(6)
Table 3 The performance metric

Equation (7) serves as the model for this gradual approach, known as the soft siege mechanism, while equation (8)represents the rapid descent mechanism, termed the quick dive.

$$\begin{aligned} Y= X_{rabbit}(t)-E \left\| J.X_{rabbit}(t)-X(t) \right\| \end{aligned}$$
(7)
$$\begin{aligned} Z = Y + S \times LF(D) \end{aligned}$$
(8)

Considering the adjustments in position due to the soft positional change and quick dive in the HHO algorithm, two new positions emerge, necessitating a comparison with the current position. Given the objective of minimizing, a new position is chosen if it represents a smaller minimum compared to others, as per equation (9).

$$\begin{aligned} X(t+1)=\left\{ \begin{matrix} Y & if~~F(Y)< F(Z)\\ Z & if~~F(Z) < F(Y) \end{matrix}\right. \end{aligned}$$
(9)

The new positions and the current optimal solution are iteratively updated on each subsequent iteration of the HHO algorithm. In the final iteration, the position is extracted as the ultimate answer.

3 Results and discussion

The evaluation of our proposed method’s performance relies on images sourced from the ISIC 2016, ISIC 2017, and ISIC 2019 datasets, juxtaposed with outcomes from previous techniques integrating the HHO algorithm for establishing a global threshold in image binarization and skin lesion identification. The efficacy of the proposed HHO segmentation method is assessed through accuracy (ACC), sensitivity (SEN), and specificity (SPE), with ACC providing an overview of pixel detection analysis, SEN indicating accurate classification of skin cancer lesion pixels, and SPE reflecting the ratio of non-lesion pixels incorrectly classified as skin cancer. The assessment involves computing the intersection ratio of the segmented lesion region and the annotated ground truth, as delineated by Rogers et al. [32]. Performance metrics such as True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN) values are utilized to assess the effectiveness of melanoma detection methods, with ACC commonly used for comparing overall data target accuracy, SPE measuring the proportion of correctly identified non-lesion skin cancer data, and SEN indicating the accuracy of identifying skin cancer lesion data, as presented in Table 3.

Furthermore, the subsequent section provides a detailed exposition of the mathematical formulations and elucidations of precision, recall, specificity, and F-measure. It is accompanied by a succinct summary of the model’s performance on the ISIC 2019, ISBI 2016, and ISBI 2017 datasets utilizing these metrics.

Precision P signifies the ratio of true positive predictions to the total number of positive predictions made by the model, indicating the accuracy of positive predictions. It can be expressed mathematically as equation (10).

$$\begin{aligned} P=\frac{TP}{TP+FP} \end{aligned}$$
(10)

Recall R, also referred to as sensitivity, assesses the model’s capability to correctly identify positive instances among all actual positive instances. Its calculation is demonstrated in (11).

$$\begin{aligned} R=\frac{TP}{TP+FN} \end{aligned}$$
(11)

Specificity S evaluates the model’s capacity to correctly identify negative instances among all actual negative instances. Its computation is depicted in the equation:

$$\begin{aligned} S=\frac{TN}{TN+FP} \end{aligned}$$
(12)
Table 4 Results (%) for melanoma detection using DL based on HHO (%)
Table 5 Result (%) comparisons using DL based on HHO for the ISIC 2019 dataset

F-measure, denoted as F, represents the harmonic mean of precision and recall. It provides a consolidated score that balances both precision and recall, as indicated by equation (13).

$$\begin{aligned} F =\frac{2 \times P \times R}{P+R} \end{aligned}$$
(13)

Subsequently, Table 4 presents an overview of the model’s performance on the ISIC 2019, ISBI 2016, and ISBI 2017 datasets using precision, recall, specificity, and F-measure.

Table 5 illustrates the percentage comparisons of outcomes achieved through DL utilizing HHO for the ISIC 2019 dataset. Additionally, to bolster the credibility of this study, the findings were juxtaposed against established melanoma detection methodologies documented in existing literature. The table offers a comprehensive comparison of the proposed technique’s ACC, SEN, and SPE with other prevalent methods, all based on the ISIC 2019 dataset.

Table 6 presents a comparison of the proposed method with other representative methods utilizing the ISBI 2016 dataset in terms of ACC, SEN, and SPE. The results indicate that the proposed method produced the best-segmented results from the ISBI 2016 pictures due to its ability to clearly define the boundary region of the lesion and improve performance parameters. Notably, Oliveira et al. [35] achieved results closest to the best-segmented results in terms of SEN.

Table 6 Result (%) comparisons using DL based on HHO for the ISBI 2016 dataset

Table 7 presents a comparison of the proposed method to other noteworthy methods that utilized the ISBI 2017 dataset, regarding ACC, SEN, and SPE. The proposed method achieved the best-segmented result from the ISBI 2017 images, with the closest results for SEN and ACC observed in Guo et al. [37]. For SPE, the results of Li & Shen [38],were the closest.

Table 7 Result (%) comparisons using using DL based on HHO for the ISBI 2017 dataset

In this study, GoogleNet and ResNet were used for feature extraction. These networks, being pre-trained, exhibit higher performance than other pre-trained methods such as AlexNet and SqueezeNet. The training process for GoogleNet and RESNET-50 is illustrated in Figs. 3 and 4, respectively.

Fig. 3
figure 3

Training process for the GoogleNet

Fig. 4
figure 4

Training process for the RESNET-50

For the classification of melanoma skin cancer, three different methods SVM, Decision Tree, and K-NN–are utilized. The Confusion matrices for Decision Tree, SVM, and K-NN are depicted in Fig. 5a, b, and c, respectively.

Fig. 5
figure 5

Confusion Matrices for various classifiers

This work presents a comparative study of image classification techniques applied to dermatoscopic images for melanoma detection. The chosen algorithms are part of a state-of-the-art survey, each employing a different classification technique. Improvement points are identified in the studied algorithms, which could significantly impact their results. Additionally, the addition of pre-and post-processing steps could enhance accuracy, although their effects on different datasets need thorough analysis.

4 Limitations

The research paper presents an innovative approach to melanoma skin cancer detection, integrating deep learning methods with the Binary Harris Hawk Optimization (HHO) algorithm, showcasing superior performance compared to alternative techniques like Support Vector Machine (SVM), Decision Tree, and K-Nearest Neighbors (K-NN). However, there are several limitations that may come to light. The reliance on public datasets from platforms such as ISIC might constrain the diversity and representativeness of the data. Additionally, variations in its effectiveness across different datasets necessitate validation on broader and more diverse datasets, including images with various skin types, lesion sizes, and imaging conditions to ensure its reliability. Moreover, the study emphasizes the necessity for further assessment of the proposed method’s real-world applicability and generalization, particularly across different demographic backgrounds and geographic regions to enhance the robustness and reliability of melanoma detection.

5 Conclusion

This study introduces a novel approach to diagnosing melanocytic lesions in macroscopic images, integrating conventional melanoma detection techniques with meta-heuristic methods. The methodology encompasses two forms of skin lesion recognition, incorporating both feature selection and non-feature selection in dermoscopic images. By employing the Harris Hawks Optimization (HHO) method, the study effectively identifies optimal features extracted through deep learning, resulting in significant advancements in describing and classifying such images. Particularly, the application of HHO for melanoma description demonstrates promising results, with the proposed methodologies yielding favorable outcomes in melanoma classification, especially when utilizing HHO and deep learning (DL). This proves more advantageous compared to models trained solely on meta-heuristic methods. The observed disparity in results between methodologies is partly attributed to the limited number of images used in the experiments, indicating the necessity of augmenting the dataset with a greater variety of images and classes to enhance the efficacy of HHO-based deep learning architectures.

Validating the study’s findings requires testing on broader and more diverse datasets. While the ISIC 2016, ISIC 2017, and ISIC 2019 databases serve as foundational resources, broadening the dataset’s scope by incorporating data from various sources can bolster the reliability and applicability of the conclusions. This expansion may entail sourcing datasets from multiple medical institutions or research entities to ensure a comprehensive representation of melanoma images.

Furthermore, diversifying the image dataset can facilitate a comprehensive evaluation of the proposed method across different skin types, lesion sizes, and imaging conditions. Including images with varying complexities, such as diverse stages of melanoma and benign lesions, offers valuable insights into the method’s real-world effectiveness. Additionally, conducting experiments with data collected from diverse geographic regions and demographic backgrounds can help gauge the method’s performance across populations with distinct genetic and environmental characteristics, identifying potential biases or limitations and ensuring its applicability across diverse patient populations. Moreover, incorporating expert annotations and clinical assessments for ground truth validation can enhance the accuracy and reliability of the results, validating automated classifications and guiding areas requiring further refinement.

In summary, validating the study’s results on broader and more diverse datasets, including images from various sources and expert annotations, is crucial for affirming the effectiveness and reliability of the proposed method for melanoma detection.