Scale bars

I recently wrote a Python script that reads EXIF data for camera, lens, and focus position and adds a scale bar to the photos: https://gist.github.com/welliam/f1df4594670b4b2165d0661a78b33a24

Here's an example of the result: https://www.inaturalist.org/photos/309888307

How it works

It's written with prime lenses in mind, though other lenses could be adapted to work for it. I didn't attempt a general formula, with my limited understanding of optics. Additionally, most people online say focus distance is not reported accurately from EXIF data at all, so a general formula wouldn't probably work. Even with perfect EXIF data, I'm not sure a general solution is actually possible; real life lenses are complicated.

Instead I manually recorded pixels/mm at various focus distances with the camera, and interpolate between them linearly. (Therefore, it doesn't matter if the EXIF focus distance is actually accurate, just that it's internally consistent.) It's a crude solution but it does seem to work; with test photos of rulers at random focus distances it seems to be reasonably accurate.

Right now it only works with known combinations of lenses and cameras (really just the one I use most often now, my OM-5 with the M.Zuiko 60mm macro lens). It feels like a safe assumption to just go off sensor size for the camera, rather than rely on an individual model, but without more cameras and lenses to try out I'm not confident about any assumptions.

Making this useful for other people

I don't think a Python script is the best way to do this part. I want a sort of webpage that people can quickly add scale bars onto. The automatic derivation from EXIF data part will be hard to get support for without people contributing their own measurements (cameras are pretty expensive!); most likely I'll add an input field for manually specifying pixels/mm at various focus distances, and give people instructions on how to figure that out on their own.

TODOs

  • Rotating the scale bar
  • Changing scale bar style (color)
  • Changing the unit (cm, mm, etc)
  • Non-macro or even telephoto distances (issues with focus distance inaccuracy might make this unreasonable: TBD)
  • Microscopes: supporting photos taken through a dissecting microscope eyepiece would probably also be useful; these focus by physically moving the microscope up and down, so they'd work a little different (you'd specify the zoom factor). The camera sensor size and resolution would be the only other factors in this situation. Light microscopes would work similarly. Neither are going to be as luxurious as the camera solution, as no information about the microscope would be in the EXIFs
  • Resizing: A limitation that might not be reasonable to work around is that you can't resize images before using this tool, as pixels/mm is the magic factor that'd be ruined by resizing (so cropping is ok). I'm not sure resizing is recorded in EXIF data; if it were, it'd be easy to adapt. If not then we're hosed!
Posted on August 17, 2023 12:24 AM by wweellll wweellll

Observations

Photos / Sounds

What

Tree Pelt Lichen (Peltigera collina)

Observer

wweellll

Date

August 12, 2023 09:30 AM PDT

Comments

No comments yet.

Add a Comment

Sign In or Sign Up to add comments

Gracias al apoyo de:

¿Quiere apoyarnos? Pregúntenos cómo escribiendo a snib.guatemala@gmail.com