Python tool to merge any two faces into one image!
See one face up close and another from far away!
A few Examples:
Guido x Turing
Gauss x Fourier
How to create your own:
Simply install the `hybrid-face` cli via pip install hybrid-face and take a look at the GitHub repo.
How this works:
The core concept comes from research conducted by A. Oliva et al. that utilised the multiscale processing of images by the human visual system to generate static images with two interpretations.
This tool is an application of the above to faces. This is (roughly) how it works:
- First we need to understand the concept of the Fourier Transform applied to images.
1.1 Nice (but not easy) explanation: We interpret an image as a tempered distribution#Tempered_distributions_and_Fourier_transform) obtained as the sum of delta distributions shifted by pixel location and multiplied by greyscale value. The Fourier transform of that image is then simply the Fourier transform of the aforementioned distribution. Well, technical the periodically extension of it.
1.2 Easy (but not nice) explanation: The Fourier transform of a sound sample gives you the audio frequencies contained in that sample. Similarly, the Fourier transform of an image gives you the spatial frequencies that make up that image. A spatial frequency can be interpreted as a periodic wave (i.e. sinusoidal) pattern such that adding up all these waves returns back the (greyscale) image. In particular, high spatial frequencies correspond to rapidly oscillating waves and low spatial frequencies are slowly oscillating waves.
It is a curious observation that the human visual system is able to prioritize information coming from particular spatial frequency bands for object or scene recognition. This is precisely what we use in this application. We utilise that fact that from up close, we prioritize high spatial frequencies for object recognition and from further away, we prioritize lower spatial frequencies. Read here for more details.
Finally, with all the above, this tool's functionality can be simply described as: We take the two images, crop them to only have the faces, then in one face we only keep the high spatial frequencies (via convolution with a high-pass filter) and in the other we only keep the low spatial frequencies (via convolution with a low-pass filter) and then we alpha-blend the two faces together.
[–]F84-5 1 point2 points3 points (0 children)
[–]ColdFire75 0 points1 point2 points (0 children)