Macro for Auto Threshold to all Split Channels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Macro for Auto Threshold to all Split Channels

krura sandhu
Hello,

I am very new to Image J and I'd be grateful for some help on making my macro capable to run auto threshold on the 3 split channels from any stained picture. The purpose is to split a multi channel image and run an auto threshold for each of the 3 split channels for any picture.  

So far the macro can convert the multi channel image to 8 bit and can perform the function "splitChannels"
However, the tittle of a stained picture prevents me to do auto threshold on a different stained picture.
I have defined the image tittle to be name = getTitle();
Additionally, I have associated the 3 split channels with these 3 variables.
C1 = "C1-"+name;
C2 = "C2-"+name;
C3 = "C3-"+name;

When I write "selectWindow C" prior to the auto threshold function, it prevent me to execute the line since there is "no window with the tittle C1 found." Should I define it as blue, green, or red?

Any suggestions will be great. I do not know if I have to create a new macro or continue with this macro.

run("8-bit");
run("Split Channels");
name = getTitle();
C1 = "C1-"+name;
C2 = "C2-"+name;
C3 = "C3-"+name;
run("Split Channels");
selectWindow("C1");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0 parameter_2=0 white");
selectWindow("C2");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0 parameter_2=0 white");
selectWindow("C3");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0 parameter_2=0 white");



Thanks so much
Krura  
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Macro for Auto Threshold to all Split Channels

Cammer, Michael
You need to get the title before splitting the channels and not the syntax in the selectWindow command.  This works for me.

newImage("HyperStack", "16-bit composite-mode label", 400, 400, 3, 1, 1);
 run("8-bit");
 name = getTitle();
 run("Split Channels");
 C1 = "C1-"+name;
 C2 = "C2-"+name;
 C3 = "C3-"+name;
 selectWindow(C1);
 setAutoThreshold("Default dark");


_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopy
http://microscopynotes.com/
Cell: (914) 309-3270

________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of krura sandhu [[hidden email]]
Sent: Wednesday, July 26, 2017 12:58 PM
To: [hidden email]
Subject: Macro for Auto Threshold to all Split Channels

Hello,

I am very new to Image J and I'd be grateful for some help on making my
macro capable to run auto threshold on the 3 split channels from any stained
picture. The purpose is to split a multi channel image and run an auto
threshold for each of the 3 split channels for any picture.

So far the macro can convert the multi channel image to 8 bit and can
perform the function "splitChannels"
However, the tittle of a stained picture prevents me to do auto threshold on
a different stained picture.
I have defined the image tittle to be name = getTitle();
Additionally, I have associated the 3 split channels with these 3 variables.
C1 = "C1-"+name;
C2 = "C2-"+name;
C3 = "C3-"+name;

When I write "selectWindow C" prior to the auto threshold function, it
prevent me to execute the line since there is "no window with the tittle C1
found." Should I define it as blue, green, or red?

Any suggestions will be great. I do not know if I have to create a new macro
or continue with this macro.

run("8-bit");
run("Split Channels");
name = getTitle();
C1 = "C1-"+name;
C2 = "C2-"+name;
C3 = "C3-"+name;
run("Split Channels");
selectWindow("C1");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0
parameter_2=0 white");
selectWindow("C2");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0
parameter_2=0 white");
selectWindow("C3");
run("Auto Local Threshold", "method =Try all radius=100 parameter_1=0
parameter_2=0 white");



Thanks so much
Krura



--
View this message in context: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_Macro-2Dfor-2DAuto-2DThreshold-2Dto-2Dall-2DSplit-2DChannels-2Dtp5019130.html&d=DQICAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=k7amV-XBe4Tuyy83y_F62b5VwzmF_vZ3J58vbJzzg6k&s=GseCzmKZd6mXQToRvYaHyMjAVAcye4J3soOKWBZoBFs&e=
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DQICAg&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=k7amV-XBe4Tuyy83y_F62b5VwzmF_vZ3J58vbJzzg6k&s=zUhcvMnRIGLQRdPv53Jv6rcxULd1nw5cQedKSEbPUgE&e=

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================

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