Re: setting min, max from histogram

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Karel Jansseune-2
On Thu, 16 Apr 2009 11:40:00 +0200, Donny George <[hidden email]>
wrote:

>On Thu, Apr 16, 2009 at 11:27 AM, Gluender <[hidden email]> wrote:
>
>> hello
>>>
>>> i would like to set the min and max values for brightness of an image
by
>>> making some calculations from the values like mean and standard
deviation

>>> obtained from the histogram of the image. i wrote the macro in this way
>>>
>>> run("Brightness/Contrast...");
>>>    getStatistics(mean, min, max, std, histogram);
>>>
>>>    setMinAndMax(mean*0.6666,201);
>>>
>>> and this not work. could somehow help me to successfully modify this.
>>>
>>> thank you one and all for the help in advance
>>>
>>> regards
>>>
>>> --
>>> Donny George
>>>
>>
>>
>> I've replied to your question immediately after your first post to the
>> list.
>>
>> ------------------------
>>
>> Here is my reply again:
>>
>> The macro functions manual says:
>> getStatistics(area, mean, min, max, std, histogram)
>>
>> so
>>
>> getStatistics(area, mean);
>> print(mean);
>>
>> should do the trick.
>>
>> HTH
>> --
>>
>>                  Herbie
>>
>>         ------------------------
>>         <http://www.gluender.de>
>>
>
>
>thankyou and sorry i didnt see ur post earlier
>
>i modified it and i could print the values correctly but i am not able to
>make a calculation with it so that i can modify the brightness
>
>run("Brightness/Contrast...");
>    getStatistics(mean, min, max, std, histogram);
>    print(""+mean+", "+min+", "+max+", "+std+"");
>    setMinAndMax("+mean+"*0.6666,201);
>
>could you help me with the syntax for the mulplication
>
>thnkyou again
>
>Donny George
>=========================================================================

Dear Donny,

changing you code to

setMinAndMax("+getStatistics[mean]+"*0.6666,201);

should do the trick


Regards,

Karel
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Gluender-2
>On Thu, 16 Apr 2009 11:40:00 +0200, Donny George <[hidden email]>
>wrote:
>
>>On Thu, Apr 16, 2009 at 11:27 AM, Gluender <[hidden email]> wrote:
>>
>>>  hello
>>>>
>>>>  i would like to set the min and max values for brightness of an image
>by
>>>>  making some calculations from the values like mean and standard
>deviation
>>>>  obtained from the histogram of the image. i wrote the macro in this way
>>>>
>>>>  run("Brightness/Contrast...");
>>>>     getStatistics(mean, min, max, std, histogram);
>>>>
>>>>     setMinAndMax(mean*0.6666,201);
>>>>
>>>>  and this not work. could somehow help me to successfully modify this.
>>>>
>>>>  thank you one and all for the help in advance
>>>>
>>>>  regards
>>>>
>>>>  --
>>>>  Donny George
>>>>
>>>
>>>
>>>  I've replied to your question immediately after your first post to the
>>>  list.
>>>
>>>  ------------------------
>>>
>>>  Here is my reply again:
>>>
>>>  The macro functions manual says:
>>>  getStatistics(area, mean, min, max, std, histogram)
>>>
>>>  so
>>>
>>>  getStatistics(area, mean);
>>>  print(mean);
>>>
>>>  should do the trick.
>>>
>>>  HTH
>>>  --
>>>
>>>                   Herbie
>>>
>>>          ------------------------
>>>          <http://www.gluender.de>
>>>
>>
>>
>>thankyou and sorry i didnt see ur post earlier
>>
>>i modified it and i could print the values correctly but i am not able to
>>make a calculation with it so that i can modify the brightness
>>
>>run("Brightness/Contrast...");
>>     getStatistics(mean, min, max, std, histogram);
>>     print(""+mean+", "+min+", "+max+", "+std+"");
>>     setMinAndMax("+mean+"*0.6666,201);
>>
>>could you help me with the syntax for the mulplication
>>
>>thnkyou again
>>
>>Donny George
>>=========================================================================
>
>Dear Donny,
>
>changing you code to
>
>setMinAndMax("+getStatistics[mean]+"*0.6666,201);
>
>should do the trick
>
>
>Regards,
>
>Karel

This is a somewhat strange suggestion, did you try it?

--

                   Herbie

          ------------------------
          <http://www.gluender.de>
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Karel Jansseune-2

Dear,

you are correct, I tried it and it doesn't work.
i use construction a lot for other functions, but it now occurs to me that it can't be used in this case.

My mistake

The solution you suggest is indeed the correct one

Met vriendelijke groet,
Best regards,
Mit freundlichen Grüßen,


Karel Jansseune


Karel Jansseune
 
Bayer BioScience N.V.
Technologiepark 38
B-9052 Gent
Belgium

Ondernemingsnummer: BTW BE 0422 529 921 RPR Gent
E-Mail Karel.Jansseune@...
  URL http://www.bayercropscience.com
   
 




Gluender <[hidden email]>
Sent by: ImageJ Interest Group <[hidden email]>

16/04/2009 11:59

Please respond to
ImageJ Interest Group <[hidden email]>

To
[hidden email]
cc
Subject
Re: setting min, max from histogram





>On Thu, 16 Apr 2009 11:40:00 +0200, Donny George <[hidden email]>
>wrote:
>
>>On Thu, Apr 16, 2009 at 11:27 AM, Gluender <[hidden email]> wrote:
>>
>>>  hello
>>>>
>>>>  i would like to set the min and max values for brightness of an image
>by
>>>>  making some calculations from the values like mean and standard
>deviation
>>>>  obtained from the histogram of the image. i wrote the macro in this way
>>>>
>>>>  run("Brightness/Contrast...");
>>>>     getStatistics(mean, min, max, std, histogram);
>>>>
>>>>     setMinAndMax(mean*0.6666,201);
>>>>
>>>>  and this not work. could somehow help me to successfully modify this.
>>>>
>>>>  thank you one and all for the help in advance
>>>>
>>>>  regards
>>>>
>>>>  --
>>>>  Donny George
>>>>
>>>
>>>
>>>  I've replied to your question immediately after your first post to the
>>>  list.
>>>
>>>  ------------------------
>>>
>>>  Here is my reply again:
>>>
>>>  The macro functions manual says:
>>>  getStatistics(area, mean, min, max, std, histogram)
>>>
>>>  so
>>>
>>>  getStatistics(area, mean);
>>>  print(mean);
>>>
>>>  should do the trick.
>>>
>>>  HTH
>>>  --
>>>
>>>                   Herbie
>>>
>>>          ------------------------
>>>          <http://www.gluender.de>
>>>
>>
>>
>>thankyou and sorry i didnt see ur post earlier
>>
>>i modified it and i could print the values correctly but i am not able to
>>make a calculation with it so that i can modify the brightness
>>
>>run("Brightness/Contrast...");
>>     getStatistics(mean, min, max, std, histogram);
>>     print(""+mean+", "+min+", "+max+", "+std+"");
>>     setMinAndMax("+mean+"*0.6666,201);
>>
>>could you help me with the syntax for the mulplication
>>
>>thnkyou again
>>
>>Donny George
>>=========================================================================
>
>Dear Donny,
>
>changing you code to
>
>setMinAndMax("+getStatistics[mean]+"*0.6666,201);
>
>should do the trick
>
>
>Regards,
>
>Karel

This is a somewhat strange suggestion, did you try it?

--

                  Herbie

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


The information contained in this e-mail is for the exclusive use of the intended recipient(s) and may be confidential, proprietary, and/or legally privileged.  Inadvertent disclosure of this message does not constitute a waiver of any privilege.  If you receive this message in error, please do not directly or indirectly use, print, copy, forward, or disclose any part of this message.  Please also delete this e-mail and all copies and notify the sender.  Thank you.

For alternate languages please go to http://bayerdisclaimer.bayerweb.com


Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

donny008
thankyou everyone for the help

this is how i have it now

run("Brightness/Contrast...");
    getStatistics(pixels, mean, min, max, std, histogram);
    print(""+pixels+""+mean+", "+min+", "+max+", "+std+"");
    setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
    waitForUser("Adjust Brightness/Contrast..., Press (OK)");
    print(""+min+","+max+"");

and even after this has been executed the min and max doesnt seem to chnage.
below i have the log entries in the order of execution

13579225155.1983, 29, 245, 9.5013
29,245

could someone tell me why the min and max are chaging ??

thanks

cheers


--
Donny George
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Gluender-2
>thankyou everyone for the help
>
>this is how i have it now
>
>run("Brightness/Contrast...");
>     getStatistics(pixels, mean, min, max, std, histogram);
>     print(""+pixels+""+mean+", "+min+", "+max+", "+std+"");
>     setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
>     waitForUser("Adjust Brightness/Contrast..., Press (OK)");
>     print(""+min+","+max+"");
>
>and even after this has been executed the min and max doesnt seem to chnage.
>below i have the log entries in the order of execution
>
>13579225155.1983, 29, 245, 9.5013
>29,245
>
>could someone tell me why the min and max are chaging ??
>
>thanks
>
>cheers
>
>--
>Donny George




It is always a good idea to read the ij-manuals:

Perhaps this ij-macro does what you want:

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);

HTH
--

                   Herbie

          ------------------------
          <http://www.gluender.de>
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

donny008
In reply to this post by donny008
On Thu, Apr 16, 2009 at 1:43 PM, Gluender <[hidden email]> wrote:

> thankyou everyone for the help
>>
>> this is how i have it now
>>
>> run("Brightness/Contrast...");
>>    getStatistics(pixels, mean, min, max, std, histogram);
>>    print(""+pixels+""+mean+", "+min+", "+max+", "+std+"");
>>    setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
>>    waitForUser("Adjust Brightness/Contrast..., Press (OK)");
>>    print(""+min+","+max+"");
>>
>> and even after this has been executed the min and max doesnt seem to
>> chnage.
>> below i have the log entries in the order of execution
>>
>> 13579225155.1983, 29, 245, 9.5013
>> 29,245
>>
>> could someone tell me why the min and max are chaging ??
>>
>> thanks
>>
>> cheers
>>
>> --
>> Donny George
>>
>
>
>
>
> It is always a good idea to read the ij-manuals:
>
> Perhaps this ij-macro does what you want:
>
> 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);
>
>
> HTH
> --
>
>                  Herbie
>
>         ------------------------
>         <http://www.gluender.de>
>



thankyou herbie for guiding

since there were so many macros for ij, i didnt know where to begin with but
the guidance from this list definitely helped me out. thankyou to you too

this is how i have it up and running
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+"");


have a nice day
--

Donny George
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Gluender-2
>On Thu, Apr 16, 2009 at 1:43 PM, Gluender <[hidden email]> wrote:
>
>>  thankyou everyone for the help
>>>
>>>  this is how i have it now
>>>
>>>  run("Brightness/Contrast...");
>>>     getStatistics(pixels, mean, min, max, std, histogram);
>>>     print(""+pixels+""+mean+", "+min+", "+max+", "+std+"");
>>>     setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
>>>     waitForUser("Adjust Brightness/Contrast..., Press (OK)");
>>>     print(""+min+","+max+"");
>>>
>>>  and even after this has been executed the min and max doesnt seem to
>>>  chnage.
>>>  below i have the log entries in the order of execution
>>>
>>>  13579225155.1983, 29, 245, 9.5013
>>>  29,245
>>>
>>>  could someone tell me why the min and max are chaging ??
>>>
>>>  thanks
>>>
>>>  cheers
>>>
>>>  --
>>>  Donny George
>>>
>>
>>
>>
>>
>>  It is always a good idea to read the ij-manuals:
>>
>>  Perhaps this ij-macro does what you want:
>>
>>  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);
>>
>>
>>  HTH
>>  --
>>
>>                   Herbie
>>
>>          ------------------------
>>          <http://www.gluender.de>
>>
>
>
>
>thankyou herbie for guiding
>
>since there were so many macros for ij, i didnt know where to begin with but
>the guidance from this list definitely helped me out. thankyou to you too
>
>this is how i have it up and running
>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+"");
>
>
>have a nice day
>--
>
>Donny George

Boy, this won't work as expected!
Why don't you keep with my working example?

BTW you need not search all the example-macros but learn how to use
the macro calls by studying the ij-macro manual at:
<http://rsb.info.nih.gov/ij/developer/macro/functions.html>
--

                   Herbie

          ------------------------
          <http://www.gluender.de>
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

donny008
In reply to this post by donny008
On Thu, Apr 16, 2009 at 5:25 PM, Gluender <[hidden email]> wrote:

> On Thu, Apr 16, 2009 at 1:43 PM, Gluender <[hidden email]> wrote:
>>
>>   thankyou everyone for the help
>>>
>>>>
>>>>  this is how i have it now
>>>>
>>>>  run("Brightness/Contrast...");
>>>>    getStatistics(pixels, mean, min, max, std, histogram);
>>>>    print(""+pixels+""+mean+", "+min+", "+max+", "+std+"");
>>>>    setMinAndMax(mean*0.6666,mean+0.3333*(255-mean));
>>>>    waitForUser("Adjust Brightness/Contrast..., Press (OK)");
>>>>    print(""+min+","+max+"");
>>>>
>>>>  and even after this has been executed the min and max doesnt seem to
>>>>  chnage.
>>>>  below i have the log entries in the order of execution
>>>>
>>>>  13579225155.1983, 29, 245, 9.5013
>>>>  29,245
>>>>
>>>>  could someone tell me why the min and max are chaging ??
>>>>
>>>>  thanks
>>>>
>>>>  cheers
>>>>
>>>>  --
>>>>  Donny George
>>>>
>>>>
>>>
>>>
>>>
>>>  It is always a good idea to read the ij-manuals:
>>>
>>>  Perhaps this ij-macro does what you want:
>>>
>>>  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);
>>>
>>>
>>>  HTH
>>>  --
>>>
>>>                  Herbie
>>>
>>>         ------------------------
>>>         <http://www.gluender.de>
>>>
>>>
>>
>>
>> thankyou herbie for guiding
>>
>> since there were so many macros for ij, i didnt know where to begin with
>> but
>> the guidance from this list definitely helped me out. thankyou to you too
>>
>> this is how i have it up and running
>> 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+"");
>>
>>
>> have a nice day
>> --
>>
>> Donny George
>>
>
> Boy, this won't work as expected!
> Why don't you keep with my working example?
>
> BTW you need not search all the example-macros but learn how to use the
> macro calls by studying the ij-macro manual at:
> <http://rsb.info.nih.gov/ij/developer/macro/functions.html>
>
> --
>
>                  Herbie
>
>         ------------------------
>         <http://www.gluender.de>
>


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
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

Gluender-2
>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>
Reply | Threaded
Open this post in threaded view
|

Re: setting min, max from histogram

donny008
In reply to this post by donny008
On Fri, Apr 17, 2009 at 3:23 PM, Gluender <[hidden email]> wrote:

> 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>
>
hey



ya it was a small mistake wen i put the code is, of course it would have to
be

 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+"");


--
Donny George