Determine Zoom Ratio on Image

Hello Folks,

I have some SEM images on different zoom ratio. I want to determine zoom ratio on every image. I am trying to write a macro but I need help on this step. This is one of the SEM images that I have.

Original TIF image: download

I make rectangle and crop with this codes:

makeRectangle(549, 1065, 124, 37);

I obtain this image and save it:

Then I open other images one by one and crop exactly as above.
Later I use imageCalculator to compare them.

imageCalculator("Subtract create", "x.tif", "y.tif");
getStatistics(area, mean);

If mean = 0 then I understand that both images has same zoom ratio. This method is working very well on most images. But I have problem on some images. Zoom Ratio is not written exactly same place on every image. Sometimes it slides a little bit because of date time and other settings. And I obtain this cropped image:

As you guess it doesn’t return mean = 0.

What can I do for determining zoom ratio correctly?

By the way, this is the first step of a macro that has several steps and I have to make this automatically since I have too many images.


I would not use that approach to compute the differences in magnification.
The mean grey value that you are computing depends on other things than magnification and the subtraction might be bracketed to 0 depending on the bit depth that you use.
I would rather use the ratio of line distance between landmarks that you can identify in both images, but really your image has a calibration bar so use that. Good luck!