color-matcher¶
Description¶
color-matcher enables color transfer across images which comes in handy for automatic color-grading of photographs, paintings and film sequences as well as light-field and stopmotion corrections. The methods behind the mappings are based on the approach from Reinhard et al., the Monge-Kantorovich Linearization (MKL) as proposed by Pitie et al. and our analytical solution to a Multi-Variate Gaussian Distribution (MVGD) transfer in conjunction with classical histogram matching. As shown below our HM-MVGD-HM compound outperforms existing methods.
Results¶
Source |
Target |
Result |
|
---|---|---|---|
Photograph |
|||
Film sequence |
|||
Light-field correction |
|||
Paintings |
Installation¶
- via pip:
install with
pip3 install color-matcher
type
color-matcher -h
to the command line once installation finished
- from source:
install Python from https://www.python.org/
download the source using
git clone https://github.com/hahnec/color-matcher.git
go to the root directory
cd color-matcher
load dependencies
$ pip3 install -r requirements.txt
install with
python3 setup.py install
if installation ran smoothly, enter
color-matcher -h
to the command line
CLI Usage¶
From the root directory of your downloaded repo, you can run the tool on the provided test data by
color-matcher -s './tests/data/scotland_house.png' -r './tests/data/scotland_plain.png'
on a UNIX system where the result is found at ./tests/data/
. A windows equivalent of the above command is
color-matcher --src=".\\tests\\data\\scotland_house.png" --ref=".\\tests\\data\\scotland_plain.png"
Alternatively, you can specify the method or select your images manually with
color-matcher --win --method='hm-mkl-hm'
Note that batch processing is possible by passing a source directory, e.g., via
color-matcher -s './tests/data/' -r './tests/data/scotland_plain.png'
More information on optional arguments, can be found using the help parameter
color-matcher -h
API Usage¶
from color_matcher import ColorMatcher
from color_matcher.io_handler import load_img_file, save_img_file, FILE_EXTS
from color_matcher.normalizer import Normalizer
import os
img_ref = load_img_file('./tests/data/scotland_plain.png')
src_path = '.'
filenames = [os.path.join(src_path, f) for f in os.listdir(src_path)
if f.lower().endswith(FILE_EXTS)]
cm = ColorMatcher()
for i, fname in enumerate(filenames):
img_src = load_img_file(fname)
img_res = cm.transfer(src=img_src, ref=img_ref, method='mkl')
img_res = Normalizer(img_res).uint8_norm()
save_img_file(img_res, os.path.join(os.path.dirname(fname), str(i)+'.png'))
Experimental results¶
The above diagram illustrates light-field color consistency from Wasserstein metric
where
Citation¶
@ARTICLE{plenopticam,
author={Hahne, Christopher and Aggoun, Amar},
journal={IEEE Transactions on Image Processing},
title={PlenoptiCam v1.0: A Light-Field Imaging Framework},
year={2021},
volume={30},
number={},
pages={6757-6771},
doi={10.1109/TIP.2021.3095671}
}