This is a very simple python Implementation of Interactive Digital Photomontage.
This implementation is far from faithful to the original paper. It only supports "Designated image" data penalty and "colors" interaction penalty, as dicussed in Section 3 of the paper. Also, for simplicity, alpha-beta swap is used in place of alpha expansion in the graph-cut stage. The way user interacts with the program is also different.
The code for poisson blending is largely borrowed from this repo.
The code is in Python 3. The GUI is written in tkinter, which should be shipped with most python distribution.
PyMaxflow and cv2 are required.
The usage is very simple. First put the source images in source_imgs
directory (only .jpg
and .jpeg
are supported). Then in the command line, run python main.py
, the window as above should appear.
The image on the left is the current composite image. The image in the middle is one of the source images. You can click "Next image" to switch to next source image. The map on the right is the label map which indicates which part of the composite comes from which source image.
This implementation blends current composite image with one source image at a time. The only thing you need to do is to draw a few strokes on the composite image and source image respectively, which indicate which parts of the composite and source image you want to preserve. Then click the "Run" button and wait for a few seconds. The new composite image will be generated on the left, along with the label map on the right. These two images are saved in the output_imgs
directory.