Color threshold macros not using parameters

colorthreshold
Tags: #<Tag:0x00007fd542a7e800>

#1

Good time of a day, friends.

I have some problem with color thresholding macros working not as it should (I want). My feeling is that there is some bug here, though I might be wrong.

So. I have an image, where I have chosen some specific color manually and used “macro” button to create macros to do the same for other images. It looks like this.
`

run("Stack to RGB");
//run("Color Threshold...");

min=newArray(3);
max=newArray(3);
filter=newArray(3);
a=getTitle();
call("ij.plugin.frame.ColorThresholder.RGBtoYUV");
run("RGB Stack");
run("Convert Stack to Images");
selectWindow("Red");
rename("0");
selectWindow("Green");
rename("1");
selectWindow("Blue");
rename("2");
min[0]=0;
max[0]=200;
filter[0]="pass";
min[1]=108;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=123;
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);
run("Analyze Particles...", "size=0-Infinity show=Masks summarize");

`

Which is mostly auto-generated code. However, it seems, that it is not using parameters, which are written inside,
min[0]=0;
max[0]=200;
filter[0]=“pass”;
min[1]=108;
max[1]=255;
filter[1]=“pass”;
min[2]=0;
max[2]=123;

See images. 1 is macros work, the other is done manually (and from this “manually” macros was created).
Can anyone give me a tip how to fix it? I have tried several variations and they all somewhy didn’t work.

Thank you in advance



#2

I bet you are using a composite image, not a colour RGB image.
You need an RGB image.


#3

I guess it should be RGB since it is made by folowing command.

run("Stack to RGB");

#4

Well. I have found my way around. If I use the RGB system to select the color and make macros from it - it works as intended.
Though I was able to pin what I want in YUV better than in RGB, and macros with YUV parameters still works strangely.


#5

Well I do not think it was an RGB image, because the info line in the image you uploaded above is shown in a red font, and that is typical of composite images, not RGB ones.


#6

Yes, the one in the picture is composite. Its raw one. I’m making it RGB in the firs line “run(“Stack to RGB”);”… Well, at least I think this command is making it RGB.