Hair Removal Algorithm method clarification (New to matlab)
16 views (last 30 days)
Show older comments
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
Test Image 1 - http://melanoma.blogsome.com/wp-admin/images/420.jpg Bottom Hat image (variable:hairs) - <http://desmond.imageshack.us/Himg37/scaled.php?server=37&filename=uploadaa.png&res=medium> Bwlabel image (variable:lab_mask) - <http://desmond.imageshack.us/Himg593/scaled.php?server=593&filename=uploadab.png&res=medium>
Test Image 2 - http://www.dermweb.com/dull_razor/DullRazor_files/fig1.gif Bottom Hat image (variable:hairs) - <http://desmond.imageshack.us/Himg849/scaled.php?server=849&filename=uploadba.png&res=medium> Bwlabel image (variable:lab_mask) - <http://desmond.imageshack.us/Himg832/scaled.php?server=832&filename=uploadbb.png&res=medium>
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
Image Analyst
on 28 Feb 2012
As would be tophat filters. But definitely stay away from erosion filters.
Answers (2)
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
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
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!