|
Hi,
On Tue, 1 Feb 2011, Frank Sprenger wrote:
> There are several ways to add a scale bar onto an image (for example
> with the "scale bar.." tool), but these are always added in a
> destructive manner. Is there a way to add the scale bar to the overlay?
As far as I understand, the only way to do that is to write a macro (or
script or plugin) to do the job.
On the positive side, that macro can be modified to put the scale bar
exactly where you want it.
This macro would work for me, for example:
-- snip --
// Where to put it?
x = 10;
y = 180;
// How large (in units) should the scale bar be?
units = 50;
// How thick (in pixels) should the scale bar be?
height = 3;
// Which color?
color = "white";
// Assuming isotropic resolution in X and Y
getVoxelSize(width, dummy, dummy, unit);
width = width * units;
// The scale bar
makeRectangle(x, y, width, height);
run("Add Selection...", "stroke=" + color + " width=1 fill=" + color);
// The label
text = "" + units + " " + unit;
fontSize = getValue("font.size");
makeText(text, x + (width - getStringWidth(text)) / 2, y - fontSize - height);
run("Add Selection...", "stroke=" + color + " font=" + fontSize + " fill=none");
run("Select None");
-- snap --
Ciao,
Johannes
|