How to limit to threshold for measurement in a macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to limit to threshold for measurement in a macro

BrianBL
Hi,

I am trying to write a macro to do some measurements that is limited to thresholded regions. I know I can do it manually by checking Menu -> Analyze->Set Measurements->Limit to Threshold and then Menu-> Analyze -> Measure. However, when I tried to do this in a macro, it does not work.

Here is the macro.

setOption("Limit to Threshold", true);
setThreshold(50,255);
List.setMeasurements;
area = List.getValue("Area");
mean = List.getValue("Mean");
//getRawStatistics(area, mean);
//getStatistics(area, mean);
print(area, mean);
resetThreshold;
setOption("Limit to Threshold", false);

The output values are different from manual measurements. I also tried getRawStatistics and getStatistics. No luck.

So it seems that this setting setOption("Limit to Threshold", true) does not affect the behavior of these measurements in a macro. Or did I do something wrong? Is there a solution?

Any suggestion are appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: How to limit to threshold for measurement in a macro

Andrew Sanchez
This might (hopefully) help you.  It's the macro I use to get measurements via Analyze Particles from a thresholded image, based on a previously selected area.  It was auto generated using Record Macro.

min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
run("HSB Stack");
run("Convert Stack to Images");
selectWindow("Hue");
rename("0");
selectWindow("Saturation");
rename("1");
selectWindow("Brightness");
rename("2");
min[0]=36;
max[0]=128;
filter[0]="pass";
min[1]=34;
max[1]=210;
filter[1]="pass";
min[2]=30;
max[2]=225;
filter[2]="pass";
for (i=0;i<3;i++){
  selectWindow(""+i);
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
}
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
  selectWindow(""+i);
  close();
}
selectWindow("Result of 0");
close();
selectWindow("Result of Result of 0");
rename(a);
// Color Thresholding-------------

// counts number of green pixels under total area column in the summary table.  excludes pixel groups of less than 10 pixels
run("Analyze Particles...", "size=10-Infinity summarize");