Visualization and GraphicsInteractionDept ICSFaculty of ScienceUU


Gap Detection for Skin Image Segmentation and Hair Removal

Segmenting lesions from surrounding skin in dermoscopic images is the first, and most critical, required step for further (semi)automatic image analysis. However, small-scale image artifacts such as noise or occluding hairs adversely impair the performance and quality of many existing image segmentation techniques.

Gap Detection Method

To alleviate the above problems, we propose a new method for image segmentation. Key to this method is the observation that, for many existing segmentation methods, impairing artifacts come as small-scale noise or gaps that overlap with, or protrude into, the region to segment. To faithfully segment the image in presence of such artifacts, we need thus to classify gaps as

  • relevant to the shape of the lesion boundary (true positives)
  • hairs deeply cutting in/through in the lesion (false positives)

We want to automatically detect and keep true-positives, and in the same time detect and eliminate false-positives.

The proposed method consists of a combination of morphological image-processing operations, as follows:

  • an open-close operation is done to eliminate both true-positive and false-positive gaps
  • the skeleton, or medial axis S, of the open-closed shape is computed
  • the parts F of S falling outside the input shape are found
  • false-positive gaps are filled by inflating F based on the distance transform of the close-open of the input image

The use of the medial axis S allows us, thus, to effectively detect deep gaps protruding into the shape (such as created by hairs), while at the same time keep fine gap-details pertaining to the shape's boundary.

Segmentation results

The figure below compares, for a dermoscopic image, the segmentation produced by several well-known methods, a manual segmentation produced by a dermatologist, and the result of our gap-detection method. As visible, our method produces a segmentation which faithfully follows the contours of the lesion, but is not adversely influenced by artifacts such as hairs.

The figure below compares, for additional clarity, classical threshold-based segmentation (still frequently used by many imaging tools) with our method. As visible, our results are significantly less influenced by noise and/or occluding artifacts.

Digital hair removal

In addition to image segmentation, we can use our method to digitally remove occluding artifacts such as hairs. These artifacts are automatically detected as being gaps that significantly protrude in the lesion area. Once found, we remove gaps by using a classical image inpainting method.

The image below shows the results of our digital hair removal (DHR) on a highly challenging skin image having considerable occlusions created by hair of various density, tint, and thickness. We compared out method with the well-known DullRazor DHR technique [Lee et al., 1997]. As visible, our method succeeds in removing considerably more hair than DullRazor.


Our gap-detection method is implemented atop of the dense-skeleton image representation using our CUDA-based salience skeleton implementation. The method can process Handyscope images at full resolution in a few seconds on a MacBook Pro with a Nvidia 330 GTM graphics card.


  • Gap-Sensitive Segmentation and Restoration of Digital Images (2014),

A. Sobiecki, A. Jalba, D. Boda, A. Diaconeasa, A. Telea; Proc. EG UK Computer Graphics and Visual Computing (CGVC), the Eurographics Association.