Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
979 views
in Technique[技术] by (71.8m points)

opencv - Detecting hair in a portrait image?

What would be the best approach for detecting and removing a person's hair in a simple portrait image ? Any useful libraries of algorithms ? I have been looking over openCV which looks like it could be of some use

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You're dealing with two different problems here:

  1. detecting if a face in a portrait has hair
  2. "removing" the hair

The first is solvable fairly easily:

  • Separate the face from the background (as you've mentioned a "simple portrait image", this shouldn't be too hard).
  • Convert your image to the Y'CbCr color space
  • Human skin has a fairly narrow range of chrominance values, regardless of race. Check out this paper for the details.
  • The approach above will help you separate skin areas of the face from non-skin areas
  • Assume that the non-skin areas consist of hair. Note that facial hair will get picked up as a non-skin area, too.

As far as the second problem goes, you need to clarify exactly what you mean by "removing":

  • Are you simply cutting out the part of the portrait that has hair? In this case, the solution follows directly from the detection method above.
  • Are you trying to make it look like the person has no hair at all (e.g. is bald, clean-shaven?) In this case, things will be a lot harder -- there's a reason why professional photo manipulators get paid well.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...