I'm interested in writing some software to eventually replace the current photogrammetry system I use at work. Distortion correction (among other calibrations) is an important factor in getting high accuracy measurements across the whole sample volume. With a lens at a fixed focal length and fixed focus, do the distortion correction factors change slightly as you move the subject in and out of the focal plane?
-
2\$\begingroup\$ It's hard to tell what you are asking. Distortion and defocus are different parameters, and you can have a variation in each across the image plane at any distance (best focus or not). It's likely that astigmatism and coma will do more to degrade your measurements (as you go out of focus) than will a putative change in distortion. \$\endgroup\$– Carl WitthoftCommented Mar 8, 2017 at 13:06
-
\$\begingroup\$ @CarlWitthoft take a look at the answer I posted for (hopefully) a little better idea of where I'm coming from. \$\endgroup\$– AaronCommented Mar 8, 2017 at 22:59
4 Answers
In short, yes the focus distance has an impact on calibration parameters. For further information on that, refer to this paper by D. C. Brown on Close-Range Calibration. Generally, it is advised to have the camera focused at infinity when capturing photographs for calibration purposes. To do that, you simply have to calculate the hyperfocal distance for your camera. There is an Android app that has many preloaded camera setups called Hyperfocal that does just that.
-
\$\begingroup\$ I haven't gotten all the way through it yet, but this paper looks to be just about exactly what I was looking for. Thanks! \$\endgroup\$– AaronCommented Jun 22, 2017 at 19:09
-
\$\begingroup\$ I have recently created a software package that performs calibration using the chessboard method and also with a calibration field. It also has a feature for distortion correction. If you are interested I could send it to you. \$\endgroup\$– NikosCommented Jun 22, 2017 at 19:17
-
\$\begingroup\$ That would be awesome! This project seems to have fallen a bit to the wayside for me as other projects come in that are higher priority, but I'd love to take a look to stash it away in the back of my brain. Do you have a github? \$\endgroup\$– AaronCommented Jun 22, 2017 at 19:35
-
1\$\begingroup\$ Yes, but I haven't uploaded it yet. I have a website to showcase it though. Visit www.imagecor.eu and send me a mail through the contact form. \$\endgroup\$– NikosCommented Jun 22, 2017 at 20:10
The distortion will change as a function of object distance unless the lens is image space telecentric and has no distortion to begin with. This is because for a nonzero chief ray angle, the image will enlarge as the object draws closer -- this is referred to as "focus breathing." This in combination with the variation in aberrations that affect distortion (notably, coma) with object distance will lead to changes in the measured or perceived distortion as a function of distance.
You may also encounter a failure of the mapping function of the lens you use if the object is sufficiently near. E.g. a rectilinear ultra wide angle lens looks "ok" at a great distance, but very distorted at a near distance. The lens is not distorted, the center of the FoV is simply much closer to the lens. This is a failure of the mapping function.
I think I may have found a solution that implies there is indeed no relation of distortion and focus. This relies on the fact that a lens system can be accurately modeled by Zernike polynomials (I am not sure what the assumptions of this model are with respect to lens/sensor systems, and how they differ from reality).
The first eight terms of the polynomial can be used to describe common lens imperfections:
- Tilt: α1 × ρ cos(θ); α2 × ρ sin(θ)
- Defocus: α3 × (2ρ2 - 1)
- Astigmatism: α4 × ρ2 cos(2θ); α5 × ρ2 sin(2θ)
- Coma: α6 × (3ρ2 - 2) ρ cos(θ); α7 × (3ρ2 - 2) ρ sin(θ)
- Spherical Aberration: α8 × (6ρ4 - 6ρ2 + 1)
As you can see, none of these terms (and indeed the infinite form summation) include a term for displacement from the aperture (only polar position on the image plane: ρ, θ).
I would appreciate any comments anyone has on the validity of this model in realistic applications.
-
4\$\begingroup\$ It appears everything in article you linked to refers to a single lens (i.e., single piece of glass). The geometry of a single piece of glass cannot change, so the polynomial coefficients are fixed. For a real-world camera lens that moves one or more glass elements (or groups of elements) to focus, the relationships of the modeled parameters of each glass element changes with respect to the other elements. Therefore, I strongly infer that the coefficients are really coefficient functions of focus position of the lens (and for zoom lenses, a function of zoom as well). \$\endgroup\$– scottbb ♦Commented Mar 9, 2017 at 1:28
-
2\$\begingroup\$ Also, as a suggestion, there's probably a better chance for good answers/info from the optics-minded contributors over at Physics.SE. I know there are a couple optics wonks here, but there are probably more at PSE, and such topics are more, well, topical, there. =) \$\endgroup\$– scottbb ♦Commented Mar 9, 2017 at 1:38
-
2\$\begingroup\$ @scottbb what you say about multi-element lenses is true in general, but the OP is asking about a fixed-focus system. It has multiple elements but since they are not moveable, the single-element formulas hold (albeit not other ones such as chromatic distortions) BTW I am an "optics wonk" :-) \$\endgroup\$ Commented Mar 9, 2017 at 12:47
-
1\$\begingroup\$ @CarlWitthoft I knew you were an optics wonk. Didn't mean to slight you... =) \$\endgroup\$– scottbb ♦Commented Mar 9, 2017 at 18:32
-
\$\begingroup\$ @CarlWitthoft &scottbb thanks for the comments, I am accustomed to having to re-calibrate every time the lenses are re-focused (they lock in place with a set screw). As for chromatic aberration, I would tend towards using a monochromatic filter instead of trying to correct in software. \$\endgroup\$– AaronCommented Mar 9, 2017 at 20:03
Moving a subject in or out of the focal plane only defocuses, does not distort.
The distortion I believe you are referring to is relative size to distance based on the fixed focal length of the lens.
While there may be no relationship between distortion and being out of focus in respect to one's position to the focal plane, do you not need to know where, if the subject you are measuring, is in front of or behind the focal plane?
If you are trying to come up with a formula to be able to tell how tall a person is based on items in the image and the focal length of your lens, the wrong lens will give you compression as another factor to deal with.
And your formulas are not just relegated to lens imperfections.
Tilt is as much based on how level the photographer holds his lens to the subject. How can you tell the difference?
Defocus is either you have the wrong focal point, or the subject is not in the focal plane. That the photographer has as much to do with as the lens.
Your question is just a bit too ambiguous to give you an answer. I just disproved several of your formulas as they must include the photographer factor.
-
\$\begingroup\$ I appreciate your response, but I think you missed the point of what I was asking. The equations are not "wrong" but they do not account for things like wavelength and diffraction. The photographer - subject relation is not really important, as it is simply modeled as wave front error (which could be converted into a coordinate system if a particular wavelength was chosen). Ultimately, I'm likely going to implement a statistical calibration approach instead of an analytical one, but the validity of this model would determine how many terms I need for the statistical model as well. \$\endgroup\$– AaronCommented Mar 9, 2017 at 20:33
-
\$\begingroup\$ Just for a reference of why I'm doing all this, it's not unheard of in the optical measurement world to achieve a positional accuracy of greater than 1/50th of a pixel. lenses can be made nearly perfectly (ground to an accuracy of tens to hundreds of nm) but those are prohibitively expensive, and only used in special physics experiments. With proper calibration, off the shelf lenses can be used to also get very high accuracy (I currently use a proprietary software system that gets 1/20th pixel accuracy with ~$500 lenses) \$\endgroup\$– AaronCommented Mar 9, 2017 at 20:45