# USAGE
# python example.py --source images/ocean_sunset.jpg --target images/ocean_day.jpg

# import the necessary packages
from color_transfer import color_transfer
import numpy as np
import argparse
import cv2

def show_image(title, image, width = 300):
	# resize the image to have a constant width, just to
	# make displaying the images take up less screen real
	# estate
	r = width / float(image.shape[1])
	dim = (width, int(image.shape[0] * r))
	resized = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)

	# show the resized image
	cv2.imshow(title, resized)

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-s", "--source", required = True,
	help = "Path to the source image")
ap.add_argument("-t", "--target", required = True,
	help = "Path to the target image")
ap.add_argument("-o", "--output", help = "Path to the output image (optional)")
args = vars(ap.parse_args())

# load the images
source = cv2.imread(args["source"])
target = cv2.imread(args["target"])

# transfer the color distribution from the source image
# to the target image
transfer = color_transfer(source, target)

# check to see if the output image should be saved
if args["output"] is not None:
	cv2.imwrite(args["output"], transfer)

# show the images and wait for a key press
show_image("Source", source)
show_image("Target", target)
show_image("Transfer", transfer)
cv2.waitKey(0)
[((22, 5, 22, 30), 'argparse.ArgumentParser', 'argparse.ArgumentParser', ({}, {}), '()', False, 'import argparse\n'), ((31, 9, 31, 35), 'cv2.imread', 'cv2.imread', ({(31, 20, 31, 34): "args['source']"}, {}), "(args['source'])", False, 'import cv2\n'), ((32, 9, 32, 35), 'cv2.imread', 'cv2.imread', ({(32, 20, 32, 34): "args['target']"}, {}), "(args['target'])", False, 'import cv2\n'), ((36, 11, 36, 41), 'color_transfer.color_transfer', 'color_transfer', ({(36, 26, 36, 32): 'source', (36, 34, 36, 40): 'target'}, {}), '(source, target)', False, 'from color_transfer import color_transfer\n'), ((46, 0, 46, 14), 'cv2.waitKey', 'cv2.waitKey', ({(46, 12, 46, 13): '(0)'}, {}), '(0)', False, 'import cv2\n'), ((16, 11, 16, 65), 'cv2.resize', 'cv2.resize', (), '', False, 'import cv2\n'), ((19, 1, 19, 27), 'cv2.imshow', 'cv2.imshow', ({(19, 12, 19, 17): 'title', (19, 19, 19, 26): 'resized'}, {}), '(title, resized)', False, 'import cv2\n'), ((40, 1, 40, 38), 'cv2.imwrite', 'cv2.imwrite', ({(40, 13, 40, 27): "args['output']", (40, 29, 40, 37): 'transfer'}, {}), "(args['output'], transfer)", False, 'import cv2\n')]