I just downloaded and digested a paper I found on the subject of lens distortion correction, it's really quite a good read (see:Automatic Correction of Lens Distortion by Using Digital Image Processing). After that I followed Apple's reasonably well written tutorials on the subject of creating a Core Image plugin: I have to say that the devil is in the details, because it was really hard to find any documentation on non-executable (GPU-only) plugins, for reasons beyond the scope of my knowledge, these simply don't work inside Motion. They work in Core Image Fun House, and Quartz Compositor, but not inside Motion. This got me frustrated enough to think about reprogramming my graphics card with my fists. So in case your wondering, GPU-only Image Units don't work inside Motion 3. (like you care!) I did get it all working in the end, but had to program some Core Image glue code to make all the little micro-chips happy!
Well without further ado, the results:
There is some great software out there, for doing lens distortion correction on still images, if that's what you need I would try Lens-Fix CI (I assume it also uses Core Image). Lens-Fix CI comes with a database full of correction parameters for different optics at different focal lengths. My plugin is more designed with movies in mind, and doesn't come with a sweet user interface.
To correct your images, you'll need to know the calibration polynomial coefficients of your lens — If you have no idea what this means, then twiddle the sliders back and forth until the picture looks right. If you want a mathematically accurate correction, you will need to calibrate your lenses with a grid or something, and probably some software. Google it. Seriously.
You can download the Image Unit (Universal Binary) and Source here: UMLensDistortionCorrection.zip
To install simply copy “UMLensDistortionCorrection.plugin” to “/Library/Graphics/Image Units/” and away you go, it should appear in the category “Distortion Effects”.