> On Feb 20, 2024, at 2:05 PM, Stein Rørvik
> <[email protected]> wrote:
>
> I just found a new case when this does not work:
> If the image is binary, it works if the order is "Fill" and then "Clear
> Outside" but not the other way around.
This bug is fixed in the latest ImageJ daily build (1.54i21).
-wayne
> close("*t1*");
> run("T1 Head (16-bits)");
> run("8-bit");
> setSlice(nSlices/2);
> setAutoThreshold("IJ_IsoData dark no-reset");
> run("Convert to Mask", "method=IJ_IsoData background=Dark black create");
> //2024-02-20
> Color.setForeground("white");
> Color.setBackground("black");
> for (s = 50; s <= 100; s++) {
> setSlice(s);
> run("Create Selection");
> if (selectionType >= 0) {
> run("Fit Ellipse");
> Overlay.addSelection("red");
> Overlay.setPosition(s);
> if (true) {
> run("Clear Outside", "slice");
> run("Fill", "slice"); //fills with black
> } else {
> run("Fill", "slice"); //fills with white
> run("Clear Outside", "slice");
> }
> }
> }
> setSlice(nSlices/2);
> resetThreshold;
> Roi.remove;
>
> Stein
>
> -----Original Message-----
> From: Stein Rørvik <[email protected]>
> Sent: 20. februar 2024 19:07
> Subject: Re: Problem with Fill and Clear Outside in macros
>
> Thanks for the quick response,
> it works fine after this update!
>
> Stein
>
> -----Original Message-----
> From: Wayne Rasband <[email protected]>
> Sent: 20. februar 2024 16:53
> Subject: Re: Problem with Fill and Clear Outside in macros
>
>> On Feb 19, 2024, at 5:20 PM, Stein Rørvik
>> <[email protected]> wrote:
>>
>> I have encountered a problem with "Fill" and "Clear Outside" in a macro.
>
> The latest daily build (1.54i17) fixes a bug where calling run("Clear
> Outside","slice") set the foreground color to the background color.
>
> -wayne
>
>> 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