FritzHairColorDemo

While creating a mask to apply hair color via:

let mask = result.buildSingleClassMask(
        forClass: FritzVisionHairClass.hair,
        clippingScoresAbove: clippingScoresAbove,
        zeroingScoresBelow: zeroingScoresBelow,
        resize: false,
        color: maskColor)

Is there a way to apply a gradient instead of a single color. Or another way to achieve this via Fritz SDK ?

Above code is taken from LiveHairViewController class in the demo provided by Fritzlabs

Thanks for your question.

We don’t currently have any built in functions for gradients, but it would definitely be possible for you to implement that yourself.

Would it be possible for you to guide me in the direction for that ? A starting point would be greatly appreciated.

Unfortunately, creating gradients and filters falls a bit outside of our expertise in mobile machine learning and I don’t have any resources for you at this time. At a high level, you need to create an image that is just your desired gradient and then use the mask as an alpha channel for that when displaying on a screen.

Thank you for the responses and direction. Appreciated.

I don’t think that creating your own mask would work. For example, if I add gradient on a UIImage, it will apply that gradient on the whole image irrespective of the segmented hair. Is there a way to add gradient on the segmented hair?