A couple of months back, I created an average face of all members of Iran’s Islamic Consultative Assembly. It was a quick 5-minute project and It has been done thousands of times. There was nothing special about this project, but something very interested happened when I started to show the results to people outside the field of Computer Science, or I should say Engineering. People at first couldn’t comprehend the results and ask silly questions at first. The problem was not the quality of the produced image or even my presentation’s skills (But it kind of was!!) But with the people’s perception of the Averaging operator itself!
I think the problem might be in how people think of pictures! To us, computer science people, images are only numbers and we can absoulty do anything we want to them.
In computer graphics, especially in shader development, mixing different textures to produce the desired effect is a very common task. Here is the simplest technique possible to merge two textures into one:
This is not only limited to Images and we can average anything that can be described with numbers. For example, an animation sequence is just an array of positions of joints, and of course, we can do some math on top of them. By doing a weighted average between two distinct animations, we can do a transition from one to another.
Doing a face blending is not at all hard, here are steps needed to reproduce my results.
Gathering: First of all, you need images, gather lots of images from faces, as much as you can
Cleaning up: We only need faces, not other body parts. It is fairly easy to write an OpenCV code to crop an image, so only the face is visible on the image.
Facial Landmarks: We need to align faces on top of each other before doing the averaging. For this, we first find Facial Landmarks on each of the faces we have. this can be achieved easily with libraries like dlib and Algoface.
As you can see the alignment is not perfect, lips are not aligned on top of each other correctly. This is due to the variation we have in our landmark finding algorithm.
After finding the average face, it is very amusing to do some additional things with it. I thought doing some manipulation using StyleGAN would be a great idea. Here are some of my results:
Here is the age transformation for both the Consultative Assembly and Assembly of Experts.
Assembly of Experts:
All members of the Assembly of Experts are men, what if they were women?