The senior design project I have been working on in school is a "smart mirror". Equipped with a thermal and RGB camera, its primary purpose is to analyze a user's face and give health feedback. The subsystem I was responsible for was image processing and my goal was to analyze the images to obtain health metrics. On this page I go over analyzing skin images to locate lesions.
Skin lesions are areas of the skin that are abnormal in appearance, such as acne and moles. Being able to locate skin lesions would give a metric for our smart mirror to track skin health over time.
The process is inspired by a paper, "Acne image analysis: lesion localization and classification".
An assumption of this process is that the input image is just skin and has already been extracted. The first step is to convert the image from BGR to CIE L*a*b* color space. Then three channels are mixed into one using weights that were found experimentally.
A guassian blur and adaptive thresholding is then applied. Why adaptive thresholding? Thresholding like Otsu's method considers the entire image when choosing a threshold value but does not work particularly well here because of uneven lighting conditions. Adaptive thresholding applies different thresholds for different regions of the image based on the local conditions of that region.
We are left with a binary image, white areas being the "blobs" that could be lesions. However some will be too small or clumped together so we apply open and erosion morphological transformations to filter them out.
Finally we find contours (vectors of points that outline region-of-interest) of the blobs and filter those further by discarding those that are still too small or too elongated. All the contours left over should then correspond to skin lesions.
There are parameters that should be adjusted depending on how large the image is and how large the lesions are. These are: Gaussian filter k-size, adaptive threshold block size, size of the morphological elements, and the minimum and maximum contour area. These parameters go up if the image is large or if the lesions take up a large area of the image. You could apply several rounds of this process to detect lesions of various sizes.
The weights of the channel mixing are parameters that can affect what kinds of blobs are detected. You can experiment with other color spaces and combinations of channels to detect different kinds of lesions. For example the Cr channel of the YCrCb color space does a pretty good job of detecting red lesions.
This particular case is suppose to catch skin lesions that are darker than the surrounding skin. However there are cases where the skin lesions are lighter than the surrounding skin, particularily for those who have darker skin. Therefore this process will not work for all skin and lesion types.
This process also works less well when a flash had been used when taking the image. The flash reflects off the skin and distort what the skin actually looks like. Ideally images of the skin are taken in uniform lighting with no flash.
Github, which includes C++ OpenCV code and example output results for several skin images.