Skip to content

damianfral/colortransfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

colortransfer

colortransfer is a small tool that transfers the color distribution of one image to another image. It offers two methods of color transfer, histogram matching and ellipsoid transformation.

Color Transfer Methods

Histogram Matching

This method adjusts the mean and standard deviation of the color channels in the input image to match those of the reference image. It's a simple and effective approach for many cases, but it may not capture more complex color relationships.

Ellipsoid Transformation

The ellipsoid transformation method offers a more advanced approach to color transfer:

  • It models the color distributions of both the input and reference images as 3D ellipsoids in the color space.
  • The method then computes a transformation that maps the input image's color ellipsoid to match the reference image's color ellipsoid.
  • This transformation takes into account not just the mean and standard deviation, but also the covariance between color channels, allowing for a more nuanced color transfer.
  • The result often preserves the relative relationships between colors better than simple histogram matching, potentially leading to more natural-looking results, especially for images with complex color distributions.

Run

nix run github:damianfral/colortransfer -- \
  --input my-photo.jpg \
  --reference nice-colors.jpg \
  --output my-photo-with-nice-colors.jpg \

Options

  • --input: The image to be used as the color source
  • --reference: The image we want to transform
  • --output: The output image
  • --method: The color transfer method to use (default: 2)
    • 1: Histogram matching
    • 2: Ellipsoid transformation

Examples

Input Image Reference Image Histogram Matching Ellipsoid Transformation
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET
Input Reference HM ET