User interaction Brightness/Contrast

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

User interaction Brightness/Contrast

SarahV
Hello everyone,
I barely have any programming experience but would like to do the following:
- scale all images in a certain directory, set scale and add scalebar, apply green LUT
- adjust brightness/contrast by hand to make it visible
- save each image both as tiff and as png with the suffixes 'beab' and 'beabpng' added to them, respectively.

This is what I have so far (see below), the scaling and LUT and saving works but ImageJ does not display the images in a window, therefore I am not able to see what I am doing before I click ok.
I am aware that I probably should add lines to display the images in a window and select a window, but no idea how or if it's even possible without splitting the thing in 2 macros.

Best greetings
Sarah


macro "greenscalethensave" {LocationOfFiles = getDirectory("Select Folder");
LocationOfSave = getDirectory("Select Save Location");
setBatchMode(true);
FileList = getFileList(LocationOfFiles);
NumberOfFiles = FileList.length;
for (i=0; i<NumberOfFiles; i+=1) {
    FileName = FileList[i];
  open(LocationOfFiles+FileName);
    name = getTitle();
        run("Green");
        run("Set Scale...", "distance=1 known=0.10 unit=um");
        run("Scale Bar...", "width=10 height=12 font=42 color=White background=None location=[Lower Right] bold overlay");
        run("Brightness/Contrast...");
        waitForUser("Do something, then click OK");
        SaveName1 = replace(name, ".tif", " beab.tiff");
    SaveName2 = replace(name, ".tif", " beab.png");
    saveAs("TIFF", LocationOfSave+SaveName1);
    saveAs("PNG", LocationOfSave+SaveName2);
}
}
}
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: User interaction Brightness/Contrast

Glen MacDonald-2
Dear Sarah,
comment out the BatchMode, it does not display intermediate images.  
        //setBatchMode(true);


Regards,
Glen MacDonald
Digital Microscopy Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
depts.washington.edu/digmicro
[hidden email]









> On Jun 7, 2017, at 9:16 AM, SarahV <[hidden email]> wrote:
>
> macro "greenscalethensave" {LocationOfFiles = getDirectory("Select Folder");
> LocationOfSave = getDirectory("Select Save Location");
> setBatchMode(true);
> FileList = getFileList(LocationOfFiles);
> NumberOfFiles = FileList.length;
> for (i=0; i<NumberOfFiles; i+=1) {
>    FileName = FileList[i];
>   open(LocationOfFiles+FileName);
>    name = getTitle();
> run("Green");
> run("Set Scale...", "distance=1 known=0.10 unit=um");
> run("Scale Bar...", "width=10 height=12 font=42 color=White background=None
> location=[Lower Right] bold overlay");
> run("Brightness/Contrast...");
> waitForUser("Do something, then click OK");
> SaveName1 = replace(name, ".tif", " beab.tiff");
>    SaveName2 = replace(name, ".tif", " beab.png");
>    saveAs("TIFF", LocationOfSave+SaveName1);
>    saveAs("PNG", LocationOfSave+SaveName2);
> }
> }
> }
>

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