def hybrid_img_generation(img_one_path, img_two_path):
    # Setup
    # Read images and convert to floating point format
    image1 = load_image(img_one_path)
    image2 = load_image(img_two_path)

    image1, image2 = equalize_image_sizes(image1, image2)

    # display the dog and cat images
    plt.figure(figsize=(3, 3))
    plt.imshow((image1 * 255).astype(np.uint8))
    plt.figure(figsize=(3, 3))
    plt.imshow((image2 * 255).astype(np.uint8))

    # For your write up, there are several additional test cases in 'data'.
    # Feel free to make your own, too (you'll need to align the images in a
    # photo editor such as Photoshop).
    # The hybrid images will differ depending on which image you
    # assign as image1 (which will provide the low frequencies) and which image
    # you asign as image2 (which will provide the high frequencies)

    ## Hybrid Image Construction ##
    # cutoff_frequency is the standard deviation, in pixels, of the Gaussian#
    # blur that will remove high frequencies. You may tune this per image pair
    # to achieve better results.
    cutoff_frequency = 7
    low_frequencies, high_frequencies, hybrid_image = gen_hybrid_image(
        image1, image2, cutoff_frequency)

    ## Visualize and save outputs ##
    plt.figure()
    plt.imshow((low_frequencies * 255).astype(np.uint8))
    plt.figure()
    plt.imshow(((high_frequencies + 0.5) * 255).astype(np.uint8))
    vis = vis_hybrid_image(hybrid_image)
    plt.figure(figsize=(20, 20))
    plt.imshow(vis)

    save_image('../results/low_frequencies.jpg', low_frequencies)
    outHigh = np.clip(high_frequencies + 0.5, 0.0, 1.0)
    save_image('../results/high_frequencies.jpg', outHigh)
    save_image('../results/hybrid_image.jpg', hybrid_image)
    save_image('../results/hybrid_image_scales.jpg', vis)
Пример #2
0
plt.imshow((image2 * 255).astype(np.uint8))

# For your write up, there are several additional test cases in 'data'.
# Feel free to make your own, too (you'll need to align the images in a
# photo editor such as Photoshop).
# The hybrid images will differ depending on which image you
# assign as image1 (which will provide the low frequencies) and which image
# you asign as image2 (which will provide the high frequencies)

## Hybrid Image Construction ##
# cutoff_frequency is the standard deviation, in pixels, of the Gaussian#
# blur that will remove high frequencies. You may tune this per image pair
# to achieve better results.
cutoff_frequency = 7
low_frequencies, high_frequencies, hybrid_image = gen_hybrid_image(
    image1, image2, cutoff_frequency)

## Visualize and save outputs ##
plt.figure()
plt.imshow((low_frequencies * 255).astype(np.uint8))
plt.figure()
plt.imshow(((high_frequencies + 0.5) * 255).astype(np.uint8))
vis = vis_hybrid_image(hybrid_image)
plt.figure(figsize=(20, 20))
plt.imshow(vis)

save_image('../results/low_frequencies.jpg', low_frequencies)
save_image('../results/high_frequencies.jpg', high_frequencies + 0.5)
save_image('../results/hybrid_image.jpg', hybrid_image)
save_image('../results/hybrid_image_scales.jpg', vis)
## Hybrid Image Construction ##
# cutoff_frequency is the standard deviation, in pixels, of the Gaussian#
# blur that will remove high frequencies. You may tune this per image pair
# to achieve better results.
cutoff_frequency = 2
low_frequencies, high_frequencies, hybrid_image = gen_hybrid_image_fft(
    image1, image2, cutoff_frequency)
# bouns

## Visualize and save outputs ##
plt.figure()
plt.imshow((low_frequencies * 255).astype(np.uint8))
plt.figure()
plt.imshow(((high_frequencies + 0.5) * 255).astype(np.uint8))
vis = vis_hybrid_image(hybrid_image)
plt.figure(figsize=(20, 20))
plt.imshow(vis)

save_image('../results/low_frequencies.jpg', low_frequencies - .1)
save_image('../results/high_frequencies.jpg', high_frequencies)
save_image('../results/hybrid_image.jpg', hybrid_image - .3)
save_image('../results/hybrid_image_scales.jpg', vis - .3)

#bouns
low_frequencies_f, high_frequencies_f, hybrid_image_f = gen_hybrid_image(
    image1, image2, cutoff_frequency)

plt.figure()
plt.imshow((low_frequencies_f * 255).astype(np.uint8))
plt.figure()