Thread Subject: Hair detection

Subject: Hair detection

From: Mitja

Date: 24 Nov, 2009 18:20:19

Message: 1 of 9

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.

Subject: Hair detection

From: ImageAnalyst

Date: 24 Nov, 2009 19:02:08

Message: 2 of 9

On Nov 24, 1:20 pm, "Mitja " <kastelic.mi...@gmail.com> wrote:
> 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.

------------------------------------------------------------
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).

Subject: Hair detection

From: Mitja

Date: 24 Nov, 2009 19:34:20

Message: 3 of 9


> 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.

Subject: Hair detection

From: ImageAnalyst

Date: 24 Nov, 2009 21:37:25

Message: 4 of 9

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

Subject: Hair detection

From: Mitja

Date: 3 Dec, 2009 10:06:00

Message: 5 of 9

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.

Subject: Hair detection

From: Branko

Date: 3 Dec, 2009 10:47:01

Message: 6 of 9

"Mitja " <kastelic.mitja@gmail.com> wrote in message <hf82i8$p5$1@fred.mathworks.com>...
> 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.

Have you looked this it may help you:

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

Branko

Subject: Hair detection

From: Mitja

Date: 8 Dec, 2009 09:04:02

Message: 7 of 9

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!!!

Subject: Hair detection

From: ImageAnalyst

Date: 8 Dec, 2009 11:21:58

Message: 8 of 9

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).

Subject: Hair detection

From: Mitja

Date: 14 Dec, 2009 09:44:32

Message: 9 of 9

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)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
hair Mitja 24 Nov, 2009 13:24:07
detection Mitja 24 Nov, 2009 13:24:07
rssFeed for this Thread

Contact us at files@mathworks.com