Correcting Lens Aberrations in Digital Photography?
Kavau asks: "I've recently entered the world of digital photography, and bought a pocket-sized digital. While the resolution and the color accuracy are very nice, I was utterly disappointed by the (lack of) quality of the zoom lens: It has a clearly visible barrel distortion, especially in wide angle, so that straight lines appear curved in the picture. This is especially annoying in architectural shots or cityscapes. While grumbling about this shortcoming, I suddenly realized that I am dealing with digital imaging here: In principle it should be no problem to measure the distortion, and then to correct it with a digital mapping. Other lens faults such as vignetting could also be corrected. Now, since I don't want to reinvent the wheel, here is my question to Slashdot: Do you know of any open-source tools that deal with issues such as (1) applying general analytic transformations to a picture, (2) specifically correcting for barrel distortion, or (3) determining the amount of distortion from test pictures? Also, since people probably had this idea before, does anyone have experience with this issue that he/she wants to share, or some resources to point out?"
1. Grip each eyeball firmly between your middle fingers and thumbs.
2. With your forefingers at 9:00 (left) and 3:00 (right), press firmly against each eye. Distortion should now be minimized.
3. Should blindness occur, trim fingernails and repeat with alternate eyeballs.
Best Windows Freeware
...that your best bet would be to take a picture of a piece of graph paper, and then figure out exactly how to stretch it so that the lines are straight again. That said, I'm not entirely certain if there are any programs out there that would do this, but I think it'd be reasonably easy to write an OpenGL program that allows you to apply arbitrary distortions to an image, and then saves those distortions to apply to other images.
I'm just curious why there's an AMD logo for this edition of ask /.
Hosting: as low as $5.95/Mo
Check out PanoTools at http://www.path.unimelb.edu.au/~dersch/
It has a steep learning curve, but seems to be worth the effort. I've only played around with it some myself but I've seen lots of (seemingly) professional photographers on the web that use it.
Exellent tutorials: Big Ben's Panorama Tutorials
Search string: photo barrel distortionm
4'th link down:
www.philohome.com/barrelpers/barrelpers.ht
It mentions to use the "panorama tools" package, which is open source. However, from what I remember, someone sued the author for patent infringement or something, so he no longer has it on his web site www.fh-furtwangen.de/~dersch/, but I found it on www.path.unimelb.edu.au/~dersch/
I know, I know, not freeware. Yet everyone seems to have a copy.
a creative pro article about correcting barrel distortion, and one at Fred Miranda.
The ______ Agenda
This has been a problem in traditional photography for some time. Distortion for wide angle shots always occurs for any wide angle shot -- try a 28mm lense sometime and see for yourself.
Special lenses do exist to correct for this. However, the are very expensive. Generally, only architecture photographers and other professionals have them.
You'll probably want a better lens anyway for doing any sort of quality photography. Oh, and as for fixing it with a filter, good luck. Its not as easy as just applying a transform as the person with the graph paper suggests. The warping depends on distance from the lens.
ph34r teh p0w3r 0f th3 c0w
Not the most computationally efficient method but I wonder if you could do this with povray.
Use the picture as an image map on a sphere or cylinder. Keep adjusting the frame and object size until the lines look straight. Make sure the object is self illuminating and you don't use external light sources...
Hmmmm, seems like it might work....
One should not theorize before one has data. -Sherlock Holmes-
Woodle, Alan S., Scott Elliott: The Vector system for dynamic gait analysis. Clinics in podiatric medicine and surgery. 10(3)485-500, 1993.
There are referances to the math in that paper. Good key words to google might be DLT & photogrametry (sp?)
VIPS is a wonderful image processing library with all sorts of "evil stuff", NIP is a GTK interface to the library which gives you a kind of spreadsheet for images. I'm telling the author about this slashdot item so he can come and pimp it here himself, but in the mean time take a look.
I have personally used it for analysis of medical images, it's nice and versatile, although the built in scripting language is a bit sick (imo).
-Yarn - Rio Karma: Excellent
http://www.humansoftware.com/pages1200/PhotoFixle
Photoshop plugin for exactly this issue. Dont' know how well it works but it may be just waht you're looking for... Mac and Windows.
A fool throws a stone into a well and a thousand sages can not remove it.
It worked for me a couple years ago with cheap USB cameras. I haven't used it recently, so I want to know if there are better choices now. I've got a new robot platform with a lot more CPU power and USB bandwidth, so I'm going to try working on the vision thing again.
Back then, I started with the instructions at Program Your Computer to See. Note how the URLs inside the article are mostly out of date.
You may be familiar with the concept of a picture plane that is used in perspective drawings. The idea is that a transparent sheet is placed between the object and the eye, and rays are mapped onto the surface. That works fine for narrow fields of vision, but it falls apart as the lens gets wider.
Imagine an extreme case: You are standing in a train station. To your left the tracks disappear to a point on the horizon, straight ahead of you the train sits, and to your right the tracks disappear off to another point. If this image is cut up into small enought chunks, you won't notice the abberations of traditional perspective. You have a one point perspective of the train, and a two point perspective on each side. But try to stitch the images into a whole, which is similar to what you are trying to do with a wide angle lens, and all those straight lines are going to have to bend somewhere!
A more accurate picture plane, one that could actually capture a real image without any distortion, would be a sphere, with the eye at the center. Straight lines now map to great circles on the sphere, and whole images, just like the ones your eye sees, can be presented in their entirety.
But then you can't exactly paste them into your photo album. So you are back to the question of, how do you map a sphere onto a plane?
Or maybe you could get some funny looking virtual reality googles.
Not always true. Reputable companies sometimes throw cheap stuff at you, too. The camera in question here is a Pentax Optio S, and Pentax certainly has a good reputation in optics (maybe not as good as Nikon, but certainly good enough). The problem with the Optio S is its "revolutionary sliding lens design", which makes the camera as thin as a deck of cards. However, as in world politics, revolutions often introduce a whole new set of problems...
I have a couple of examples, both involve correcting perspective at the same time:
A single photo, corrected
Two photos stitched, corrected and perspective adjusted
There is a project to build an easy-to-use front-end for panorama tools: Hugin, it has a Mailing-list, anyone welcome.
If you just want to batch process individual photos without having to learn Panorama Tools, try this perl-script, it implements everything required to correct barrel distortion (though you have to calibrate your camera first).