MarcoForte / FBA_Matting

Official repository for the paper F, B, Alpha Matting
MIT License
464 stars 95 forks source link

Random foreground composition vs solving #44

Open shkarupa-alex opened 3 years ago

shkarupa-alex commented 3 years ago

In paper you wrote:

To further increase the dataset diversity, we randomly composite a new foreground object with 50% probability, as in [34].

Could you please provide more details on how exactly you did it. Did you compose foregrounds before or after solving colors in areas where alpha is 0. And did you do something (maybe mean?) to save correct foreground colors during composition where both fg's alpha is 0?

I noticed that if i compose solved foregrounds it results to dominating "background" fg colors where alpha is 0.

Here is an example of compositioning 2 foregrounds in different order. Look at "orange"/green background.

Снимок экрана 2021-04-06 в 09 25 33

And here is what i've got if solve combined fg one more time (but as i think, double solving could lead to incorrect colors in semitransparent regions)

Снимок экрана 2021-04-06 в 09 28 51
MarcoForte commented 3 years ago

Good question.
When compositing a foreground above one another we essentially solve for the foregrounds three times.

  1. Solve for each foreground independently.
  2. Resize/crop the second foreground to be placed on top.
  3. Perform the alpha compositing, using the over operator. https://en.wikipedia.org/wiki/Alpha_compositing
  4. Re-estimate the extended foreground.

To re-estimate the foreground you could use the pymatting library which is quite fast. Faster then the implementation I have on my github. https://pymatting.github.io/pymatting.foreground.html#module-pymatting.foreground.estimate_foreground_ml