# Image segmentation algorithm

I wonder if there are algorithms used to segment images efficiently. The ones I tested by now can not segment hair correctly as on this image:

I just want to know if someone can give me some efficient algorithms to segment the hair on this image for example without cutting it and so on (correct segmentation)

Note that I tested famous algorithms such as watershed, grabcut, mean shift ... but no one of them segments this hair correctly.

Thank you very much in advance.

You can find what you need here where a comparaison of lot of matting algorithms is done. You can see the rank of those algorithms' performances as well as online demonstration on a natural and complicated image.

From that study, you can guess that A Global Sampling Method for Alpha Matting is the best algorithm to resolve your problem. The algorithm is conceived by A Global Sampling Method for Alpha Matting Kaiming He, Christoph Rhemann, Carsten Rother, Xiaoou Tang and Jian Su.

Hope this helps.

What exactly did you expect from segmentation? The problem here is that there aren't real segments to start with.

That said, this looks like a case for texture-based segmenting. most of the hair has a grooved texture with one predominant direction.

You could try difference matting.

I quote from A bayesian approach to digital matting

Under some circumstances, it might be possible to photograph a foreground object against a known but non-constant background. One simple approach for handling such a scene is to take a difference between the photograph and the known background and determine α to be 0 or 1 based on an arbitrary threshold. This approach, known as difference matting (see, e.g., [9]) is error prone and leads to “jagged” mattes. Smoothing such mattes by blurring can help with the jaggedness but does not generally compensate for gross errors.

Its a very simple algorithm, making it easy to implement and fast to run. You would not even need a trimap. It has the obvious accuracy problems mentioned in that paper, but given your picture is on a constant white background I doubt they would be an issue. Of course, if you wanted it to work on more complex backgrounds, you might have to come up with something else.