by Zhi-Yi Chin
Our goal is to apply KNN matting to do image composition. We use KNN matting to get the α value from the original image with a corresponding trimap; we extract the foreground from the original image and paste it to a new background. The α value decides the pixel weight of the composite image.
You can download a copy of all the files in this repository by cloning the repository:
svn export https://github.com/joycenerd/Image_Manipulation_Techniques_Visual_Effects/trunk/hw1
You need to have Anaconda or Miniconda installed in your environment. You can create a virtual environment using conda
and install all reequired dependencies in it by:
conda env create -f environment.yml
conda activate matte
You can use the data we provided in image/
, trimap/
and background/
to reproduce our results. Or you can download data from alphamating datasets.
image/
: contains the source imagetrimap/
: contains the trimap of the source imagebackground/
: contains the new background you want
You can put your own data in the folders mention above and name them with the same name, also the image should be png
format.
release.py
is our main code implementation.
python release.py [--name NAME] [--k K]
optional arguments:
--name NAME image name
--k K k nearest neighbors k
ex:
python release.py --name winnie --k 100
The results will be generated in result/
with the name same as --name
parameter.
We thank the authors of these repositories: