MarcoForte / closed-form-matting

Python implementation of A. Levin D. Lischinski and Y. Weiss. A Closed Form Solution to Natural Image Matting. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), June 2006, New York
MIT License
435 stars 107 forks source link

question: why np.concatenate is not called in solve_foreground_background.py ? #16

Closed wyshmily closed 5 years ago

wyshmily commented 5 years ago

I see this code line is called when --solve-fg is setted image

But in solve_foreground_background.py there is not. image

Just confused why is that?

merofeev commented 5 years ago

I think there is no any great idea behind this.

In the first case we concatenate foreground with alpha to output RGBA image that will be nicely displayed in most of image viewers and can be easily composed on the new background with almost any image editor.

Since solving for foreground with known alpha is very specific usecase, I made an assumption that user knows what he/she wants to do with foreground and background so we can just output raw data. Probably, it was bad design decision.

I think PR adding --rgba output option to solve_foreground_background.py and keeping --foreground and --background outputs intact is warmly welcome. I hope @MarcoForte will agree with me.

wyshmily commented 5 years ago

@merofeev Thank you very much.

I am working on developing a tool (for windows) with the "intelligent image cut out" functionality, and the cut out calculation should take place in the client side.

I use this code and found it a bit slow without gpu acceleration, even if I zoom in the image to about 200 pixels.

Can you provide some suggestion?

merofeev commented 5 years ago

Can you provide some suggestion?

In your case I would try two things:

  1. Don't use solve_foreground in interactive mode and just use it for final pass. In interactive mode use original image instead of estimated foreground image. In many cases solving for foreground gives just a minor barely noticeable improvement, so it can be omitted.
  2. Apply solve_foreground to downscaled image to save some computational time.
wyshmily commented 5 years ago

@merofeev Thanks a lot !