Re: Auto set max brightness - Color Threshold Macro

Posted by shubham1278 on
URL: http://imagej.273.s1.nabble.com/Auto-set-max-brightness-Color-Threshold-Macro-tp5010043p5022369.html

Hi,

I found the answer to this issue. You can change the macro as follows

//run("Threshold...");
// Color Thresholder 1.48v
// 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");
selectWindow("2");
setAutoThreshold("Default");
//run("Threshold...");
getThreshold(lower,upper);
resetThreshold();
//run("Close");

//print(lower+","+upper);

min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=lower;
max[2]=upper;
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-------------
setOption("BlackBackground", false);

Best,
Shubham



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html