MATLAB Answers

Hair Removal Algorithm method clarification (New to matlab)

59 views (last 30 days)
Milinda
Milinda on 22 Feb 2012
Commented: Walter Roberson on 9 May 2017
Hi all,
I am new to Matlab and was looking to implement an algorithm for hair removal from skin lesion images, I am trying to base my algorithm on the methods described here
"1) It identifies the dark hair locations by a generalized grayscale morphological closing operation, 2) It verifies the shape of the hair pixels as thin and long structure, and replace the verified pixels by a bilinear interpolation, and 3) It smooths the replaced hair pixels with an adaptive median filter."
I am currently confused about the "generalized grayscale morphological closing operation" and what it means. Plus additionally I could not get any standard information on this via researching, if anyone could guide me as to what it means it would be quite helpful
Secondly while I did understand what bilinear interpolation means, the examples I could find was only on resizing images, if anyone could point me out to an example where neighboring pixels are replaced I would be grateful
I currently do not have much knowledge on image processing, if anyone could suggest an alternative method on separating the hairs from the skin as the hair is black (as the skin is likely to be brown at most) and identifying the hair pixels which could be appropriately replaced by bilinear interpolation I would be grateful
Any help would be really appreciated
UPDATE
I have so far managed to apply a bottom hat filter to get all of the hair pixels, however I am currently stuck on replacing the pixels, currently I am trying to utilize roifilter for this purpose
%load image
image = im2double(imread('fig2.jpg'));
%get hairs using bottomhat filter
se = strel('disk',2);
hairs = imbothat(image,se);
%stats
%matrice = logical(rgb2gray(hairs));
replacedImage = roifill(rgb2gray(image), rgb2gray(hairs));
figure, imshow(replacedImage);
Currently thats the code I have written, for the roifill function used I am using the "J = roifill(I, BW)" signature where I send a grayscale image as the mask, however the "replacedImage" variable still contains the image with hairs instead of a filtered image. Any clue on what I am doing wrong here? Additionally the hairs appear in WHITE in the grayscale version of the bottomhat filtered image, should it be perhaps black instead? Any guidance on solving this issue is appreciated
UPDATE 2
%load image
image = im2double(imread('fig2.jpg'));
grayscale = rgb2gray(image);
mediatedImage = medfilt2(grayscale);
%get hairs using bottomhat filter
se = strel('disk',5);
hairs = imbothat(mediatedImage,se);
lab_mask = bwlabel(hairs);
stats = regionprops(lab_mask, 'MajorAxisLength', 'MinorAxisLength');
%identifies long, thin objects
Aaxis = [stats.MajorAxisLength];
Iaxis = [stats.MinorAxisLength];
idx = find((Aaxis ./ Iaxis) > 4); % Selects regions that meet logic check
out_mask = ismember(lab_mask, idx);
disp(out_mask);
%replacedImage = roifill(image, hairs);
figure, imshow(out_mask);
Hi I currently am getting stuck after applying the bottom hat filter, while the bottom hat filter displays successful results the bwlabeled version of it doesn't. Currently is a following result of the above code
The problem here is that there is noise in both images after applying the bottom hat filter and even with a median filter they are not eliminated, any suggestions on fixing this issue?
Regards, Milinda

  4 Comments

Show 1 older comment
Sean de Wolski
Sean de Wolski on 22 Feb 2012
A morphological hole filling could also possibly be effective.
Image Analyst
Image Analyst on 28 Feb 2012
As would be tophat filters. But definitely stay away from erosion filters.

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 22 Feb 2012
I don't know it by that name. It's probably like a top hat or bottom hat filter, which is basically subtracting the original image from the morphological closed or opened version of it. That should get you the dark hairs. Then call bwlabel and regionprops to identify long skinny objects and throw out the rest. See my demos in my File Exchange. I don't really have the time to rewrite dull razor in MATLAB for you. You could use roifill() to fill in behind the detected hairs which would probably be better and easier than bilinear interpolation.

  8 Comments

Show 5 older comments
Image Analyst
Image Analyst on 29 Feb 2012
Now that I can see your images (except the first one which says "forbidden") I think you can just threshold and call roifill(). Try that.
Milinda
Milinda on 29 Feb 2012
Threshold doesn't seem to be accurate enough as certain details tend to be left out, however I cant get roifill properly for some reason, I for now took the thresholded image (with a value of 0.2) (image - http://desmond.imageshack.us/Himg201/scaled.php?server=201&filename=36563760.png&res=medium), and then when I apply roifill I get almost the same image (roifilled image - http://desmond.imageshack.us/Himg545/scaled.php?server=545&filename=77564307.png&res=medium), the only difference with the original image (original - http://desmond.imageshack.us/Himg38/scaled.php?server=38&filename=grayscale.png&res=medium) is that the hair is more of a lighter gray color than black thus concluding that the roifill has been applied but has not achieved the desired result. Any idea on what's wrong and should be done?
Milinda
Milinda on 29 Feb 2012
Also any suggestions for the previous "noise" issue aand threshold leaving some details out?

Sign in to comment.


asma arafat
asma arafat on 9 May 2017
how i can remove eyebrows from an image to use edge detectors after that and i don't need eyebrows to detect as edge. any help!!?

  1 Comment

Sign in to comment.

Sign in to answer this question.