# Skin Lesion Segmentation in Dermoscopic Images with Combination of YOLO and GrabCut Algorithm
## 3 Materials and Methods
### Prepossessing and Labelling  
This study proposes a real-time skin lesion segmentation method. The proposed method consists of two major and two complement steps. One of the major steps is the detection of the lesion location in the image and the second is use of this information of location for the segmentation of the lesion. The complementary steps are preprocessing and postprocessing operations. Figure 3 illustrates a flow chart of the method.  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c} \hline \hline
**Dataset.** & \multicolumn{4}{c}{**Training Data**} & \multicolumn{4}{c}{**Validation Data**} & \multicolumn{4}{c}{**Test Data**} & \multicolumn{4}{c}{**Total**} \\ \hline
**Label** & **B** & **M** & **SK** & **Total** & **B** & **M** & **SK** & **Total** & **B** & **M** & **SK** & **AT** & **Total** & \\ \hline ISBI 2017 & 1375 & 374 & 254 & 2000 & 78 & 30 & 42 & 150 & 393 & 197 & 90 & * & 600 & 2750 \\ PH2 & * & * & * & * & * & * & * & * & * & 80 & 40 & * & 80 & 200 & 200 \\ Total & & & & 2000 & & & 150 & & & & & & 800 & 2950 \\ \hline \hline \end{tabular} B-Benign, M-Melanoma, SK-Seborrheic keratosis, AT-Atypical nevus, * there is no data in this field.  
\end{table}
Table 1: Distribution of data and labels for training, validation, and test in the ISBI 2017 and the PH2 datasets.  
Figure 2: Dermoscopic skin lesion images and their ground truths from datasets. (**a**) a dermoscopic image sample and its binary ground truth from the ISBI 2017 dataset, (**b**) a dermoscopic image sample and its binary ground truth from the PH2 dataset.  
All data in the training set were resized to the \(512\times 512\) resolution before starting Yolov3 training. Next, each image in the training set was labelled according to the training needs of [PERSON]. [PERSON] needs some information about the images as well as images during the training. This information includes middle point coordinates (x, y), width (w) and height (h) values of the bounding box and its class definition of the object to be detected. For this purpose, a bounding box was drawn around the skin lesion using a python script. The upper left corner coordinates (x1, y1) and the bottom right corner coordinates (x2, y2) of the bounding box were used for the determination of the x and y coordinates, that is the midpoint, and the height (h), width (w) of the bounding box. Detailed calculations are presented in Figure 4.  
Also, hairs were removed from all the images during the testing phase by using the DullRazor [61] algorithm for more accurate detection and segmentation. This algorithm removes the hairs over the lesion in three steps. In the first step, it identifies the hair locations by using a grayscale morphological  
Figure 4: Labeling a skin lesion image for the training of [PERSON]. The upper left corner coordinates (x1, y1) and the bottom right corner coordinates (x2, y2) of bounding box was were used for determining of the bounding box x, y, w, and h values.  
Figure 3: Flow chart of the proposed method including all steps.  
closing operation. At the second step, it verifies the hair locations by looking at the length and thickness of the detected shapes and then, the verified pixels are replaced by using the bilinear interpolation method. In the final step, it smooths the replaced pixels with the help of an adaptive median filter. Figure 5 demonstrates hair removal results.