This tool helps you to extract foreground and background from images.
run following command to install prerequisites.
pip install -r requirements.txt
Run program for your photo by following comand. (use your photo instead of images/2.jpg
!)
python main.py images/2.jpg
you can select foreground by left click on the photo and after that, selected point will be shown by a green circle.
by doing left click again on each point, undo it.
you can select background by right click on the photo and after that, selected point will be shown by a red circle.
by doing right click again on each point, undo it.
using d
in your keyboard, clear all your screen from all selected points.
you can do your segmentation proccess by pressing c
on your keyborad.
you can save your file using s
on your keyboard.
you can reselect foreground and background by pressing r
in keyboard.
following code shows you how to use this tool as a developer.
# import graph cut tools
import graph
# load image by graph
network = graph.Image(image)
# do cut by using some of foreground and background pixels
network.do_cut(some_foreground_pixels, some_background_pixels)
# extracting foreground and background pixels
foreground = network.get_foreground()
background = network.get_background()