How to draw lines in every slice of a stack

Dear Forum,

I’m trying to add a scale to every image of an stack. The code for scale is done so far.

setLineWidth(2); setColor(255, 255, 255); drawLine(zero, height, w, height);

This is just a snippet of the code and it just draws the horizontal line of the scale.
But if I try to use this on a stack and then run the Flatten comand
run("Flatten");
which I think is the command for combining the line with the image.
It only apllies the line to the first Image of the stack.

Do you know how to apply the line (and text) to all images within the stack?

Best Tobias

Okay I figured out by myself.

The trick was istead of using drawLine I use Overlay.drawLine(x, y, x, y); now folowed by Overlay.show(); and run("Flatten", "stack"); now the whole stack is processed. :slight_smile:

Thanks for reading :slight_smile:,
maybe this will help others.

Best Tobias

2 Likes