Posted by
Wayne Rasband-2 on
Sep 19, 2020; 12:42am
URL: http://imagej.273.s1.nabble.com/List-setMeasurements-limit-question-tp5023965p5023967.html
> On Sep 17, 2020, at 9:14 PM, Cammer, Michael <
[hidden email]> wrote:
>
> Hello, all-
>
> Last night I was trying to use the List.setMeasurements("limit") command and wanted to figure out how to toggle it on and off. I was getting unexpected results on microscopy data so wrote a macro to test it. The following gave unexpected results and I'd appreciate if someone could please point out how I am misusing the new command.
The List.setMeasurements function will work as expected if you use List.getValue() to read the values. The easiest way to get the mean with “limit to threshold” set is to use getValue(“Mean limit”). Here is an example:
newImage("Untitled", "8-bit ramp", 256, 256, 1);
setThreshold(128, 255);
//easy way
print("Mean with limit: "+getValue("Mean limit"));
print("Mean without limit: "+getValue("Mean"));
// harder way
List.setMeasurements("limit");
print("Mean with limit: "+List.getValue("Mean"));
List.setMeasurements;
print("Mean without limit: "+List.getValue("Mean"));
-wayne
> Using the following code, I expected either of these two outputs:
>
> 191.5
> 191.5
> 191.5
> 127.5
>
> or
>
> 191.5
> 127.5
> 191.5
> 127.5
>
> However, this is the output:
>
> 127.5
> 127.5
> 191.5
> 127.5
>
>
> macro "test limit command" {
> newImage("Untitled", "8-bit ramp", 256, 256, 1);
> run("Select All");
> setThreshold(128, 255);
> List.setMeasurements("limit"); // enables the "Limit to threshold" option.
> print(getValue("Mean"));
> List.setMeasurements("");
> print(getValue("Mean"));
> run("Set Measurements...", "mean limit redirect=None decimal=3");
> run("Measure");
> print(getResult("Mean", nResults-1));
> run("Set Measurements...", "mean redirect=None decimal=3");
> run("Measure");
> print(getResult("Mean", nResults-1));
> }
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html