This is broadly called natural image matting if anyone is curious enough to look into the last 20 years of research.
(wouldn't it be nice if every time a research topic pops up here that there would be a small list of the essential keywords to look for more background information?)