Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hair detection

37 views
Skip to first unread message

Mitja

unread,
Nov 24, 2009, 1:20:19 PM11/24/09
to
Hello!

I have a problem with my project. Title is hair segmentation / detection. I don't know how to start doing it, seperate hair from picture (portreit ) with filters, so that at the end I can chance hair color. I would really appreciate your suggestions, support,
sample or code.

ImageAnalyst

unread,
Nov 24, 2009, 2:02:08 PM11/24/09
to

------------------------------------------------------------
It's not easy. It might seem so at first but once you get it working
for one head, then another one comes along with a different haristyle
that messes up your algorithm. But anyway, you'll have to use a
variety of classification methods and need to combine them to see if
some pixel is really hair or not. You might even have to look for
what is not hair (e.g. flesh tones and background colors, if known)
and use spatial information (e.g. background is expected to be
connected to the edge of the photo while flesh tones are not connected
to the border, and hair may or may not be connected to the border).
You could look at color classification - but that could pick up pixels
in the face or clothing or even background. You could look at
texture. You could try region growing. And, like I said, look at
position/location. You might look at other things too and list all
the measurements in a "feature vector." Then train it by outlining
known hair regions by hand and seeing what the feature vector looks
like for the known hair regions. Then see how well your test regions
match that (to within some tolerance).

Mitja

unread,
Nov 24, 2009, 2:34:20 PM11/24/09
to

> It's not easy. It might seem so at first but once you get it working
> for one head, then another one comes along with a different haristyle
> that messes up your algorithm. But anyway, you'll have to use a
> variety of classification methods and need to combine them to see if
> some pixel is really hair or not. You might even have to look for
> what is not hair (e.g. flesh tones and background colors, if known)
> and use spatial information (e.g. background is expected to be
> connected to the edge of the photo while flesh tones are not connected
> to the border, and hair may or may not be connected to the border).
> You could look at color classification - but that could pick up pixels
> in the face or clothing or even background. You could look at
> texture. You could try region growing. And, like I said, look at
> position/location. You might look at other things too and list all
> the measurements in a "feature vector." Then train it by outlining
> known hair regions by hand and seeing what the feature vector looks
> like for the known hair regions. Then see how well your test regions
> match that (to within some tolerance).
-----------------------------------------------------------------------------------------------------------------
Well I had an idea how to simplify a little bit. for the first time I would use homogeneously backgroung (blue or white color), so i could then "cut" it off, and even do the same whit skin tone! and than I "made" edges and from there I would like to separate hair. but i think i will have the biggest problems at the and with separation.

ImageAnalyst

unread,
Nov 24, 2009, 4:37:25 PM11/24/09
to
On Nov 24, 2:34 pm, "Mitja " <kastelic.mi...@gmail.com> wrote:
> Well I had an idea how to simplify a little bit. for the first time I would use homogeneously backgroung (blue or white color), so i could then "cut" it off, and even do the same whit skin tone! and than I  "made" edges and from there I would like to separate hair.  but i think i will have the biggest problems at the and with separation.  - Hide quoted text -
>
-----------------------------------------------------------
Perhaps you'd like to see my image segmentation demo. If you're going
to just use simple thresholding in this phase of your project, then
the demo may help you.
http://www.mathworks.com/matlabcentral/fileexchange/25157
You can just threshold each of the color planes and then combine them,
something like
redPlane = rgbImage(:,:,1);
greenPlane = rgbImage(:,:,2);
bluePlane = rgbImage(:,:,3);
redBinary = redPlane > lowThresholdR & redPlane < highThresholdR;
greenBinary = greenPlane > lowThresholdG & greenPlane <
highThresholdG;
blueBinary = bluePlane > lowThresholdB & bluePlane < highThresholdB;
overallBinary = redBinary & greenBinary & blueBinary;

Then just call bwlabel (or bwconncomp in R2009b), regionprops, and so
on.
Maybe you'd like to post an image somewhere (on a free image hosting
web site), although I won't be answering any questions from tomorrow
morning through Saturday night (but there are many other talented
people here who could help you if you post an image and some code.)
Regards,
ImageAnalyst

Mitja

unread,
Dec 3, 2009, 5:06:00 AM12/3/09
to
Hello!

Well, I looked at the demo http://www.mathworks.com/matlabcentral/fileexchange/25157 and I find par of code that is interesting to me (!!!foregroud and backgroud!!!):

% Threshold the image to get a binary image (only 0's and 1's) of class "logical."
% Method #1: using im2bw()
% normalizedThresholdValue = 0.4; % In range 0 to 1.
% thresholdValue = normalizedThresholdValue * max(max(originalImage)); % Gray Levels.
% binaryImage = im2bw(originalImage, normalizedThresholdValue); % One way to threshold to binary
% Method #2: using a logical operation.
thresholdValue = 100;
binaryImage = originalImage > thresholdValue; % Bright objects will be the chosen if you use >.
% binaryImage = originalImage < thresholdValue; % Dark objects will be the chosen if you use <.

% Do a "hole fill" to get rid of any background pixels inside the blobs.
binaryImage = imfill(binaryImage, 'holes');


I dont know yet how to implement this code to may project. I thought i could use a portret of some person on blue or white background. This would be initial picture. The plan would be next: 1. I would made face recognition 2. frequential mask 3. Color mask 4. fusion and markers placement (white for foregroung and black for background) 5. alpha matte estimated 6. hair segmentation. It was taken from that article: http://www-video.eecs.berkeley.edu/Proceedings/ICIP2008/pdfs/0002276.pdf


if its posible I would do it in less steps if it's posible.

Branko

unread,
Dec 3, 2009, 5:47:01 AM12/3/09
to
"Mitja " <kasteli...@gmail.com> wrote in message <hf82i8$p5$1...@fred.mathworks.com>...

Have you looked this it may help you:

http://www.cs.huji.ac.il/~yweiss/Colorization/

Branko

Mitja

unread,
Dec 8, 2009, 4:04:02 AM12/8/09
to
Hello! I looked this example. I have opened the matlab code and its not working! in
--------------------------------------------------------------------
cheapUI.m writs an error:

??? Input argument "im1" is undefined.
Error in ==> cheapUI at 3
gg=rgb2gray(im1);
--------------------------------------------------------------------
in colorize.m if I insert some other picture it doesn't work!
error:

?? Error using ==> rgb2ntsc>parse_inputs at 76
RGBMAP must be an M-by-3 array.

Error in ==> rgb2ntsc at 29
A = parse_inputs(varargin{:});

Error in ==> colorize at 15
sgI=rgb2ntsc(gI);
-----------------------------------------------------------------------
in colorizeFun.m puts next error:

??? Error using ==> rgb2ntsc>parse_inputs at 76
RGBMAP must be an M-by-3 array.

Error in ==> rgb2ntsc at 29
A = parse_inputs(varargin{:});

Error in ==> colorizeFun at 16
sgI=rgb2ntsc(gI);

I would really need some help, becouse I dont know what to do!!!

ImageAnalyst

unread,
Dec 8, 2009, 6:21:58 AM12/8/09
to
I don't know - I didn't run it. But are you sure you're giving it an
rgb image and not a monochrome image? Maybe that would cause the
error (but I doubt it).

Mitja

unread,
Dec 14, 2009, 4:44:32 AM12/14/09
to
well i tried with this code. The problem is that, that works only on this picture (geeks.jpeg). If I change to any other picture, the code doesnt work any more and I cant find why!!! Can anybody pleese help me!?

http://www.kyb.mpg.de/bs/people/kienzle/fdlib/fdlib.htm

downaload: - fdlib for Matlab (Windows)

bhattpooja

unread,
Dec 4, 2012, 2:01:17 PM12/4/12
to
hi,
any one can help me in my project?I want to implement algo for face recognization using hair and skin detection.
Any one having code regarding this.
reply me as soon as possible.


0 new messages