Macro recorded changes automatically giving false result

Hi guys just wondering if any of you had this problem

I recorded my macro as this

with threshold for brightness pass being 113/255

but when I run my image into that recorded macro, it shows 0/85

Anyone have some ideas please

Thank you guys

Here is an idea: please post the image (not a screenshot) and the macro you recorded, otherwise it is impossible to know what you are doing.

1 Like

Thank you Gabriel ,

Macro that I recorded is

run("Color Threshold...");
// Color Thresholder 1.51a
// Autogenerated macro, single images only!
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]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=114;
max[2]=255;
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);
// Colour Thresholding-------------
run("Measure");

and this is my image I was working on

The macro you posted is not what the allegedly wrong result image is showing. Check the settings in the screenshot and the code. They are different.

The code:

min[2]=114;
max[2]=255;
filter[2]="pass";

the screenshot shows 0 and 85.

But more important. If you chose to run the macro, you should not run the applet.
The macro processes the image to obtain the same result that would be obained using the applet at the time when you pressed the “Macro” button.

I have a similar problem. When I use the CT windows (applet) in my image, I obtained one perfect ROI, but when I run the autogenerated CT macro from the same into recorded macro , the ROI is different, Why that happens or where are the error? I thinking of using this autogenerated CT macro for the others images too… Thanks so much :slight_smile:

this is my macro:

run("RGB Color");
// Color Thresholder 2.0.0-rc-49/1.51d
// Autogenerated macro, single images only!
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]=0;
max[0]=147;
filter[0]="pass";
min[1]=6;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=255;
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);
// Colour Thresholding-------------
run("Find Edges");
run("Gaussian Blur...", "sigma=4 scaled");
//setOption("BlackBackground", true);
run("Make Binary");
run("Dilate");
run("Dilate");
run("Fill Holes");
run("Dilate");
run("Fill Holes");
run("Erode");
run("Erode");
run("Erode");
run("Analyze Particles...", "size=10000-Infinity pixel display include add");
//run("Skeletonize");
//run("Analyze Skeleton (2D/3D)", "prune=none prune calculate");
//selectWindow("Tagged skeleton");
//close();

This is my original image

and that is the perfect ROI when I use the same parameters of H, S and B

and that is the other ROI when I use the autogenerated CT macro with the same parameters

Finally, I’m sure that I follow the same steps from the autogenerated macro concerning Process<Binary<Dilate or Erode

Thank you for the reply,

I am new to this software

I run the macro only I did not run applet yet it appear there

When I run the macro and result is showing 0 and 85.

I have been investing more than 10 hours in the macro and I am not getting any reliable data. I am frustrated mate.

I tried jorom’s image above and the macro I generated produces the same result as the applet settings at the same time I pressed “macro”. I used hue filtering in HSB mode (stopping rather than passing [i.e. untick “Pass”] and the range is 19 to 191.

// Color Thresholder 1.51e
// Autogenerated macro, single images only!
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]=19;
max[0]=191;
filter[0]="stop";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=255;
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);
// Colour Thresholding-------------

So, I think there is an error yet? because the filter in HSB mode is not the same, parameters have changed into both used proccesses.
At first, I thought this error was because I work with zvi files but then I converted them into RGB color with the same wrong result

Thanks :slight_smile:

I do not know if there is an error in the software because I cannot reproduce it. When I run it and generate the macro, it generates the same settings as when running the applet.