Login  Register

Re: Threshold Colour - select/macro question

Posted by Michael Schmid on Oct 16, 2012; 9:34am
URL: http://imagej.273.s1.nabble.com/Threshold-Colour-select-macro-question-tp5000412p5000415.html

Hi Dani,

as I see it, the first problem is that the macro created by "Threshold Colour" is destructive. You have to duplicate the image first.
After running the macro created by "Threshold Colour", you get a mask, not a selection. You need Edit>Selection>Create Selection. Then you can select the original image and transfer the selection to the original image via Edit>Selection>Restore Selection. You can also transfer the selection via the ROI Manager (before adding to the ROI manager, clear an other selections in the ROI Manager's list).


Michael
________________________________________________________________
On Oct 16, 2012, at 01:42, danih wrote:

> 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");
>
>
>
> --
> View this message in context: http://imagej.1557.n6.nabble.com/Threshold-Colour-select-macro-question-tp5000412.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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