Background: The removal of hair and ruler marks is critical in handcrafted image analysis of dermoscopic skin lesions. No other dermoscopic artifacts cause more problems in segmentation and structure detection. Purpose: The aim of the work is to detect both white and black hair, artifacts and finally inpaint correctly the image. Method: We introduce a new algorithm: SharpRazor, to detect hair and ruler marks and remove them from the image. Our multiple-filter approach detects hairs of varying widths within varying backgrounds, while avoiding detection of vessels and bubbles. The proposed algorithm utilizes grayscale plane modification, hair enhancement, segmentation using tri-directional gradients, and multiple filters for hair of varying widths. We develop an alternate entropy-based processing adaptive thresholding method. White or light-colored hair, and ruler marks are detected separately and added to the final hair mask. A classifier removes noise objects. Finally, a new technique of inpainting is presented, and this is utilized to remove the detected object from the lesion image. Results: The proposed algorithm is tested on two datasets, and compares with seven existing methods measuring accuracy, precision, recall, dice, and Jaccard scores. SharpRazor is shown to outperform existing methods. Conclusion: The Shaprazor techniques show the promise to reach the purpose of removing and inpaint both dark and white hair in a wide variety of lesions.


Mechanical and Aerospace Engineering

Second Department

Electrical and Computer Engineering

Third Department


Publication Status

Open Access

Keywords and Phrases

dermoscopy; hair removal; image processing; inpainting; mathematical morphology; segmentation

International Standard Serial Number (ISSN)

1600-0846; 0909-752X

Document Type

Article - Journal

Document Version


File Type





© 2023 Wiley, All rights reserved.

Publication Date

01 Apr 2023

PubMed ID