Login  Register

batch adjust levels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

batch adjust levels

Uknalis, Joseph-2
Hiya, I'm trying to create a macro that will AUTO adjust all the images in one folder and place them in another.

So far I can select the folders but it barfs on the function.
Is resetMandMax another function call I have to write in?

  Thanks

Joe


dir1 = getDirectory("Choose Source Directory ");format = getFormat();
dir2 = getDirectory("Choose Destination Directory ");list = getFileList(dir1);
setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);

// Resets the display range of the current
// image so it is the same is the pixel
// value range.
macro "Reset Display Range"
{ resetMinAndMax();
saveAs(format, dir2+list[i]);
close();}





This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: batch adjust levels

Stein Rørvik
The syntax is wrong;
The construct macro "" is a declaration on the top level meant to be called from the menu or keyboard; and is not a function.

You probably need something like this:

macro "Reset Display Range" {
        dir1 = getDirectory("Choose Source Directory "); format = getFormat();
        dir2 = getDirectory("Choose Destination Directory "); list = getFileList(dir1);
        setBatchMode(true);
        for (i=0; i<list.length; i++) {
                showProgress(i+1, list.length);
                open(dir1+list[i]);
                // Resets the display range of the current
                // image so it is the same is the pixel
                // value range.
                resetMinAndMax();
                saveAs(format, dir2+list[i]);
                close();
        }
}

You also need to declare getFormat() in some way, I do not know your intent here.
Or just write format = "TIFF" or similar.

Stein

-----Original Message-----
Sent: 3. februar 2020 20:09
To: [hidden email]
Subject: batch adjust levels

Hiya, I'm trying to create a macro that will AUTO adjust all the images in one folder and place them in another.

So far I can select the folders but it barfs on the function.
Is resetMandMax another function call I have to write in?

  Thanks

Joe


dir1 = getDirectory("Choose Source Directory ");format = getFormat();
dir2 = getDirectory("Choose Destination Directory ");list = getFileList(dir1);
setBatchMode(true);
for (i=0; i<list.length; i++) {
showProgress(i+1, list.length);
open(dir1+list[i]);

// Resets the display range of the current
// image so it is the same is the pixel
// value range.
macro "Reset Display Range"
{ resetMinAndMax();
saveAs(format, dir2+list[i]);
close();}





This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.

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