Login  Register

Re: Threshold Colour - select/macro question

Posted by andreeas on Jul 29, 2015; 9:52am
URL: http://imagej.273.s1.nabble.com/Threshold-Colour-select-macro-question-tp5000412p5013796.html

Hello List,

Has anybody found a solution for the problem of yorkh2/Tate?
I'm struggling with the same problem: I cannot run the Color Threshold Macro on multiple files..

Thanks for any help
Andreas


Code I'm using:

dir1 = "......";
dir2 = ".........";
list = getFileList(dir1);

setBatchMode(true);
        for (i=0; i<list.length; i++) {
        showProgress(i+1, list.length);
        open(dir1+list[i]);

run("Color Threshold...");
// Color Thresholder 2.0.0-rc-30/1.49s
// 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]=40;
max[0]=125;
filter[0]="pass";
min[1]=78;
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-------------
saveAs("TIFF", dir2+list[i]);
close();
}
setBatchMode(false);