Auto set max brightness - Color Threshold Macro
Posted by ams376 on
URL: http://imagej.273.s1.nabble.com/Auto-set-max-brightness-Color-Threshold-Macro-tp5010043.html
When manually using the Color Threshold command, ImageJ automatically sets the max brightness according to the selected image. When you put this into a macro using the recording tool it will set the max brightness to a fixed value. Is there a way to create a Color Threshold macro that doesn't use a fixed max, but automatically sets it according to the selected image like how the command works when using it manually.? Macro posted below.. The line I'm referring to - "max[2]=10;".
//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");
min[0]=0;
max[0]=255;
filter[0]="pass";
min[1]=0;
max[1]=255;
filter[1]="pass";
min[2]=0;
max[2]=10;
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);