jrosebr1 / color_transfer

Performs color transfer between two images. Loosely based on the "Color Transfer between Images" paper by Reinhard et al., 2001.
http://www.pyimagesearch.com/2014/06/30/super-fast-color-transfer-images/
MIT License
484 stars 149 forks source link

automatic choosing of best `clip` & `preserve_paper` args? #6

Open AdamSpannbauer opened 6 years ago

AdamSpannbauer commented 6 years ago

Any interest in including a utility function for choosing the 'truest to source' color transfer?

I've implemented an (unoptimized) auto_color_transfer function that attempts to choose the best combination of clip & preserve_paper by comparing each potential result to the source image in the HSV color space using chi2 distance. ~The mean absolute error is calculated between the channel means of the source & candidate images.~ Since the 'truest' color transfer isn't always the most aesthetically pleasing the function also returns a comparison matrix image (see below).

In this case, the bottom left image is chosen as the truest transfer by the current method.

image

EDIT: updated distance used to determine 'truest' transfer

jrosebr1 commented 6 years ago

Thanks @AdamSpannbauer, this is a really cool tool and utility function but I'm hesitant to include it in the actual library. The library is meant to be compact and a "self explanatory" implementation of color transfer (along with the accompanying blog post, of course).

I'd really like to keep it on the compact side and let the user decide which method they would like to preserve via the clip and preserve_paper booleans.

I will keep this issue open though for any other users of the library would like to chime in.

AdamSpannbauer commented 6 years ago

Makes total sense. I'll keep the function code alive in the fork where I was playing around with the idea