cat = np.array(cat, dtype="f") earth = np.array(earth, dtype="f") # make sure we can combine these images directly assert cat.shape == earth.shape # take fourier transforms ft_e = fft2(cat) ft_m = fft2(earth) # shift so hi-freq stuff is in the center ft_e = fftshift(ft_e) ft_m = fftshift(ft_m) # use gaussian filter as a low pass filter flo, _ = gaussian_filter(cat.shape, sigma=15) # create a high pass filter fhi = 1 - flo # lowpass on earth, high-pass on cat lo_e = ifft2(ifftshift(flo * ft_e)) hi_m = ifft2(ifftshift(fhi * ft_m)) # high pass on earth, low-pass on cat lo_m = ifft2(ifftshift(flo * ft_m)) hi_e = ifft2(ifftshift(fhi * ft_e)) hybrid = lo_e + hi_m hybrid_rev = lo_m + hi_e
einstein = np.array(einstein, dtype='f') marilyn = np.array(marilyn, dtype='f') # make sure we can combine these images directly assert cat.shape == earth.shape # take fourier transforms ft_e = fft2(cat) ft_m = fft2(earth) # shift so hi-freq stuff is in the center ft_e = fftshift(ft_e) ft_m = fftshift(ft_m) # use gaussian filter as a low pass filter flo, _ = gaussian_filter(einstein.shape, sigma=10) # create a high pass filter fhi = 1 - flo # lowpass on earth, high-pass on cat lo_e = ifft2(ifftshift(flo * ft_e)) hi_m = ifft2(ifftshift(fhi * ft_m)) # high pass on earth, low-pass on cat lo_m = ifft2(ifftshift(flo * ft_m)) hi_e = ifft2(ifftshift(fhi * ft_e)) # combine the lowpassed and highpassed images to produce the hybrid hybrid = lo_e + hi_m hybrid_rev = lo_m + hi_e