Skip to content

Performs color transfer between two images. Loosely based on the "Color Transfer between Images" paper by Reinhard et al., 2001.

License

Notifications You must be signed in to change notification settings

AdamSpannbauer/color_transfer

 
 

Repository files navigation

Super fast color transfer between images

The color_transfer package is an OpenCV and Python implementation based (loosely) on Color Transfer between Images [Reinhard et al., 2001] The algorithm itself is extremely efficient (much faster than histogram based methods), requiring only the mean and standard deviation of pixel intensities for each channel in the L*a*b* color space.

For more information, along with a detailed code review, take a look at this post on my blog.

Requirements

  • OpenCV
  • NumPy

Install

To install, make sure you have installed NumPy and compiled OpenCV with Python bindings enabled.

From there, there easiest way to install is via pip:

$ pip install color_transfer

Examples

Below are some examples showing how to run the example.py demo and the associated color transfers between images.

$ python example.py --source images/autumn.jpg --target images/fallingwater.jpg Autumn and Fallingwater screenshot

$ python example.py --source images/woods.jpg --target images/storm.jpg Woods and Storm screenshot

$ python example.py --source images/ocean_sunset.jpg --target images/ocean_day.jpg Sunset and Ocean screenshot

color_transfer options & auto_color_transfer

The color_transfer function has additional arguments for toggling clip and preserve_paper. These options can change how aesthetically pleasing the color transfer result is. See help(color_transfer.color_transfer) for more info on the arguments (or view this pull request thread for a more in depth discussion)

A utility function, auto_color_transfer, has been added to easily view the results of all combinations of these 2 arguments. In addition to showing all possible transfers, auto_color_transfer suggests the transfer that is truest to the source image's color (using mean absolute error to compare HSV color channels). Despite attempting to minimize error, the suggested result is not always the most aesthetically pleasing; this is why the comparison image is provided for the user to choose which result works best for the use case.

$ python auto_transfer_example.py -s images/storm.jpg -t images/ocean_day.jpg

About

Performs color transfer between two images. Loosely based on the "Color Transfer between Images" paper by Reinhard et al., 2001.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%