Here is a macro to get you started:
#@ Double (label = "Scale bar length in microns", value = 100) scaleBarLength
// Processes the active image, closing it when finished.
function process() {
// Measure the width of the scale bar.
roiManager("reset");
setThreshold(250, 255); // threshold the scale bar
run("Analyze Particles...", "size=200-Infinity add");
if (roiManager("count") != 1) {
exit("Failed to isolate the scale bar");
}
roiManager("select", 0);
Roi.getBounds(x, y, width, height);
run("Duplicate...", "scalebar");
pixelsPerPhysical = getWidth();
close();
// Crop off the no-longer-needed scale bar.
makeRectangle(0, 0, getWidth(), y - 1);
run("Crop");
// Assign the physical calibration.
micronsPerPixel = scaleBarLength / pixelsPerPhysical;
print("Microns per pixel = " + micronsPerPixel);
run("Properties...", "unit=micron" +
" pixel_width=" + micronsPerPixel +
" pixel_height=" + micronsPerPixel +
" voxel_depth=" + micronsPerPixel);
// Segment the main structure.
setAutoThreshold("Default dark");
run("Create Mask");
run("Dilate");
run("Erode");
run("Fill Holes");
run("Create Selection");
close();
run("Restore Selection");
// Measure the main structure.
run("Measure");
// All done.
//close();
selectImage(orig);
}
// Chop up the image and process each piece.
orig = getImageID();
w = getWidth();
h = getHeight();
// Isolate and process left image.
print("Processing left image");
makeRectangle(0, 0, w / 3, h);
run("Duplicate...", "left");
process();
// Isolate and process middle image.
print("Processing middle image");
makeRectangle(w / 3, 0, w / 3, h);
run("Duplicate...", "middle");
process();
// Isolate and process right image.
print("Processing right image");
makeRectangle(2 * w / 3, 0, w / 3, h);
run("Duplicate...", "right");
process();
run("Select None");
This macro makes some assumptions:
- All your images are divided into exactly three equally wide parts.
- The scale bar is the only white/nearly-white chunk of pixels. You can tune that latter assumption by changing the [250, 255] range in the
setThreshold
call to control exactly how bright the scale bar will be, and changing the size=200-Infinity
to control exactly how big the expected size of the scale bar will be in pixels.
- Auto-thresholding, followed by a simple dilate/erode/fill-holes sequence, will result in a reasonable mask of the object(s) to be measured. This can be adjusted in part labeled "Segment the main structure."
For the data posted above, the macro emits the following to the Log:
Processing left image
Microns per pixel = 0.6579
Processing middle image
Microns per pixel = 0.8696
Processing right image
Microns per pixel = 0.8929
And it emits the following information to the Results window:

You can control which columns get calculated using the Set Measurements... command.
Use setBatchMode(true)
to make things happen in the background (without windows being visibly created and deleted).
For more information, see this guide to macro programming.
Finally, be careful with JPEGs. It is better not to use them for quantitative image analysis unless you are certain it is OK. See this article for details.