Threshold Colour - select/macro question
Posted by danih on Oct 15, 2012; 11:42pm
URL: http://imagej.273.s1.nabble.com/Threshold-Colour-select-macro-question-tp5000412.html
Dear Esteemed List,
I'd like to create a macro that will select an ROI based on the Hue range I define in order to subsequently delete those regions/values from my histological RGB images. Using Landini's Threshold Colour Plugin, I set my hue, saturation and brightness settings, press "Select" in the Threshold Colour dialogue, and press "Macro" in the Threshold Colour dialogue in order to generate the code in the recorder (see below). I subsequently hit the delete key on my keyboard to delete my selection (this adds run("Clear", "slice"); to my macro recorder).
THE PROBLEM: When I run this macro, it stalls immediately prior to the
run("Clear", "slice");
line and gives an error that indicates that the "Clear" command requires a selection.
I'm confused b/c I HAVE pressed the "Select" button within the CT dialogue, but I don't think it's actually doing anything that gets recorded in the macro. If I do this process manually, I get the result I want: an image with portions of it defined by the hue range deleted. But, the macro isn't working.
MY QUESTION: is there a way to either a. make the CT dialogue record my selection in the macro OR b. select this color thresholded area as an ROI in some other manner?? Any and ALL help much appreciated!!
Many thanks!
dani
run("Threshold Colour");
// Threshold Colour v1.12a------
// Autogenerated macro, single images only!
// G. Landini 27/Sep/2010.
//
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]=207;
filter[0]="pass";
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);
// Threshold Colour ------------
run("Clear", "slice");