Correcting Lens Aberrations in Digital Photography? 67
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?"
Tutorial (Score:4, Funny)
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.
Re:Tutorial (Score:1)
Seems to me... (Score:5, Informative)
Re:Seems to me... (Score:3, Informative)
Re:Seems to me... (Score:3, Informative)
Sure it does.
The way to do it is use the original as a texture, and then draw a grid of square polygons, each with a corresponding of that texture. Allow the user to distort those squares (while leaving the texture the same) and you can distort the image. To really make this look good, you'll need to use fairly fine-grained squares, but you're not concerned with frame-rate here.
Re:Seems to me... (Score:2)
dude, you're a genius (Score:2)
Re:Seems to me... (Score:1)
I think the poster already has an idea how to solve the problem, he mentions digital mappings, but the point is that he doesn't want to go to the effort of coding if it has been done before.
Re:Seems to me... (Score:4, Insightful)
Huh? Graph paper would do a MUCH better job at finding the lenses flaws, and make it fairly simple to correct them...that picture you have would barely do any good at all...just on the parts where there was detail. Even then, that would be insanely hard to implement in software compared to a grid. It might be better at finding focus or something...but thats not the point. The graph paper would show you exactly how the lense was deformed at practically every point on the lense (depending on density of the lines of course). All you would have to do to fix it would be straighten out the lines. I don't really see how that picture you posted could be used to find lense distortion...it just doesn't have enough detail. What is it specifically for?
Re:Seems to me... (Score:2)
A grid, such as that generated by taking a picture of graph paper, is exactly what you need to correct for barrel distortions and the like.
AMD logo? (Score:3, Interesting)
Re:AMD logo? (Score:1)
Re:AMD logo? (Score:2)
IIRC I posted the story with "Graphics" as the topic. However, "AMD" is the first topic in the list so I strongly suspect an oversight by the editor (not to be blasphemous or anything...)
Re:AMD logo? (Score:1)
PanoTools (Score:5, Informative)
Check out PanoTools at http://www.path.unimelb.edu.au/~dersch/ [unimelb.edu.au]
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 [unimelb.edu.au]
Re:PanoTools (Score:2)
Anyway, he has a page on Correcting Barrel Distortion [unimelb.edu.au].
google says... (Score:5, Informative)
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/
Ugly patent story (Score:2)
Photoshop options (Score:3, Informative)
a creative pro [creativepro.com] article about correcting barrel distortion, and one at Fred Miranda [fredmiranda.com].
Re:Photoshop options (Score:2)
Nothing new here (Score:5, Interesting)
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.
Re:Nothing new here (Score:2)
If some physicist can explain that one to me, I'll eat my shorts. (Note, we're not talking about blurring, we're talking about warping.)
Re:Nothing new here (Score:3, Informative)
That's not quite right, so leave your shorts where they belong.
The warping changes as you change focus or zoom. How much it changes depends on the quality of the lens.
If you zoom in, you may need to recalibrate your dewarping transform.
Cheap cameras that don't autofocus or zoom have an advantage here.
Not Quite...(Plus some experiential data) (Score:1)
Re:Nothing new here (Score:2)
Re:Nothing new here (Score:2)
True. However, my film SLR has no noticeable distortion at 35mm. With my pocket digital, the issue is clearly the inferior lens, and not the fundamental limitations you're mentioning.
You'll probably want a better lens anyway for doing any sort of quality photography.
I'm well aware that it's impossible to get high-quality pictures from an ultra-compact camera. I chose this particular camera, however, because it's easy to carry around
Hmmmm, I wonder (Score:2, Insightful)
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....
Re:Hmmmm, I wonder (Score:1)
Basically build a custom lens in the program and view the image through that lens. The lens would straighten the lines....
Err I think it could..
Re:Hmmmm, I wonder (Score:1)
Re:Hmmmm, I wonder (Score:2)
Even if you were limited to a sphere, you could just subtract it from a box.
DLT (Score:5, Informative)
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?)
Re:DLT (Score:2)
Re:Bottom line... (Score:2)
The advantage of a pocket-sized camera is that it fits in a shirt pocket. Nuff said.
Re:Bottom line... (Score:3, Informative)
Not always true. Reputable companies sometimes throw cheap stuff at you, too. The camera in question here is a Pentax Optio S [dpreview.com], 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" [pentax.com], which makes the camera as thin
Pentax optics (Score:2)
I believe that no other manufacturere can approach Pentax's MC technology w/o having to pay Pentax royalties.
Nikon may be ahead of Pentax in other optical areas, but Pentax is the leader in coatings, or at least used to be.
But I agree, even the reputable companies can often give you cheap crap.
Re:Bottom line... (Score:2)
Take Nikon, for example. All their sub-$1000 digital cameras have crappy f/2.8 zoom lenses. Even Sony offer better glass than that.
OK - buy a bigger shirt ! (Score:2)
Don't forget a pocket torch in case you fall inside it!
You could see how deep it is by timing your fall with the in-built pocket watch!
I'm so funny !
VIPS & NIP (Score:5, Informative)
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).
Re:VIPS & NIP (Score:2)
Re:VIPS & NIP (Score:2)
Re:VIPS & NIP (Score:2, Informative)
It has a rubbersheet tool. You make a target image (a black and white chessboard works well), print the target out, take a picture of it (you'll need to pick a particular zoom setting to calibrate), and feed the original (undistored) image and the (distorted) photo into the transformation estimator.
The estimator uses gradient analysis to iteratively discover a 0/1/2nd order transform from the distorted image back to the original. It won't work so wel
Re:VIPS & NIP (Score:2)
Unfortunately, I can't this rubbersheet plugin anywhere, neither in the rpms from the site, nor the source package I have compiled up. Both nip 7.8.8. I can find the rubbersheet batch stuff, but nothing that looks like a binary plugin. Am I doing something stupid, or is it really not there?
Also, is there a page where all the nifty scripts/plugins that people have made can be found? If there isn't, do you think there should be?
Re:VIPS & NIP (Score:1)
Re:VIPS & NIP (Score:1)
The RPMs should have the rubbersheet stuff inside already (complied into the library).
I've added an extra download for the binary for just the plugin, in case you build from source. Check out the vips-7.8 download page again.
There are some extras in the "extras" bit at the top of the website. nip has only been launched properly for 6 months, so there's no public repository yet.
Re:VIPS & NIP (Score:2)
photoshop plugin (Score:5, Informative)
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.
Try Intel's Open Source Computer Vision Library (Score:4, Informative)
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 [oreillynet.com]. Note how the URLs inside the article are mostly out of date.
Objective reality of 3-d space (Score:5, Informative)
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.
Re:Objective reality of 3-d space (Score:2)
Your statement is certainly true for ultra-wide angle lenses (below 24mm focal length, 35mm equivalent). A moderate wide-angle lens (24-35mm, 35mm equivalent) of good quality should not show any significant distortions, according to this article [ephotozine.com]. I am actually more interested in the range above
Correcting Lens Distortion (Score:1)
This describes a piece of software called FLATFISH that can correct the type of distortion you're seeing.
I'll warn you, it can be a bit tempermental until you get used to working with it, and it's not meant for the faint of heart. But I've personally used it for camera calibration on a robot using a webcam for vision, and I can say that it does work pretty well. It will very likely give you the tech
Camera Calibration Code - Link (Score:1)
Using Panorama Tools to correct lens distortions (Score:2, Informative)
I have a couple of examples, both involve correcting perspective at the same time:
A single photo, corrected [blackfish.org.uk]
Two photos stitched, corrected and perspective adjusted [blackfish.org.uk]
There is a project to build an easy-to-use front-end for panorama tools: Hugin [sourceforge.net], it has a Mailing-list [email-lists.org], anyone welcome.
If you just want to batch process individual photos without having to learn Panorama Tools, try this perl-script [blackfish.org.uk], it implements everything required to correct barrel distortion (though you have to calibrate your camera firs
Pixelzap and other tools.. (Score:2)
Digital Pornography (Score:1)
Dave Dyer wrote a tool specifically for this (Score:2)
What your looking for is Extended Depth Imaging. (Score:1)
does it for you prior to dumping to the storage unit. This technique is used extensively in robotics to