Objects Extraction from an Image using Python

Viewed 2041

I'm trying to implement a python program to remove the background and extract the object/objects in the foreground from any given static image (as shown in the attached images). This is similar to "iPhoneX Portrait Effect" or "Bokeh Effect". However, instead of blurring the background one needs to completely remove it.

In short, I want to extract objects from any given image and also create a mask. Below are the examples of both respectively:

Object Extraction:

Object Extraction

Image Mask:

enter image description here

I have somewhere listened to Google's DeepLab, but I don't know how to start with it.

Can someone help me, please! Any step by step tutorial will be very appreciated.

Thanks in advance!

2 Answers

This is a really hard task, there is a reason there are basically no good software to do this already, even in photoshop this is a struggle. I can advice you to start with open Cv and their implemented facial tracking which you may need to configure to work with animals if thats your goal

resources

facial detection:
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html#face-detection

object detection:
https://docs.opencv.org/2.4/modules/contrib/doc/facerec/facerec_tutorial.html

Firstly you should collect data(image) for which object you want to detect or extract the object/objects in the foreground and also create a mask.

Then using tensorflow you can train an instance segmentation model Using your own dataset. (Ref : instance_segmentation)

After getting mask you can extract the foreground.

Related