Posted by
Stein Rørvik on
Sep 24, 2018; 12:39pm
URL: http://imagej.273.s1.nabble.com/Placement-of-Scale-Bar-is-not-optimal-for-images-with-non-1-1-aspect-ratio-tp5021230.html
When using the "Calibration Bar..." and "Scale Bar..." functions, the resulting position on the image is inconsistent for the two cases.
It seems that "Calibration Bar" uses symmetric margins of x = 1/50th of image width; y = 1/50th of image width
and "Scale Bar" uses a non-symmetric margin of x = 1/20th of image width; y = 1/20th of image height
I think this looks good for the Calibration Bar, but it often looks awkward for the Scale Bar.
The Scale Bar position in the corner will be asymmetric if the image aspect ratio is not 1:1.
Also, I think that the tighter margins of Calibration bar looks better on large images.
Perhaps these margins should be controllable with a setting somewhere, or the same method for setting Calibration Bar margins could be used for Scale Bar too, for consistent results?
Yes I know there we have the location=[At selection] option but that is only convenient to use for the upper left placement, as the resulting height and width of the scale bar is not known beforehand so you cannot easily use [At selection] in the other three corners of the image because you do not know the result width or height of the scalebar in pixels before its creation.
Please have a look at this demo macro to see what I mean:
newImage("Untitled", "8-bit black", 400, 400, 1);
AnnotateImage(12);
newImage("Untitled", "8-bit black", 2000, 2000, 1);
AnnotateImage(24);
newImage("Untitled", "8-bit black", 400, 2000, 1);
AnnotateImage(24);
newImage("Untitled", "8-bit black", 2000, 400, 1);
AnnotateImage(20);
//placement of Calibration Bar looks good in all images
//placement of Scale Bar looks good only in the smallest image with 1:1 aspect ratio
function AnnotateImage(fontsize) {
run("Calibration Bar...", "location=[Upper Right] fill=White label=Black number=5 decimal=2 font=&fontsize zoom=1 overlay");
//margin: x = 1/50th of width
//margin: y = 1/50th of width
run("Scale Bar...", "width=50 height=2 font=&fontsize color=Black background=White location=[Upper Left] overlay");
//margin: x = 1/20th of width
//margin: y = 1/20th of height
}
Stein
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html