I often use

run("Set...", "value=25 slice");

instead of clear or clear outside to avoid issues with LUTs or users changing 
colors.

Cheers-

Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory

NYU Langone Health, New York, NY  10016

[email protected]<mailto:[email protected]>

http://nyulmc.org/micros  http://microscopynotes.com/

Cell voice (no text) 1-914-309-3270

Office 1-646-501-0567



________________________________
From: Stein Rørvik <[email protected]>
Sent: Monday, February 19, 2024 4:17:37 PM
To: [email protected]
Subject: Problem with Fill and Clear Outside in macros

[EXTERNAL]

I have encountered a problem with "Fill" and "Clear Outside" in a macro.

What I want to do is to create a ROI on each slice in a stack based on fitting 
around the outline of a thresholded object,
and fill inside and clear outside to create a mask, leaving an overlay of the 
selection.

The problem is that "Fill" fills with the background color instead of the 
foreground color. It fills correctly on the first selected slice.
The problem does not occur if either the "Fill" or "Clear Outside" command is 
removed. It also does not occur if done manually via the GUI.

The following macro reproduces the problem:

close("*t1*");
run("T1 Head (16-bits)");
run("8-bit");
setSlice(nSlices/2);
setAutoThreshold("IJ_IsoData dark no-reset");
Color.setForeground("white");
Color.setBackground("black");
for (s = 50; s <= 100; s++) {
                setSlice(s);
                run("Create Selection");
                if (selectionType >= 0) {
                               run("Fit Ellipse");
                               run("Clear Outside", "slice");
                               run("Fill", "slice");            //bug? this 
fills with black, except for on slice 50
                }
                Overlay.addSelection("red");
                Overlay.setPosition(s);
}
setSlice(nSlices/2);
resetThreshold;
Roi.remove;


I am on Windows 10/64 using the latest daily build under Java 8 jre.

Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Reply via email to