Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 3.07 KB

File metadata and controls

62 lines (46 loc) · 3.07 KB

This repository is part of a collection of three repositories. See the links below for the related projects.

Button 1 Button 2 Button 3

colortransferexample

ColorTransferAlg

python3.12.6


ColorTransferAlg is a template repository which can be modified and installed to provide new color transfer algorithms to ColorTransferLib.

Template Adjustment

  1. Open the setup.py and change the name, author and author_email.
setuptools.setup(
    name="ColorTransferLib-<TO-DO>",
    author="<TO-DO>",
    author_email="<TO-DO>",
    ...
  1. Change the name within LICENSE.

  2. Rename the folder TestAlgo, the files TestAlgo.json and TestAlgo.py, and the class name in TestAlgo.py to 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).

  3. Add additional options to TestAlgo.json. See ColorTransferLib for examples of how these options can be defined.

  4. In TestAlgo.py, update the copyright notice and the information section to reference the publications on which the algorithm is based.

  5. TestAlgo.py contains 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.

Installation

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/.

Usage

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"])