An ImageJ tutorial for using the Microscope_Scale plugin and multiple calibration files.

Dale Callaham - University of Massachusetts @ Amherst

This tutorial has information for use with files in the "" file available at


Unpack the file into the Plugins folder.

These instructions work with the Zipfile of my "#Calibrations" folder as an example to experiment with and modify. I used Winzip to pack it. If you unzip into the ImageJ 'plugins' folder it should create a folder "#Calibrations". In that folder are several source and compiled plugins that demonstrate how I use it. (Note: the "#" in the "#Calibrations" name places it at the top of the Plugins menu.......)

Check the unzip/installation................

If you have it unzipped in the Plugins folder and see the #Calibrations folder, then launch ImageJ and select from the top menu "Plugins" and you should see a folder "#Calibrations" if all is set correctly, and selecting "#Calibrations" should show the available choices: this step was just to confirm the installation so let the menu close and do the next step.

Try it out..................

Open the file "JEOL_600dpi_10k.jpg" located in the #Calibrations folder; it is a piece of a calibration grating (2160 lines/mm) shot at 10k and negative scanned at 600dpi.

With the image open you will see in the top bar of the image (below the filename/window_name) "2052x429 pixels" indicating that it is in pixels and not calibrated.

With the image selected, go to the menu "Plugins|#Calibrations" and select JEOL_600dpi and you should get a panel with a "Nominal Magnification" selection box: Click on the arrow and select "10k" from the list (since you know it is shot at 10k, scanned at 600dpi, and this is the 600dpi calibration plugin). For now, just click OK and you should see the image top info bar change to "7928.93x1657.66 nm" indicating that it has been "calibrated". To confirm the correct calibration, select the "line tool" (5th from left on the standard menu bar). Position the mouse cursor at the start of one line and <holding down the mouse button drag a straight line across 10 of the grating lines (you can parallel the marked line already on the image) and look at the ImageJ info bar before you release the mouse button - it displays the coordinates and should display the length of the line in "nm" since this is how the calibration is set.

Release the mouse cursor and the marked line remains.
    If you press CTRL-D it will draw the line in the current color
    If you press CTRL-M it will measure and open "RESULTS"

Note that you had a couple of options when the JEOL_600dpi plugin was selected: 'Global Calibration' and 'Add A Scalebar'. Check the Global Calibration box if all of the images you will be working with are at the same calibration to save time when each new image is opened. The 'Add A Scalebar' option does just what you would expect, and will place it at the selection if one exists on the current image, or else at the chosen position, settable in the panel. Note that it will probably offer some inappropriate value, like "617 nm" but you can just type a more conventional value like "500" in the box before accecpting the choice.

How do you get the calibration data?

First you have to shoot the calibration images. The calibration images are taken of an appropriate sample, in this case a 2160 lines/mm grating replica, and one picture for each magnification required. This can be direct digital data (from a CCD, etc.) or from scanning the negatives at a certain resolution; note that you will need different calibration files for negatives scanned at 600dpi or 1200dpi, etc. (see below).

Using the same demo image ("JEOL_600dpi_10k.jpg")  you can see how the JEOL_600dpi "10k" calibration was CREATED, and also check that it is giving correct results. If you close and re-open the image again it should again appear uncalibrated (watch the status/info line at the top of the image window). This image was labeled, but the info is in the "2160-replica-info.txt" file.

Use the straight line tool to draw a selection straight across 10 lines of the grating image noting the number in the ImageJ status line before releasing the mouse cursor (if you already released it, press CTRL-M to see the value in the "Results" window. If you selected 10 lines you should have a value "1202" (pixels). You know the line spacing as given in the included file "2160-replica-info.txt": 2160 lines/mm grating = 2.160 lines/um = 0.46296 um/line = 463 nm/line.

10 lines are ~4630 nm (known for the grating), and ~1202 pixels (by your measurement) so 4630nm/1202pixels = 3.852 nm/pixel.

Note: A calibration has to be generated for each condition that is used to acquire an image. By "condition" I mean that if a "10k" negative is scanned at 600dpi, or 1200dpi, you will have to make a calibration for each. If you use binning on a CCD array you might want a "full" and a "-2x2" version of the file so you can quickly select the correct one. In the case of the JEOL samples files, the value for the 1200dpi scan of a "10k" negative will result in twice as many pixels for the measured length. To avoid errors, I find it useful to name the files with the mag and scan resolution as part of the name as in the sample image "JEOL_600dpi_10k.jpg".

How do you create or edit the calibration file?

If starting from scratch, just make a copy of the file to a new name and edit that file.  See notes on multiple calibration files.

Open the source file with a text-only editor such as Notepad (included in Windows) or  Notepad++ (free open-source programming editor for Windows) and have a look at the java code. If you look in the file you will see this section of source code:

        Edit the following arrays using your microscope's nominal magnification steps, the
        corresponding spatial calibration and the length units of the spatial calibration.
        Make sure the arrays are of equal length.
        // nominal magnification settings of the microscope
        private static String[] mags =  { "2k", "3k", "4k", "5k", "6k", "8k", "10k", "15k", "20k", "25k", "30k", "40k", "50k"};
        // spatial calibration for the nominal magnification settings - width of one pixel (pixelWidth) in units below
        private static double[] xscales = {18.049, 12.695, 9.595, 7.754, 6.351, 4.994, 3.864, 2.630, 2.132, 1.583, 1.264, 1.068, 0.788};
        // units for the spacial calibrations given in xscales array above
        private static String[] units =  { "nm",  "nm",  "nm", "nm",  "nm",  "nm",  "nm",  "nm", "nm",  "nm",  "nm",  "nm",  "nm"};
/* END EDIT **/

These were produced for the magnification steps of our TEM and for digitized (scanned) negatives and the data in this file was produced from negatives scanned at 600dpi while a separate file was produced for 1200dpi scanned negatives.

There are 3 lists of values that define the name of the calibration; each of these lists starts with "private static" keywords. Edit these arrays with your data measured from the images of the calibration standard (grating, etc). Check that you have the same number of elements in each array and that you have correspondence between the lists. For the "10k" entry of the JEOL_600dpi example, "10k"  info is the 7th element in each array: a calibration name ("10k"); a calibration value (3.864); and a unit name ("nm"). Note that a calibration can change from micrometers to nanometers to cubits as long as the corresponding calibration value is correct. (Note: 1 cubit  =  457,200,000 nanometers (approximately)).

You will make a measurement from an image of a standard for each needed calibration and edit these arrays inserting your data. You don't need to know JAVA, but pay careful attention to the existing puctuation format and maintain it - assume that everything including spaces inside of quotes, etc. matter - just mimic the format and if you have trouble compiling (the "Plugins|Compile and Run" selection) go back and check for "syntax" errors. Only edit the arrays within the Start/End comments.

Using Multiple Calibration Files

This should be clear if you have downloaded and installed the "" contents to yield the "#Calibrations" folder in the ImageJ/plugins folder since there will be several sample calibrations to study and choose from. The sample plugins are all based on the "Microscope_Scale" plugin from the ImageJ website. It a file is copied to a new name for modification remember these things:
ImageJ plugins

Installing a plugin is easy. Follow these steps to download and install the Microscope_Scale plugin.

Locate the ImageJ folder on your computer so you can put the plugins into the "Plugins" folder. One easy way (on a PC) is to run ImageJ and go to the menu "Plugins|Edit" and it will show the path to the ImageJ folder so you can select a plugin for editing; look at the path so you know where ImageJ is installed - the "Plugins" folder is a subfolder of the ImageJ folder, although plugins can be located elsewhere it is good to keep them here. The "Plugins" folder can have subfolders that can be used to organize related Plugins.

ImageJ installs (default on a PC) in the "C:\Program Files\ImageJ" folder so the path to the plugins in that case is:  "C:\Program Files\ImageJ\plugins"

Using a web browser go to, select "Plugins" and in the "Analysis" section you should see "Microscope Scale" (The URL is On this page you will see a "Microscope_Scale.class" file that is the source (editable, human readable code) and a file "" that is the compiled version. The ".java" can be downloaded directly to your "plugins" folder and run, but in this case it contains only demo data and so it will not be useful to you! The ".class" file needs to be downloaded in order to edit to produce a useful microscope_scale plugin.

To download one of these files, just click on it and (typically) you will be offered a "save to disk" dialog box and you can point it to your ImageJ plugins folder. On a PC running a Mozilla browser, you can press the CTRL key when clicking on the filename to force a "save to disk" so it doesn't try to open the file and run it....

If you downloaded a ".java" file directly to the "plugins" folder, it should appear on the Plugins menu when ImageJ is next restarted. If it is placed in a folder in the "plugins" folder that folder will appear on the Plugins menu and the plugin will be found in that folder. This gives a nice way to organize related plugins.

If you downloaded a ".class" file you have the source code and it needs to be compiled before it will appear on the ImageJ menu and be functional as a plugin. To do this, just launch ImageJ, select the Plugins|Compile and Run choice; select the folder and file to compile, and select OK. It should compile and run. This only has to be done when the source code ".java" file is altered. Once compiled the ".class" file is placed in the same folder as the sorucecode and it can subsequently be run from the Plugins menu. If the plugin requires an image, it will complain and you must close the info window, but the plugin will now be compiled to the same folder as the source ".java" file was located.  Now just open an image and then the plugin can be run directly from the Plugins menu.

How to make your PC open ".java" files with Notepad.

Go to the folder containing the java code. Select a ".java" file - don't open, just one click to select - and then right-click and choose "Open with". When you get the list of programs to use, scroll down to select "Notepad", and check the box "Always use this application to open this type of file".

Final note. The cubit is a greatly neglected unit of measurement these days, and it would be nice to see it used more widely.