<s> import numpy as np <EOL> import cv2 <EOL> def color_transfer ( source , target ) : <EOL> """<STR_LIT>""" <EOL> source = cv2 . cvtColor ( source , cv2 . COLOR_BGR2LAB ) . astype ( "<STR_LIT>" ) <EOL> target = cv2 . cvtColor ( target , cv2 . COLOR_BGR2LAB ) . astype ( "<STR_LIT>" ) <EOL> ( lMeanSrc , lStdSrc , aMeanSrc , aStdSrc , bMeanSrc , bStdSrc ) = image_stats ( source ) <EOL> ( lMeanTar , lStdTar , aMeanTar , aStdTar , bMeanTar , bStdTar ) = image_stats ( target ) <EOL> ( l , a , b ) = cv2 . split ( target ) <EOL> l -= lMeanTar <EOL> a -= aMeanTar <EOL> b -= bMeanTar <EOL> l = ( lStdTar / lStdSrc ) * l <EOL> a = ( aStdTar / aStdSrc ) * a <EOL> b = ( bStdTar / bStdSrc ) * b <EOL> l += lMeanSrc <EOL> a += aMeanSrc <EOL> b += bMeanSrc <EOL> l = np . clip ( l , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> a = np . clip ( a , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> b = np . clip ( b , <NUM_LIT:0> , <NUM_LIT:255> ) <EOL> transfer = cv2 . merge ( [ l , a , b ] ) <EOL> transfer = cv2 . cvtColor ( transfer . astype ( "<STR_LIT>" ) , cv2 . COLOR_LAB2BGR ) <EOL> return transfer <EOL> def image_stats ( image ) : <EOL> """<STR_LIT>""" <EOL> ( l , a , b ) = cv2 . split ( image ) <EOL> ( lMean , lStd ) = ( l . mean ( ) , l . std ( ) ) <EOL> ( aMean , aStd ) = ( a . mean ( ) , a . std ( ) ) <EOL> ( bMean , bStd ) = ( b . mean ( ) , b . std ( ) ) <EOL> return ( lMean , lStd , aMean , aStd , bMean , bStd ) </s>
