Login  Register

Re: macro help

Posted by Huang, Judy C on Sep 09, 2005; 1:39pm
URL: http://imagej.273.s1.nabble.com/macro-help-tp3704810p3704816.html

Anil,

This is how I did it except for writing the result to an excel file which I
believe you can use the Excel Plug-In module mentioned in a few of earlier
e-mail.   -Judy



dir = getDirectory("Choose a Directory ");
list = getFileList(dir);
requires("1.34m");
totalFile=list.length;
setBatchMode(true);
for (i=1; i<=totalFile; i++)
{
    open(dir+list[i-1]);
    run("8-bit");
    run("Set Scale...", "distance=236.000 known=20 pixel=1 unit=mm global");
    setThreshold(67, 255);
    makeRectangle(280, 120, 116, 1562);
    fileName =substring(list[i-1],0,lengthOf(list[i-1])-4);
    run("Analyze Particles...", "minimum=100 maximum=999999 bins=20
show=Nothing display summarize");
    save("C:\\ImageJ\\Results\\" + fileName +"R"+i + ".txt");
    setThreshold(67, 133);
    makeRectangle(396, 128, 116, 1562);
   run("Analyze Particles...", "minimum=100 maximum=999999 bins=20
show=Nothing display summarize");
   save("C:\\ImageJ\\Results\\" +fileName+"L"+i + ".txt");
   close();
}
exit();


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Anil
Bagri
Sent: Thursday, September 08, 2005 9:06 PM
To: [hidden email]
Subject: macro help


hi all,
I have a quick (or perhaps not so quick) question for you.  I am trying
to process (count objects in ) a large batch of jpg files that are all
in the same directory using the following macro:

setAutoThreshold();
//run("Threshold...");
setThreshold(132, 255);
run("Threshold", "thresholded remaining black");
run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
show=Nothing summarize");


but I dont want to run the macro individually on each file in the
directory.  Is there a way to make the macro automatically run on every
file in the folder and put the values in an excel file?  will I have to
write another macro to make that happen.  can anyone help me with this
- it is clearly beyond my coding abilities.
thanks in advance
Anil





------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system.
------------------------------------------------------------------------------