示例#1
0
def test_transfer_color3():
    input_img = image_from_path("inputs/trees-greyscale.jpg")
    source_img = image_from_path("inputs/leaves-colored.jpg")

    # Test without using bilateral
    print("==== Testing transfer color 3 without bilateral ====")
    start_time = time()
    color_transferred = transfer_color(input_img,
                                       source_img,
                                       sample_rate=1.0,
                                       filter_colors=False)
    end_time = time()
    outpath = "outputs/trees-leaves-transfer-color-no-bilateral.jpg"
    save_image(color_transferred, outpath)
    print(f"Saved in {outpath}, finished in {end_time - start_time} seconds\n")

    # Test with using bilateral
    print("==== Testing transfer color 3 with bilateral ====")
    start_time = time()
    color_transferred = transfer_color(input_img,
                                       source_img,
                                       sample_rate=1.0,
                                       filter_colors=True)
    end_time = time()
    outpath = "outputs/trees-leaves-transfer-color-with-bilateral.jpg"
    save_image(color_transferred, outpath)
    print(f"Saved in {outpath}, finished in {end_time - start_time} seconds\n")
示例#2
0
def test_propagate_color_transfer5():
    input_img = image_from_path("inputs/mothersmall-greyscale.jpg")
    source_img = image_from_path("inputs/miserables-colored.jpg")

    print("==== Testing transfer color 5 propagating using colorization ====")
    # Create marked image by using color transfer with low sample rate
    start_time = time()
    color_transferred = transfer_color(input_img,
                                       source_img,
                                       sample_rate=0.2,
                                       filter_colors=False)
    intermediate_time = time()
    intermediate_path = "outputs/mother-miserables-transfer-color-sample.jpg"
    save_image(color_transferred, intermediate_path)
    print(
        f"Saved intermediate in {intermediate_path}, took {intermediate_time - start_time} so far"
    )

    # Propagate colors using colorization
    colorized = colorize(input_img, color_transferred, filter_colors=True)
    end_time = time()
    outpath = "outputs/mother-miserables-transfer-color-propagated-colorization.jpg"
    save_image(colorized, outpath)
    print(f"Saved output in {outpath}, finished in {end_time - start_time}\n")