7
I am working with skin images, in the recognition of skin spots, and due to the presence of noises, mainly by the presence of hair, it is more complicated this work.
I have an example image in which I work on trying to highlight only the skin stain, but due to the large amount of hair, the algorithm is not effective. With this, I would like you to help me develop an algorithm for removal or decrease the amount of hair and so be able to highlight only my area of interest (ROI), which are the spots.
Algorithm used to highlight skin spots:
import numpy as np
import cv2
#Read the image and perform threshold
img = cv2.imread('IMD006.bmp')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.medianBlur(gray,5)
_,thresh = cv2.threshold(blur,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
#Search for contours and select the biggest one
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
cnt = max(contours, key=cv2.contourArea)
#Create a new mask for the result image
h, w = img.shape[:2]
mask = np.zeros((h, w), np.uint8)
#Draw the contour on the new mask and perform the bitwise operation
cv2.drawContours(mask, [cnt],-1, 255, -1)
res = cv2.bitwise_and(img, img, mask=mask)
#Display the result
cv2.imwrite('IMD006.png', res)
#cv2.imshow('img', res)
cv2.waitKey(0)
cv2.destroyAllWindows()
The algorithm behaves as expected for hairless images, as shown below:
How to treat these noises to the point of improving my region of interest?