I have an image like this:

enter image description here

I am trying to build a semantic segmentation and matting model which currently gives an output like this:

enter image description here

One can see that some regions between the hair strands are fuzzy. This is because the value of the alpha channel in between those regions are non-zero. Is it possible to somehow adjust the alpha values in just those regions as a post-processing step, in order to make the hair strands sharper?

My expected output would be something like this. Notice how the hair strands are sharper and the regions between the strands are completely transparent (alpha value 0):

enter image description here

  • $\begingroup$ Your question isn't clear. $\endgroup$
    – Royi
    Sep 28, 2019 at 9:29
  • $\begingroup$ Well you already defined the filter yourself. Check if a pixel has an alpha value < 1 and filter them out. $\endgroup$
    – Tyathalae
    Oct 1, 2019 at 15:42

1 Answer 1


This is known as Image Matting.
Specifically you're after portrait matting.

Currently there are great result even for semi transparent areas like hair using U-Net Square.

Even for Deep Learning based models, people do some finish work based on A Closed Form Solution to Natural Image Matting which is pretty straight forward to implement.

When I worked on such problem I found the thesis Vincent Zhu - Improving Hair Segmentation using Image Matting (On WayBack Machine) to be useful.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.