Archivos de diario de mayo 2017

26 de mayo de 2017

Scale bars

I have long wanted to put scale bars on pictures. They just make them seem more scientific. When it comes to more difficult species to ID they can even be pretty important in being able to get an ID from a photo. With a scale bar it is even possible to put the picture in photoshop, set the scale, and measure out lengths of various details such as antenna length in the photos.

Getting them on images with a macro lens is a bit of a pain though. The scale changes as the image focus changes. In theory it should be possible to take the information in the photo about the lens focus at the time of the photo and convert it to a scale, in practice it is difficult though. At a minimum it takes a bit of scripting, and from what I have read the accuracy of the lenses is not good enough to get particularly accurate.

With a microscope objective it is comparatively easy. As I have it set up my Mitutoyo 5X Objective is either at 3X or 5X magnification. So, all I need do is figure out the dimensions of one pixel in each scenario and make Photoshop add a scale bar. To that end I bought a microscope calibration slide and imaged it at 3X and 5X.

After doing this, I realized that I take a majority of my photos of insects with 1X magnification by putting the macro lens at minimum focus. By taking a photo of the calibration slide at 1X magnification, it is possible to add a scale bar to any photo which was taken at minimum focus distance. Technically this would be possible at any magnification, but 1X magnification is the only magnification I can quickly and accurately reproduce since it is the minimum focus distance.

That was the easy part. Even once I figured out the overall idea, turning this into a practical method took some time. First, I needed to measure the scale bar 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 microns.

I was then able to set the scale such that 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.

Now I had my first scale bar!

After making about ten of these, I realized that this was just way too much work to fit into my workflow. It needed to be automated!

First I read up on 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 into pushing one button. Then I made another action which recorded the process of saving as a jpg. Now I just needed to load the photo into photoshop and hit two buttons and the whole process would just work.

Still too much work.  Then I learned that by going to File > Automate >  Batch I could run the action to add a scale bar to every photo which is open. So now all I do is load all the files to get a scale bar, tell it to put a scale bar on every photo then tell it to save every photo. I will have to turn it all into one action one of these days, but it is finally practical to insert into my workflow.

If you are trying this there are a few traps to watch out for. First, the pixel size must be unchanged since the photo was taken. If the photo was compressed when you exported from Lightroom, or saved in some other software then all your scale bars will be wrong. Also, it is easy to put a photo into Photoshop which was not at 1X magnification. Any of those photos will have a wrong scale bar.

Publicado el mayo 26, 2017 03:35 MAÑANA por glmory glmory | 29 observaciones | 3 comentarios | Deja un comentario