A different perspective

by jegeblad

I have around 70 photes of frames that I want to use for an app I am working on. The pictures were taken using a digital camera. Unfortunately, even though I was careful, many of the frames are taken from an angle other than 90 degrees. The frames I need for the app need to be axis aligned. To solve this problem I could use PhotoShop or Gimp, which have "perspective correction" features. After 5 minutes of playing around with those applications I gave up. Instead I made my own using Cocoa. Here is how.

First, I record four coordinates on the original images which can be placed by the mouse. Then to output the photo I interpolate those coordinate, much like painting a texture-map in reverse.

The concept is quite simple and it took me only about 1 hour to implement including bilinear filtering. Here is an example of the transformation:


With this little tool I was able to fix the perspective of all my frames in less than 20 minutes. Of course I only do linear interpolation (not perspective correct), but it works ok because most of the photos are from an angle of around 90 degrees.