Re: problem with incomplete contrast adjustment

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

Hi Michael and Wayne,

thank's very much for your advice! After removing
run("Brightness/Contrast..."); the macro works perfectly and faster too.

cheers,

Finn


> Hi Finn,
>
> Did you try to remove the
>   run("Brightness/Contrast...");
> statement and just leave the setMinAndMax?
>
> I think that you don't need to show the B&C panel. I have not analyzed
> it carefully, but the following might happen:
>
> If the B&C panel needs some time to get displayed, its windowActivated
> gets called asynchronously and runs the 'setup' procedure, which takes
> a new snapshot in case of an RGB image.
> This may cause a lot of trouble.
>
> Michael
> ________________________________________________________________
>
> On 24 Aug 2011, at 16:57, Finn Peters wrote:
>
>> Dear Kees,
>>
>> thank you for the reply. I tried it with a pause up to wait(10000)
>> after setMINAndMax(16,44); and at additional other positions. It
>> still does not work. It doesn't even work if I only run a macro of
>> the following two lines on a single image:
>> run("Brightness/Contrast..."); setMinAndMax(16, 44);
>> I guess there must be a problem with my computer somewhere. I will
>> try to make the macro in Photoshop.
>>
>> cheers,
>>
>> Finn
>>
>>> 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;
>>>           }}
>>>
>