This repository is part of a collection of three repositories. See the links below for the related projects.
ColorTransferAlg is a template repository which can be modified and installed to provide new color transfer algorithms to ColorTransferLib.
- Open the
setup.pyand change the name, author and author_email.
setuptools.setup(
name="ColorTransferLib-<TO-DO>",
author="<TO-DO>",
author_email="<TO-DO>",
...-
Change the name within
LICENSE. -
Rename the folder
TestAlgo, the filesTestAlgo.jsonandTestAlgo.py, and the class name inTestAlgo.pyto the name of your algorithm. If you want to follow the naming convention, use your last name and the last two digits of the current year (e.g., Doe26). -
Add additional options to
TestAlgo.json. See ColorTransferLib for examples of how these options can be defined. -
In
TestAlgo.py, update the copyright notice and the information section to reference the publications on which the algorithm is based. -
TestAlgo.pycontains a class method for each data type. For example, the method for images is called__apply_image(cls, src, ref, opt). Update the implementation of these methods to match your algorithm.
ColorTransferLib must be installed beforehand. See the corresponding repository for installation instructions.
Once you have cloned and modified the ColorTransferAlg repository locally, you can install it in your environment using:
pip install <path>/ColorTransferAlg/.
from ColorTransferLib.ColorTransfer import ColorTransfer
from ColorTransferLib.DataTypes.Image import Image
src = Image(file_path='/media/source.png')
ref = Image(file_path='/media/reference.png')
algo = "Doe26"
ct = ColorTransfer(src, ref, algo)
ct.set_option("colorspace", "rgb")
out = ct.apply()
if out["status_code"] == 0:
out["object"].write("/media/out")
else:
print("Error: " + out["response"])