The main challenge in an automated diagnostic system for the early diagnosis of melanoma is the correct segmentation. In skindermoscope images manyartifacts such as ruler markings, air bubbles and hairsmust be removed to correctly diagnosis skin cancer. This paper focuses on the use of image processing techniques to automatically detects and removes hairs and ruler markings from dermoscopy images. The proposed algorithm includes two main steps: firstly, hairs and ruler marking are isolatedby generating a binary image mask include these artifacts only. The suggested mask procedure start with separate RGB dermoscopy images to the red, green and blue color components.Utilizingred channelto create the mask by applying noise removing on this plan, then adaptive canny edge detector is used for refinement by morphological operators. Secondly, the white regions ofthe mask are repaired based onpolygonsinpainting. Experiment on a number of dermoscopy images demonstrates that the proposed method produces superior results compared to existing techniques.