This python script lets you remove background form image by keeping only foreground in focus. By using Grabcut Algorithm it makes easy to do the task.
We make use of OpenCV, numpy libraries of Python.
This Script:
- Takes image as input and
- Asks user to select ROI by dragging mouse pointer.
- Performs background subtraction.
- Displaying the updated image.
- Saving the processed image in your current directory.
-
Create a virtual environment and activate it.
-
Install the requirements
$ pip install -r requirements.txt
$ python BG_Subtractor.py
- Enter valid file location/path.
- Select ROI by using mouse pointer on the window BG Subractor.
- Then script will process the image.
- Image Bg_removed.jpg will be stored in your current directory.