Import your image
img = Import["https://i.sstatic.net/hfEZx.png", "PNG"];
From the metadata (extracted from here) we can get the scaling of the picture.
pixelsPerMeter = {7710892, 7710892}
(I didn't mange to get the metadata from Mathematica)
We can check by overlaying a 10 x 1 micrometers bar on the original scale bar
Graphics[
{
img
, Red
, Rectangle @@ {#, # + N[pixelsPerMeter {10, 1} 10^-6]} &[{1797, 1369}]
}
]
Now you are scaling with ImageResize
from {1920, 1440}
to {250, 266}
, distorting the image.
scaledImg =
ImageTrim[
ImageResize[
ImageAdjust[img, {0.7, 0.75, 0.9}], {250,
266}], {{.08, .30}, {0.55, 0.75}}
, DataRange -> {{0, 1}, {0, 1}}]
The new scale is
newscale = pixelsPerMeter*{250, 266}/ImageDimensions[img]
and we can place a scale "Square" of 10x10 micrometers
With[
{
lbcorner = {10, 10}, (* In pixels *)
boxsize = newscale *{10, 10} *Power[10, -6](* In pixels *)
},
Graphics[{
scaledImg
, Red
, Rectangle @@ Accumulate[{lbcorner, boxsize}]
}
]
]
Please notice the undesirable distortion on the "square" you have introduced by forcing a change in the aspect ratio.
pixelsPerMeter
information directly from the image using Mathematica. $\endgroup$