0

I have come across this BackgroundMattingV2 AI library to remove background of an image. So, I have tried their example and it is working as shown. I watched this video to learn how to setup.

So far so good it is removing background, I tried other images as well and it working.

However, I can see some noise on the edges. I tried Image number 12 form here.

And here is the output Background Matting output

I have tried a few different settings with model type mattingrefine

  1. refine mode - full with backbone scale 0.125
  2. refine mode - sampling with sample pixcel 320000 and backbone scale 0.125
  3. refine mode - thresholding with threshold value as 0.7 and backbone scale 0.125

I can see some difference in the noise but it's not removed completely. Hence, I could conclude that the background matting is designed to work in this way and it is correct output.

Note that I am using python 3.9 on windows 10 OS.

So here are my questions:

  1. Am I thinking right that the best solution here is to apply feathers to the edges?
  2. I believe that this is possible using image processing library like openCV. But I could not find a good example that can show me how can I use openCV to apply feathers to the edges of the image. Can someone please provide sample code to soften the edges of the image. Attached image can be used as reference. The backgroundmatting can return the transparent image as numpy.ndarray or a PIL Image object.
  3. Any other option alternative to remove that unwanted noise and make edges cleaner?

Update


Thanks fmw42 I have applied the filter (Gaussian Blur) after searching in the forum this and this. I got better results and the noise was removed. Now, I am getting greedy and want the perfect edge.

enter image description here

Meritor
  • 166
  • 11
  • 2
    Search this forum. I have answered this type question a number of times about anti-aliasing the edges of the mask used for the alpha channel – fmw42 May 19 '22 at 00:41
  • 2
    See for example, https://stackoverflow.com/questions/51719472/remove-green-background-screen-from-image-using-opencv-python/72280828#72280828 and https://stackoverflow.com/questions/64208431/how-to-remove-visible-background-boundary-around-object-after-saliency-detection/64216970#64216970 – fmw42 May 19 '22 at 00:45

0 Answers0