Transform Power Go!


Inspired by an online video, I decided to take a picture of myself every day. There’s a camera built into the lid of my MacBook Pro, so I wrote some programs to make the job easier, and now every day that I remember I snap an image; I’ve remembered about 250 days in the last 300. I decided to make a video of all the images in sequence, so I ran them through a Photoshop action to normalize the colors and contrast, made a movie from them, and watched it. Even though I tried to hold my head the same way in every picture, my face still jumped around way too much for continuity.
So I figured, hey, I’m a math nerd! With a little linear algebra I can create an affine transformation for each image so that both eyes always appear in the same place. I was going to write a face-recognition package to find the eyes, but my friend Steve observed it would be easier to do it manually. So I wrote a program in Processing that put up each image and captured three mouse clicks, one in the center of each eyeball and one at the base of my nose. I also wrote a quick 2D matrix and vector manipulation library. For each picture, I used the mouse clicks to calculate the appropriate transformation matrix, inverted it, and used it to redraw the image so these three points would always land in the same spots. The results were awful! It turns out the MacBook Pro uses a pretty wide-angle lens, which is great, but it meant that when my head was off-axis or tilted, the affine map could shear or squash my head almost comically, looking like an overcooked hotdog flopping around. I thought I was stuck.
But then I figured, hey, I’m a math nerd! I wrote some code to compute a special-purpose transform using only a rigid transform and uniform scaling. I then used just the eyeball positions to compute the transform for each image. Success! Above you can see the averages of the first 50 images and the last 50 (I grew a beard). The resulting time-lapse-ish video is kind of fun to watch (click here), though YouTube’s compression is pretty extreme. Computer graphics has really come of age. Now we can have an idea for a project like this in the late afternoon and then write the code, apply it, pick a whole new approach, write the new code, apply it, and be done before The Daily Show at 11pm.
Update: My friend EricH suggested making a video of the averaged images. Good idea! So here’s a new video, where each frame is the average of that daily image and the 49 that follow it. Click here to see my beard grow!
