Re: problem with incomplete contrast adjustment

Posted by Krs5 on
URL: http://imagej.273.s1.nabble.com/problem-with-incomplete-contrast-adjustment-tp3683343p3683344.html

Dear Finn,

It seems that the macro sometimes get ahead of itself. If you include

wait(100); after setMinAndMax(16, 44); it might solve the problem, at least it did on my test dataset.

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Centre for Core Biotechnology Services
College of Medicine, Biological Sciences and Psychology

http://www.le.ac.uk/biochem/microscopy/home.html


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Finn Peters
Sent: 23 August 2011 13:17
To: [hidden email]
Subject: problem with incomplete contrast adjustment

Hi,

in the following macro I do contrast and brightness adjustments on two images (one in red the other in green) and subsequently a selection of the red image is laid over the green image. Now I am quite puzzled because the same macro seemingly by chance yields different results (see attached jpgs) In the first case it worked out but in the second example only the upper part of the green image has been adjusted in contrast.
The bottom part still has the same linear contrast as in the orignial image.

I really have no idea what could be the reason for this.

cheers,

Finn


macro code:


inputFolder = getDirectory("Input folder"); files = getFileList(inputFolder); count = 0; id = 0; for (i = 0; i < files.length; i++) {
         open(inputFolder + files[i]);
         id2 = id;
         id = getImageID();
         count++;
         if ((count % 2) == 0) {
             selectImage(id);
             run("8-bit");
             run("Red");
             setAutoThreshold("Default");
             //run("Threshold...");
             setThreshold(3, 7);
             run("Create Selection");
             run("RGB Color");
             run("Copy");

             selectImage(id2);
             run("Brightness/Contrast..."); setMinAndMax(16, 44);
             run("Paste");
             run("Select None");

             name = getTitle();
             saveAs("Tiff", "C:/Users/Admins/Desktop/test/target/"+name+
"_merged.tif");
             close();
             close();
             count = 0;
         }}