|I’d Call It That||3.0||0.00||0|
|Could Be||1.0||5.70||1||(Alan Rockefeller)|
sum(score * weight) /
(total weight + 1)
|I’d Call It That||3.0||0.00||0|
sum(score * weight) /
(total weight + 1)
A. For a photo with adequate exiftool data
A1. Look up scale bar length in pixels in the calibration table for that camera + lensA2. There is an example of such a calibration table lower down in this chain of messages
B. For two photos that share two points, P and Q, and one of the photos has a ruler in it
B1. Measure the length in pixels of a 1 cm segment of the ruler, rulerPixelsPerCM
This is the length in pixels of a 1 cm scale bar for that photo
B2. Measure the length in pixels between P and Q in the ruler photo, rulerPQ
Measure the length in pixels between P and Q in the new photo, newPQ
The length in pixels of a 1 cm scale bar for the new photo is
(newPQ / rulerPQ) * rulerPixelsPerCM
C. Use a graphics program or Jason’s gimp plug-in to draw a scale bar of the proper length
I wrote a Gimp plug-in, and tested it extensively on the photos from my two-week hike on the northern end of the PCT last month in which I have already added scale-bars by hand — it works remarkably well! I’m so stoked. This will not only save me loads of time, but it is likely more accurate than what I was doing before.
It currently only supports my Casio EX-Z1080. You/we will need to do the calibration for other cameras. In particular, the way I’ve written it, you will need to fit a 4th-order polynomial relating inverse scale (cm per pixel) to subject distance (as reported by exiftool). But given these three coefficients and intercept, it should in theory work for any camera.
If you want, just send me, say, 10 to 20 photos of a ruler at distances varying from as close as you can to up to 5m, taken at typical aperture, no zoom. (Use of zoom adds another variable we haven’t considered yet.) I can calculate the calibration and add support for your camera to the script.
Just place my python script in /home/user/.gimp-2.6/plug-ins. I’ve reassigned ctrl-S to run it for me, otherwise look for it at the bottom of the Edit menu. It places a scale-bar of the desired length in any of the four corners of the image. If you press ctrl-dot a few times afterwards, it will darken the background a bit behind the ruler, as well.
I’m posting the script here until I can find a better home for it:
Please let me know if anyone ends up trying it out. Thanks!
to user-friendly scale bars using a well-known shareware program called GraphicConverter on a Mac. The operations are so basic that they could probably be done by any number of graphics programs.
1. Open the full-sized jpg image in GraphicConverter (3888 pixels wide for a certain camera).
2. Use Show Information to get the exiftool data on Focal Distance for that photo (say, 90cm for a certain example)
3. Find appropriate scale bar length for that distance from your calibration table (239 pixels, in this case)
4. Select Position to display the cursor’s position, Toolbox to get the tools panel, Line for the line tool, hold down the Shift key to draw a straight horizontal line, and draw a horizontal line 239 pixels long (watch the little Position box to know how long your line is as you draw it).
5. Select the Text tool and write “1cm” just above the scale bar. Use the Pointer tool to fine adjust the position of that text.
6. Save the image.
All this takes less than a minute after a bit of practice. Jason’s idea of automating some of this would be wonderful … just drop a generic white bar on an image and stretch it to the right length.
I’m fairly confident that a handy plug-in could be written for both Photoshop and Gimp which would read the appropriate info from the EXIF header and create a scale-bar as a transparent layer on top of the image. You could then drag this layer around to a convenient spot, optionally reversing the color. Could even add a weak shadow behind it to help it stand out (I already have a macro that does that for me once I’ve loaded the appropriate scale-bar layer). Anyone good with writing PS or Gimp plug-ins?? I’m still very much a rank beginner.
I could also imagine a handy little Windows (or Mac?) program that, using ImageMagick and exiftool, could slap a scale-bar in some fixed part of the image, say, by dragging and dropping images on an icon? I’m definitely not a Windows guy, though, so I don’t know how such interfaces work.
to say that I’ve gotten a fair bit more than I bargained for in my initial proposal to illicit more information on this technique. All of it has been fascinating (if a bit over my head, namely the physics element). I’d love to see some simplified system come of this conversation that allows the lay photographer to make use of such a valuable tool. photographs can convey a great deal, to be certain, but scale often goes unexpressed without something actually in the frame to serve as a point of reference. I’d be overjoyed to be able to make use of an easy, approachable, user-friendly system for expressing scale easily in every photo. thanks to everyone for your contributions on this observation and the topic at large.
1. an efficient procedure for calibrating a camera + fixed focal length lens,
2. exif data right on the photo reporting distance from sensor to target,
3. a simple formula for the length of scale bars for close-ups,
4. and a fairly high degree of confidence in the length of those scale bars over the most relevant distances for close-ups (say < 1.2 m or so).
Now I’m working on the final step:
5. use gimp to draw the scale bar
It’s so obvious when you look at the plot, isn’t it? So it does follow a relation of the form we expect:
M ~ 1 / (f – So)
1/M ~ f – So
It’s just that f isn’t even close to what it should be. It should be the focal length, which for my camera should be 7.9 mm; instead I find it is -0.0072 mm. Also, I need to cut off the points for So > 1m, because something screwy starts to happen out there. (But that also makes sense, because field of view becomes infinite somewhere around 5-10 m even at largest aperture. Finally, note that according to the formula, M should be negative, which just means that the image should be inverted. Note that this is the formula for a “simple, thin lens”; clearly my lens is emphatically not “simple”.
(Note that R-squared for the fit — after removing the points with So > 1 m — is 0.995.)
Totally empirical at this point. I don’t understand the optics of it at all. A Hubble Space Telescope Lichen Camera could watch my little ruler retreat for ages, and the image of it would still take up a few pixels, so the function has to be asymptotic to 0 as x → infinity. Good candidates are 1/x and e^(-x). Also, light rays from both sides of the lichen cross each other inside the camera somewhere in front of the sensor, so we might expect a formula involving x-x0, rather than just x.
On the other hand, once a camera + fixed focal-length lens is calibrated like this (which takes perhaps 20 minutes for shooting the photos and making a table of numbers) the exif distance seems to be a fairly reliable guide for subsequent photos (for short distances) for indexing into the distance table to produce a reasonable scale bar length. Cool!
Very nicely documented! I see that your data is also non-linear. More like M ~ So ** -1.5 in your case.
WTF? What am I missing? I’m totally stumped. This makes no sense to me… (Does it need to, though??)
Here’s my data:
(Dist = exiftool’s “Object Distance” in meters; scale is distance between two fixed points in pixels, in this case the width of a business card or ~9.35 mm.)
Empirically M = f / (So – f) doesn’t work, either. I get something closer to M ~ So ** -0.85. I have no idea what my camera’s “object distance” means. But it seems to be consistent, so maybe it is usable.
Have I officially beaten this subject to death yet??
Yikes, I’m still trying to understand how all this stuff works. But I think I’ve found the operative equation… and I understand much better some inherent problems with calibrating your scale bar solely on this one number (object/subject distance).
Magnification is not quite (inversely) linear with respect to this reported distance. I think it is M = f / (So – f) …that is, subtract the focal length first, then it is supposed to be inverse linear. I need to test it on mine again.
Whatever the equation, though, I think if you empirically plot the scale for a reasonable set of subject distances, you should nevertheless end up with a usable approximation.
As for “lower” and “upper focus distance”, this might refer to the depth of field — i.e. the nearest and farthest distance in which things are sharply in focus. That would be cool, because it would allow you to explicitly measure the uncertainty of your scale bar. (Mine definitely does not provide that EXIF information!)
But another thing to keep in mind is depth of field. At infinity the whole concept of a scale bar becomes virtually meaningless, since everything from the camera’s so-called hyperfocus distance to infinity is in focus. That is, there is no narrow focal plane anymore, it is infinitely thick. With my Casio Exilim, if I focus at 1 m with f/2.8 (as large an aperature as I can get, thus narrowest focal plane) I still get a depth of field of 0.6 m (see this supercool on-line DOF calculator.) In particular, things up to 20% closer than the subject are in focus, making the “uncertainty” of the scale bar at least 20%… in the best case.
So my take-home lesson regarding this is that I’m probably not going to be fooling with scale bars at anything farther than a few dozen cm any more. I don’t know, maybe it’s still better than nothing, but it seems to have more potential for confusion than explication!
For a photo taken by a Canon EOS 40D, ExifTool shows “Focus Distance Upper” and “Focus Distance Lower,” so we might have this sort of data for a number of cameras. That suggests a variation on your experiment, Jason. Take 10 photos of a meter rule at 10 known distances (say, out to 1.5m) and make a table of known distances, exif distances, and (using the image of the ruler on the photos) mm/pixel.
I just discovered that my camera now also records something called “Object Distance”, but the mathematical relationship between this number and scale is not linear as I would expect (is my physics rusty??). Still, it’s not hard to estimate a 3rd or 4th-order polynomial to the data (I think Excel or Open Office Calc can do this?). I took 10 photos from 0.078 to 1.235 m away and measured the distance in pixels between two dots visible in all the photos. I would do it again with even more points to improve the error — I was getting 5% error at the 1.2 m end even with a 3rd order approximation. Hopefully your D60 works better!
I just looked at a few of your photos, and yes, your D60 does include the information you need. “exiftool” calls it “Subject Distance” (and it even looks accurate :). Couldn’t ask for better!
Most cameras these days let you know somehow (flashing lights and/or beeps) when you are trying to focus too close. I cranked the volume all the way up on mine, then start way too close and back away slowly. Each time I half-press the shutter release it flashes silently if I’m still too close. Once I’m finally far enough, it stops flashing and beeps. May seem a bit tedious, but it only takes a few seconds in practice, and not only does it calibrate the photo, but it also ensures that I have maximum detail.
Some cameras let you focus essentially touching the object — those wouldn’t work this way, clearly. But fancy cameras like yours may well give a focus distance or equivalent in the EXIF information. In principle it should be possible to use that calibrate. This would be an ideal method, since you wouldn’t have to pay attention at all in the field, knowing that every picture will automatically have its scale essentially recorded in the header.
Check out exiftool. It’s a free tool that dumps out all the info in the EXIF header. May only be available on unix, but windows and mac typically have even more options. All you’d need is a simple perl script that ran exiftool, grabbed the appropriate number(s), crunched them and spit out the target size of your scale bar.
my next question then is: which cameras have such a calibration feature? i’m not aware of any such function on my D60.
I got the idea from amadej:
I’ve calibrated my camera so that I know how many pixels per mm. The key is to take at least one photo as close as possible to the subject: start too close, then back off until the camera beeps, telling you it successfully got a lock.
I have a tiny transparent image layer that I can then overlay on top of the photo showing the scale. I just move it to some place suitably dark or featureless, sometimes darkening behind it a bit to help it show up. You might need Photoshop (or the roughly equivalent free product called Gimp), because not all image manipulation programs can handle layered images.
You can infer calibration for more distant shots by measuring the distance between shared points in both the close-up and distant shot, then scaling the scale bar layer accordingly.
I calibrated by taking ~10 photos of a ruler in various poses and at various angles. Result is accurate to within about 10%, good enough for these purposes. It’s much more accurate for shots through the microscope or dissecting scope — within 1%… which is to say, as accurate as your ruler or reticle!
(Note, of course, that this scale bar only applies to the focal plane, which is pretty narrow in my photos since my camera only goes down to f8 even in the brightest conditions. Things in the background will be larger than the scale bar says, things in the foreground smaller.)
how do you get the scale at the bottom left of each photo?
Created: 2010-10-02 08:17:33 BST (+0100)
Last modified: 2010-10-07 05:52:14 BST (+0100)
Viewed: 391 times, last viewed: 2016-11-01 18:33:52 GMT (+0000)