Login  Register

Re: setting min, max from histogram

Posted by Gluender-2 on Apr 17, 2009; 1:23pm
URL: http://imagej.273.s1.nabble.com/Re-setting-min-max-from-histogram-tp3692900p3692907.html

>thankyou herbie
>
>i executed both of them and both yeild the same results. so i guess both
>works
>
>and yours does the same thing in lesser number of lines and is less complex
>so i would love to stick to ur codes.
>
>thankyou again
>
>have a nice evening
>--
>Donny George


Ok, here we go, using an imagej 16 bit "ramp" 256x64 test image.

Your macro code:
>>     getStatistics(pixels, mean, min, max, std, histogram);
>>     print("Initial-  Mean "+mean+", Min "+min+", Max"+max+", STD"+std+"");
>>     //getMinAndMax(min, max);
>>     run("Brightness/Contrast...");
>>     setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
>>     //getMinAndMax(min, max);
>>     waitForUser("Adjust Brightness/Contrast..., Press (OK)");
>>     print("Modified Min"+min+", Max"+max+"");

Log-window output:
Initial-  Mean 32640, Min 0, Max65280, STD18919.0467
Modified Min0, Max65280


My macro code:
resetMinAndMax;
getStatistics(N, mean, min, max);
print(mean);
print(min, max);
setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
getMinAndMax(min, max);
print(min, max);

Log-window output:
32640
0 65280
21757 21846

---------------------------------

Evidently, your min-value is 0 and the max-value is 65280 in the log
window, while with my code the values are 21757 and 21846
respectively.

Of course the actual Brightness/Contrast-setting is correct with both macros.

HTH
--

                   Herbie

          ------------------------
          <http://www.gluender.de>