Adding Scale Bars to Images

A while back I posted the method I use to make scale bars onto a Journal post. However, it feels like something which fits better here.

Fundamentally scale bars are pretty simple. Take a picture of a standard length such as a calibration slide, measure to get the mm/pixel, and add it to a photo.

To make my first scale bar I measured a photo of the calibration slide in Photoshop by going to Image > Analysis > Ruler Tool . That gave me the width of the scale bar in pixels. With the length of the 1 mm scale in pixels I was able to calculate the width of a single pixel.

In Photoshop I could measure any dimension in correct microns by going to Image> Analysis; Set Measurement Scale> Custom and setting it so one pixel was the correct number of microns. Then by going to Image> Analysis> Place Scale Marker I could make a 1mm scale bar. Unfortunately it gave a scale bar with a ridiculous number of significant digits and units in microns. Luckily with the text edit I was able to set it to 1mm.

Once you learn to make a scale bar you learn there are two big problems which must be overcome:

  1. You need to know what scale the photo is at.
  2. You need a method of adding scale bars quickly.

I solved the first problem two ways. The first is the traditional solution, use a microscope objective. There is no focus so the scale is always the same. The second was when using my macro lens to always focus to the minimum focus distance when I want to add a scale bar. This does require some discipline either remembering what photos were at minimum focus distance, or simply not taking photos at any other distance. However I found that on a 1X lens I was able to do 95% of my insect or lichen photography at minimum focus distance. This is nice because I just had to make a scale bar for 1X magnification and I was good to go.

An alternate solution to the first problem is to photograph a scale right after the photo, before you adjust the focus. This seemed like too much work to me though.

The second problem was solved with Photoshop actions. By making a new action and by pressing record when I made the scale bar I was able to turn the process of making a scale bar, saving the file, and closing the file into pushing one button. By going to File > Automate > Batch I can run the action on every file in a folder to add a scale bar, change the significant figures, save the file to a folder, and close the file.

Today my workflow is to put all the photos at minimum focus distance into a folder. Then I run the batch from Photoshop on every file in the folder and in a minute or so I have scale bars on all of them.

14 Likes

Somewhat related to this, including a scale object in the observation photo is often recommended or suggested. This might be a pen or coin, ie a common object that others will have access to and can measure directly themselves. I have seen a lens cap used, which is variable in terms of lens diameter, but not hugely so. For large things, like trees, having someone stand alongside is a good indicator of size, but again quite variable!

I gave a bit of thought to this, and it occurs to me that a pen, for instance, could be at a slight angle to the camera, and thus appear shorter than it really is. This would have the effect of making the subject appear larger than it is. Still considering the pen, if you angle it sideways (ie rotating in line with the barrel) then it doesn’t distort. This is true of any circular object, that no matter which way it is tipped, the apparent longest diameter will still be true. So it follows that the best “scale objects” are those that are circular, as well as readily available or familiar to others. Coins of course are country specific, and in the age of plastic are less likely to be at hand when needed, but are able to be sized even if you don’t have them handy, as you can google and find information on the coins of most countries!

3 Likes

I saw something about an app that does this. It was marketed to academics, and of course (sigh) I did not record the name. If I can find out more I’ll post it here.

My fallback for a scale object, especially w/ moths, is the Lightning Powder 6"/15cm rule. It lives in my field bag w/ my camera. Advantages include flat grey color (useful for photo editing/white balance), and quartered circles, to indicate if the rule is distorted. They can be used to correct for the distortion (I forget the formulas, but they’re available online.)

Or, of course, any rule, and I’m certainly not trying to sell people on this particular one, just let folks know of one among many that I’ve found useful.

5 Likes

It would be cool if cameras could just figure this out on their own and overlay an accurate virtual reticle on the image. But they don’t, so when I’m in the field I just carry a small ruler around. Nothing fancy, just a 6-inch clear plastic ruler with black numbers printed on it, like from a kid’s math set. Will set you back about $1-2. I tweak it by adding yellow electric tape to the back so the numbers show up better (example: https://inaturalist.ca/observations/2829077).

A grid background can work great too. Any school supply place/site should have rolls of the stuff, in metric or imperial. One application: I cover the wall by my moth light with panels covered in grid paper (example: https://inaturalist.ca/observations/14028334). Another application: tape some to your clipboard or a smaller board for field use…

6 Likes

UPDATE: I just wanted to followup with my coin-case idea for small creatures, samples.

Here’s the case I tried (friend included) has a diameter of 2cm. They were actually pretty cheap: something like 25 cases for $4.

The plastic is clear enough to photo through and unlike most small glass jars, the bottom surface is actually very flat. I printed out a small concentric scale (1mm steps) on my home printer and just taped it to my desk. Here’s my friend with a shot (taken with flash).

So yeah, if you want something to hold wee subjects for photographing, this seems to work pretty well. For shooting in the field, I’m going to clear glue that circle to another container. As you can see, the printed lines under the plastic get blurred with a super macro shot like this, but that can actually be an advantage. It’s still usable as a visual scale reference, but not strong enough in contrast to interfere with the specimen details.

The challenge is getting the specimen into the container. But that’s true with almost every handling technique.

4 Likes

@glmory I use also Photoshop analysis tools for my microscope images, e.g. here https://www.inaturalist.org/observations/148019872

In addition I use also piximetre http://www.piximetre.fr/ for accurate measurements of spores - very capable sofware, though interface is perhaps from Windows Xp era, but haven’t found better alternative

For standard macroshots I do mostly with Canon EF 100 mm lens, like this one https://www.inaturalist.org/observations/148279140) I think it could be posible to make a script for Photoshop to extract lens-to-object distance and generate scale bar - here is some discussion but I could not find more info: https://community.adobe.com/t5/photoshop-ecosystem-discussions/create-a-scale-bar-thoughts/m-p/3675682

2 Likes

@broacher Do you remember the brand, or where you got it? I’ve been looking for something like this without success.

Desmids, Microsoop. Sieralgen, Scale bars

Software

MICAM
Software to capture microscope images, measure objects and naming the result in an easy way.

October 2020. An updated version (MICAM 3.0.2) is available now!

Microscope & Photography at http://science4all.nl

Due to the fact that there is no additional optics between the microscope objective and the sensor only a small part of the total image is displayed on the sensor. This can be a drawback when you want to make a photograph of an object that fills the whole visible area. But for small object I get very sharp pictures this way.

Note: Normally you need a compensating eyepiece for many objectives to avoid coloured artefacts around the objects. As those artefacts are less obvious at the centre of the images the small field of view makes those artefacts less visible.

Using a DSLR

Many people use DSLR cameras on the microscope, so I also gave it a try with the Canon EOS 600D. I bought this camera because the Live View software comes for free with this camera.
The first hurdle I had to take is finding the right eyepiece to have the largest field of view without distortion or chromatic aberration around the edges of the objects. Fortunately I had I box with some old eyepieces and it proofed that an old K7x created a wonderful image. This eyepiece also has the option to move the eye-lens by means of a coarse thread. This was originally intended to focus a reticule in the eyepiece. In my case it enabled me to get increase the field of view by lifting the eye-lens about 1 cm.
Now I have the largest possible field of view and no chromatic aberration.


The Canon EOS 600D on my microscope

It would be nice if it was possible to open the image immediately in MICAM. So I tried to find a method to realize that. I stumbled upon a lot of problems, so finally I decided to do it in a different way: Let the Live View software store the image in a certain directory and then let my program detect the arrival of the image in that directory. Open the image in MICAM and be ready to perform my measurements, do some cropping and save the result with a specific name.
This way it would be possible for users of other brands of cameras to use the program as well. I hope that this is indeed possible, because I have no way to check this.

As I am a heavy microscope user I need a lot of functionality that can be accessed easily:

  • Cropping images to a convenient size.

  • Exposure correction inside MICAM after grabbing an image

  • Rotation of the image

  • Positioning of Scales and labels

  • The use of short-cut keys, to make operating MICAM as easy as possible.

  • Save the image with a selectable name from a database (so I don’t have to type a long name like Micrasterias truncata)

  • Save the picture as BMP, JPG, TIF or PNG

  • File name can be: Date+Time+Magnification or File name+Number+Magnification (you can Copy (or load from file) a picture in a measuring window. After calibration you can measure objects on the photo

  • Insert a scale (as you know from electron microscope pictures) and save the file again

  • Make calibration files for up to 16 different microscope-webcam combinations

  • Comprehensive manual

Below a few examples of the use of MICAM V2
http://science4all.nl/?Microscopy_and_Photography

German Manual (Not English!)
Microsoft Word - MICAM Anleitung dt.docx (science4all.nl)

4 Likes

Whereas credit and debit cards seem to be the same size everywhere.

Posting you credit card number online is only a medium-great idea though! :wink: :stuck_out_tongue:

6 Likes

That may be why credit cards nowadays seem to have the number on the back next to the security code.

The mentioned methods are all fine for static situations (like microscopes with known magnification or leaves on grid paper). How can we proceed in real outdoor settings? When photographing a wild animal, one cannot put a ruler next to it (the animal might be far away, it might sit on water, or be easily scared away).
My idea would be to use the EXIF informations, but I don’t know how reliable [0] they are. Ideally the website would have an embedded tool that allows one to insert a scale bar using the mouse. This is probably useless for animals far away where the distance setting on the lens is essentially at infinity, but it would help for macro lenses with their very small depth of focus. Alternatively a separate software might help with that.

All we need is a conversion factor from pixels to millimeters at a certain place in the image. If the distance to the animal is significantly larger than the focal length, we can assume animal_size=number_of_pixels*sensor_pixel_pitch*distance/focal_length, but this becomes increasingly wrong for shorter distances (where 1/focal_length=1/distance+1/separation_lens_sensor and the latter term is variable and unknown (that’s what one varies to get the image sharp)).

[0] The annotations to https://www.inaturalist.org/photos/266347495 say e.g. “2023-04-09 16:39:02 -0700”, but the timezone -0700 is in the American fly-over states, not here (+0100 in winter, +0200 in summer). I can’t assess whether the other data there are better (those which I understand seem to be OK).