## 2 Materials and Methods
### Proposed Method
#### 2.2.1 Pre-Processing Stage  
First, a Gaussian smoothing filter is applied, which is a filter that is widely used in the pre-processing stage in computer vision algorithms because it eliminates noise in the image and generates a uniform smoothing [13]. Gaussian function is defined as  
Figure 3: Example of the detection and classification of melanoma corresponding to Algorithm 1. (**a**) the input image \(I_{(a)}\); (**b**) corresponds to the identification of possible cases of melanoma after noise and skin removal \(I_{(b)}\); (**c**) shows the semiplanes formed for the evaluation of symmetry \(a\); (**d**) the edge identified \(d\).  
Figure 2: Flowchart of the proposed method.  
\[G_{0}(x,y)=Ae^{-\frac{(x-\mu_{x})^{2}}{2\sigma_{x}^{2}}-\frac{(y-\mu_{y})^{2}}{2 \sigma_{y}^{2}}} \tag{1}\]  
where \(\mu\) is the mean (the peak), \(A\) is a constant, \(\sigma\) represents the standard deviation (for each of the variables \(x\) and \(y\)), and (x,y) is the pixel location.  
Subsequently, the image is converted to the HSV color space to identify the skin color and remove it from the image. The HSV color space is obtained by a nonlinear transformation of RGB color space into cylindrical coordinates so that each channel is defined by hue, saturation, and brightness (value) [16].  
Once the image is converted to this color space, several color samples are taken at the corners of the image to identify the skin color. These values are compared until the ranges are determined and the threshold levels are identified. Skin color is detected for each image evaluated. Therefore, the threshold range changes for each one. Since the skin color is established automatically, the algorithm works for all skin tones.  
When the color ranges are identified and the thresholding is applied, the skin is black, and the possible cases of melanoma are white. Then, a series of filters are applied: Gaussian, morphological erosion, and dilation to remove image noise. Equation (2) corresponds to erosion where \(X\) is a set that represents the binary image, \(A\) the structuring element, \(\varepsilon_{A}(X)\) the erosion of \(X\) with structuring element \(A\), and \(x\) the points belonging to the set \(X\) such that \(A\), transferred in \(x\), is fully included in \(X\)[22]. Equation (3) corresponds to dilatation where \(X\) is a set that represents the binary image, \(A\) the structuring element, \(\delta_{A}(X)\) the expansion of \(X\) with structuring element \(A\), and \(p\) points such that \(A\) intersects \(X\) when the reference point of the structuring element is transferred to \(p\)[16]:  
\[\varepsilon_{A}(X)=\{x:A_{x}\subseteq X\} \tag{2}\]  
\[\delta_{A}(X)=\{p:A_{p}\cap X\
eq 0\} \tag{3}\]  
Algorithm 2 shows the corresponding pseudocode for image conditioning, skin removal, and identification of possible cases of melanoma. Figure 4 shows four examples of conditioning and identification of potential cases of melanoma.  
```
1:\(I_{a}\), input image.
2:Output:\(I_{f}\), skinless and denoised image.
3:procedurePreprocessing(\(I_{a}\))
4:\(I_{b}=GaussianBlur(I_{a})\)
5:\(I_{c}=convert\_RGBto HSV(I_{b})\)
6:\(h,s,v=get\_Split(I_{c})\)
7:\(h_{min},h_{max}=get\_RangesCorners(h)\)
8:\(s_{min},s_{max}=get\_RangesCorners(s)\)
9:\(v_{min},v_{max}=get\_RangesCorners(v)\)
10:\(I_{d}\)=zeros(size(\(h\)))
11:for\((x,y)\in h\)do
12:\(I_{d}(x,y)=\begin{cases}1,&\text{if }h_{min}<h(x,y)<h_{max}\And\\ &s_{min}<s(x,y)<s_{max}\And\\ &v_{min}<v(x,y)<v_{max}\\ 0,&\text{otherwise.}\end{cases}\)
13:\(I_{e}=Erosion(I_{d},K_{1})\)
14:\(I_{f}=Dilation(I_{e},K_{2})\)\(\triangleright\)\(K_{1},K_{2}\) are the kernel
15:return \(I_{f}\)
```  
**Algorithm 2** Proposed method for skin removal, showing lines 1-13, corresponding to the images in Figure 3b.