Detection and diagnosis of skin diseases by using snake algorithm and neural networks

. This research presents a medical application to diagnose types of skin diseases based on the axis of dermatology, where a computer intelligent system was built based on identifying and diagnosing the type of skin inflammation, and this system called (SANN) (Snake Algorithm Neural Network). The system consists of two stages, the first stage is the axis of locating the presence of skin inflammation and distinguish it from uninfected skin by performing the initial processing of the image using the snake algorithm. while the second stage using neural networks to diagnose types of skin disease that were identified in the first stage by adding some improvements to the neural networks to work more efficiently for diagnosis. The suggested SANN system was applied to 250 images, and the accuracy and execution time were calculated. The results showed that using the system based on the snake algorithm and neural networks in the process of identifying and diagnosing types of dermatitis (psoriasis or Spider birthmark) achieves high performance and accuracy, and gave a diagnosis rate of 88.9%

• Itching • The appearance of painful sores on the skin • Suffering from redness and swelling • a change in skin color • Skin wrinkling and peeling • The appearance of blisters

Research Problem Definition
Many researchers have used various techniques to analyze medical images in order to reveal the things that effect to the healthy lives. The discovery and diagnosis of skin diseases traditionally may take a long and expensive time because it needs specialists in this field due to the diversity of this disease and the similarity of most cases. The research problem can be defined as follows: 1. How to extract skin diseases from images taken from different sources. 2. It is difficult to classify the irregular forms of skin diseases due to the similarity of several types of skin diseases.

Research Objectives
Complex medical problems can be solved by segmentation and treating each problem individually. After determining the location of the skin disease, which differs in nature from the usual skin, the stage of detecting the type of this disease comes. That is why this computer system, which was designed by adopting the snake algorithm and neural networks, aims at speed and accuracy in diagnosing skin diseases.

Neural Networks
Artificial Neural Network (ANN) are computational techniques designed to solve problems, and their work is inspired by the method of the human brain [14]. However, it is important to note that the ANN is not very similar to the complexity of the human brain. The ANN consists of a set of ganglia that mimic the biological neurons of the human brain [7]. The nodes are connected to each other by means of connections, and each neuron acts on the received input to process the information and gives the desired output [10]as shown in the figure 1.

figure (1): Neural Networks structure
In addition, there are weights between nodes that work similarly to those in a biological network. These weights are the core of the network learning process that can be learned and used as intermediate parameters between nodes. In addition, weight is a value that changes through network training. The following equation shows the relationship between inputs and weights [15] = ∑( . ) … … . . (1) Where X :is the input. W :is the weight. y :is the output

Psoriasis
Psoriasis is a chronic immune skin disorder that causes thick, dry and white scaly layers to appear on the affected parts of the skin, and may appear anywhere on the body, but it usually appears on the scalp, elbows, knees, and lower The appearance of these crusts is accompanied by a feeling of itching, burning, and tingling in some cases, and it is worth noting that psoriasis is not considered an infectious disease, and in some cases psoriasis can be associated with a group of other health conditions, such as: arthritis, and heart diseases. It should be noted that psoriasis affects both women and men, and may appear at any age, but it is more common in adults, but it should be noted that one of the types of psoriasis known as psoriasis Guttate is usually more common in individuals in childhood and puberty

. Spider Birthmark
They are a collection of dilated vessels and capillaries close to the surface of the skin with a size of 1-10 mm, which bear a reticular shape as its name reflects, which is represented by the presence of a point in the middle from which a group of small dilated vessels branch, which appear in about 10% of people. Spider birthmarks can appear anywhere on the body, usually spider birthmarks are not a cause for concern if the person does not have any symptoms or other health conditions. the study of researchers proved that various factors may lead to the appearance of spider birthmarks are (exposure to sunlight, changes in hormone levels, liver disease) as for the factors that cause spider birthmarks. It increases the incidence of spider nevus (age, hormonal changes, sitting or standing for long periods of time, heredity, obesity), The figure 3 shows Spider birthmark. [16] Figure3: Spider birthmark in the face 7. Snake Algorithm Features are usually extracted through the using snake algorithm , as the target is identified through a set of points that represent the active perimeter, and at the same time it is the feature to be found. This case can be represented by using a balloon. When the balloon is deflated, the balloon will deflate and the target shape will be recognized. [2] Figure 4 illustrates this case, which aims to identify dermatitis ( Fig. 4a), as it is surrounded by an initial contour and then zoomed out until it surrounds the dermatitis (Fig. 4d). After repeating the process 400 times, the points surrounding the skin inflammation can be seen well. [2] Figure (4): Using a snake to find a dermatitis To detect the edges, we traditionally followed the canny edge detection algorithm by using the image derivatives of gray-scale image. In snake's algorithm we try to move snake in a direction where energy is minimum by adopting the energy functional Esnake shown in the equation (2). [11] Where: Eint: "The internal energy controls the natural behaviour of the snake and hence the arrangement of the snake points" Eimage: "The image energy, attracts the snake to chosen low-level features (such as edge points)". Econ: "The constraint energy, allows higher level information to control the snake's evolution"

Neural Network Convolutional (CNN)
When we first hear the term convolutional neural networks, a strange mixture of biology and mathematics comes to mind with a little computer science, but in fact, these networks are among the most influential innovations in the field of computer vision, a field concerned with the development of technologies that enable computers to Seeing and recognizing objects and the surrounding environment through understanding the content of digital images and videos. In this research, this network was adopted in diagnosing the type of dermatitis that was detected in the previous step, The CNN consists 107 Technium Vol. 4, No.10 pp.104-114 (2022) ISSN: 2668-778X www.techniumscience.com of three layers: " convolutional layers, pooling layers, and fully connected layers" shown in Figure 5 [9].

8.1-Input Layer
In this layer, the images to be entered into the model are prepared by changing their sizes to a fixed size, after which they go through a total of the steps specified in Figure 5 to diagnose the type of dermatitis . [9]

8.2-Convolutional Layers
The convolutional layer is the core building block of a CNN, and it is where the majority of computation occurs. It requires a few components, which are input data, a filter, and a feature map. The proposed system consists of three convolutional layers, the first layer receives the input of the input layer, on which 128 filters (128 filters) with a size of 3 × 3 are applied. The filter size is a 3x3 matrix; this also determines the receptive field size. The filter is then applied to the image, and a dot product is calculated between the input pixels and the filter. This dot product is then fed into an output array. Afterwards, the filter shifts by a stride, repeating the process until the kernel has swept across the entire image. The final output from the series of dot products from the input and the filter is known as a feature map, activation map, or a convolved feature [18], shown in Figure 6.

8.3-Pooling layers
The number of parameters in input and calculations is reduced by reducing dimensions and this is the benefit of Pooling layer. In the proposed research model, three layers of (max-pooling layer) were adopted, in each of them a filter with dimensions (2 x 2), in steps of (2) [filter with size 2 x 2 with stride 2], which will lead to the result. To a feature map with dimensions (32*32) as a first step, and in the second layer it will produce a feature map with dimensions (16*16), while the output of the dimensions of the feature map in the third layer will be (8*). 8) . That is, the greatest benefit of this layer is to reduce the dimensions of the feature map in half to facilitate the work of the system . [12].

8.4-Connected Layers
Fully connected layer is another main layer that is used in the CNN model. This layer takes the output of the previous layers and use it as an input of fully connected layer after flattens them into single vector. However, the purpose of fullyconnected layer is classifying the output of last layer of convolution/pooling into its label. The CNN model, used two fully connected layers and for each fully connected layer take calculation as [15]. F(Wx+b) … ( 3 ) Where: W:weights matrix.

Loss Function in CNN
The network's classification layer contains a loss function that calculates the cross-entropy loss between network predictions and the desired output. Cross-entropy loss function is the one that the CNN model uses by default when measuring how well it performs throughout the training process. Additionally, classification often employs the cross-entropy loss function.The input of cross-entropy loss function is the probability value of soft-Max function which fall between 0 and 1 as shown in Figure  7. It can be calculated as [14]; Where, d is desired output, p is the predict output, c number of class, d(xi) is the probability of class xi in target and p(xi) is the probability of class xi in prediction. When the value of predicting a probability of the function approaching to 0, the CNN performance will be perfect.

The Suggested System
The proposed computer system called (SANN) was designed with three main models, each model performs its own task, as shown below:

Convert image to gray
We converted the image to gray scale, in order to avoid using the three channels of the RGB color system. As show in figure. In order to detected the location of dermatitis and distinguish it from the healthy part, the snake algorithm was adopted and the steps to detect the affected part are shown in the following figure. Technium Vol. 4, No.10 pp.104-114 (2022) ISSN: 2668-778X www.techniumscience.com

Diagnosis of the type of dermatitis.
After the image has gone through the previous two stages and the location of the skin inflammation has been determined, the last stage comes to diagnose the type of this inflammation through the use of one of the neural network algorithms, the CNN algorithm, and the following figure shows the mechanism of the proposed system.

Training the Classification
The model is trained on "Dataset Classification". The dataset loaded and prepared by using imageDatastore() function , the image is rotated randomly by [0-90] and reflected by both direction (Horizontally and Vertically). This option used imageDataAugmenter() function . This augmenter option is applied on the image data store by using augmentedImageDatastore () function. Moreover, as it has been mentioned in previous part, to start the training the model many important trainings parameter should be defined by using trainingOptions () function. The main training option is shown in Table (1).  Figure 11 illustrates the training progress of classification model as well as the levels of the Loss function .

Test Results of Classification Model
The classification model is tested on the test dataset which consist of 250 Image chosen the 70% for training and 30% for testing for dataset set as main percentage. The Figure 12 illustrates the confusion matrix of classification model. This confusion matrix shows that there are amount of images correctly and incorrectly classified as belonging to target class as shown in Table (2).  Accuracy "The performance evaluation metrics for each class" A = TP + TN TP + FP + FP + TN 2 Precision "Represent the correct classified with respect to the total number of samples in test dataset" P = TP TP + FP

3
Recall "Ratio of images correctly classified for each class divided to the total number of images (correctly or incorrectly)."

4
Specificity "Represent the ratio of images correctly classified for each class with respect to total images that are actually belong to the same class"

S = TN FN + FP
The observing the results in Table (2) and studying these Measures, we find that the proposed