BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Update: It turns out that there is something weird with the image I chose as an example (picked from an online image search for its size focus and apparent normality to the camera lens), in as much as, the thread angle (the inclusive angle between the faces of adjacent turns of the threads), is as near as I can measure 90°. That's weird because none of the defined standard threads use a 90° thread angle. Metric and Unified are 60°; BSW are 55° & BA are 47.5°. So don't base too much on that image; I'll swap the link for one I know is good once I find it.

Update2: Image now updated with what I am pretty confident are standard M8x1.0 threaded nuts and bolts.

Update 3: This is an image I've taken myself as there is some speculation the one above may be GC.

If you look at this image, the extreme close-up nature of the photo, the close proximity of the lens to the subject and parallax mean that you can see the underside of the heads of the bolts, but the end of the bolts is not visible.

My question is: Is there a way to determine the central axis of the lens in this photo?

Basically what I would like to do is, assuming (for now) that the plane of the photograph is normal to the lens that took it, draw a red cross on the image at the point the central axis of the lens intersects that plane.

Firstly, is there enough information in the photograph to make that determination?

And if so, can a program then be written to automate that process. (But I'm not asking anyone to attempt the latter, just looking for clues how to approach the problem.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on [OT] Mathematical photographers that program (Perl)? (Updated.)

Replies are listed 'Best First'.
Re: [OT] Mathematical photographers that program (Perl)?
by Corion (Patriarch) on Mar 25, 2017 at 09:00 UTC

    I think if you can get some more assumptions, there might be a way to infer the distortion by the perspective, and hence the lens structure.

    If the below assumptions hold, then an edge detection filter (like a Sobel operator) will give you lots of what should be straight, parallel lines in the Real World but what are imaged as slightly curved lines in the image. That curvature then will likely come from the lens and the midpoint is the central axis.

    • All objects must be of roughly the same height so that the perspective distortion is mostly due to the lens and not due to the distance from the lens.
    • There are parallel lines in the edges of the objects (like the gap between the nuts)
    • You can mark or detect the areas where perpendicular edges become visible (like the right borders of the nuts)

    I'm not sure how much of these rules is easy/enforceable. If this is for images yet to be taken, maybe you can add a grid to the background behind the subjects. If this is for images already taken, maybe you can find the lens characteristics somewhere. For example panorama stitchers solve a similar problem, deconvoluting images back into rectangular shape.

Re: [OT] Mathematical photographers that program (Perl)? (Updated.)
by Your Mother (Archbishop) on Mar 25, 2017 at 15:19 UTC

    FWIW, the image looks CG to me. I am not asserting it is, just offering that as a possibility if it might matter.

    Edge detection of straight lines (edges of bolt heads) could give you the horizon line at least (assumptions being they and the plane they rest on are regular/level).

      FWIW, the image looks CG to me.

      Even with all the nicks and scratches?

      My thoughts are that they've probably been shot-peened or sand tumbled.

      I've added an image I've just taken myself to the root node.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice.

        Yes; I agree about the tumbling but artificial flaws are a good trick to fool on expectations. It’s the quality of the light on the metal that looks off to me. I’m not at all sure, though. It might be just a filter/tart-up edit on it. We’re only another few years away from never being able to know again if still images, and then video and audio, are authentic. o_O

        There's a point midway along the bolt where the threads look deepest and straightest. However, that's not "the central axis of the lens," it's the point where the axis of the bolt is perpendicular to a line drawn to the focal point of the lens. Try this: take a picture of two similar bolts, but put a few sheets of paper under the corner of one, so it leans toward (or away from) the camera a bit. You'll see that the "deepest and straightest" point is displaced upward (or downward).