'image segmentation of skin lesion

I have images dataset out of which I'm supposed to segment the skin lesion part. I'm attaching some sample images, I'd like to get some suggestions as to what may work on these type of images. Thank youenter image description here

enter image description here

enter image description hereenter image description here



Solution 1:[1]

Here is a simple method that should allow you to segment the skin lesions. it uses a maximum filter to get the darker areas of the image and then dbscan clustering to separate the zone of interest from the hairs.

import matplotlib.pyplot as plt
import numpy as np
import skimage.io
from scipy import ndimage as ndi
from sklearn.cluster import DBSCAN
img = skimage.io.imread('0moBX.jpg')[:,:,0]


image_max = ndi.maximum_filter(-img, size=10, mode='constant')
image_max = image_max > np.quantile(image_max, 0.8)

X = np.array(np.nonzero(image_max)).transpose()
clustering = DBSCAN(eps=10, min_samples=200).fit(X)

fig, axs = plt.subplots(ncols = 2, sharex = True, sharey = True)
axs[0].imshow(image_max, cmap=plt.cm.gray)
clustering.labels_[clustering.labels_ == -1] = max(clustering.labels_)+1
axs[1].scatter(X[:,1], X[:,0], c = clustering.labels_) 
plt.show()

I didnt tune the parameters properly but you should be able to get your larger cluster on the lesion pixels by tuning eps and min_samples in dbscan. enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 endive1783