Login  Register

Antwort: Re: How to call "Contrast Enhancer" from Java plugin

Posted by Joachim Wesner on Sep 08, 2009; 5:30pm
URL: http://imagej.273.s1.nabble.com/How-to-call-Contrast-Enhancer-from-Java-plugin-tp3691264p3691266.html

Hi Wayne,

thanks for the hint, I now understand the difference between IJ.run and
IJ.runPlugIn!

However, this seems to reveal some bug in the contrast enhancer:

If you look in the sourecode of the "B&C" window, you see that the "Auto"
button that I would like to use has it´s own built-in contrast enhancer
which seems to work fine. HOWEVER, it records

      run("Enhance Contrast", "saturated=0.5");

instead! What I find with my data that there seems to be a bug in the true
ContrastEnhancer, the result is NOT the same and depends strongly on the %
value given, for 0.1 there is practically no
effect, while 0.5 percent leads to a strongly asymmetrical  clipping of
much more than 0.5%!

I will send you a test image (float) by personal mail, you should use B&C
Auto and Enhance Contrast 0.5 on it to see the difference!

Sincerely

Mit freundlichen Grüßen / Best regards

Joachim Wesner




                                                                           
             Wayne Rasband                                                
             <[hidden email]>                                                
             Gesendet von:                                              An
             ImageJ Interest            [hidden email]                
             Group                                                   Kopie
             <[hidden email].                                            
             GOV>                                                    Thema
                                        Re: How to call "Contrast          
                                        Enhancer" from Java plugin        
             08.09.2009 17:59                                              
                                                                           
                                                                           
              Bitte antworten                                              
                    an                                                    
              ImageJ Interest                                              
                   Group                                                  
             <[hidden email].                                            
                   GOV>                                                    
                                                                           
                                                                           




  > HI,
  >
  > I would  like to use the "ContrastEnhancer" class/plugin
  > from my own plugin.
  >
  > After some fiddling around I thought the correct call might be
  >
  > IJ.runPlugIn(imp, "ij.plugin.ContrastEnhancer", "saturated=.1");
  >
  > which runs the enhancer plugin up to the dialog window, but
  > does not process the argument string, but wants the user to
  > enter values and press OK.
  >
  > What is the right way to do it? Or is there a more direct way
  > to call the enhancer class? THANX!

Run the Process>Enhance Contrast command with the command recorder
(Plugins>Macros>Record) running and you get this macro call:

      run("Enhance Contrast", "saturated=0.1");

To convert it into a method that can be called from a plugin, change
"run" to "IJ.run" and add an argument that passes an ImagePlus object:

      IJ.run(imp, "Enhance Contrast", "saturated=0.1");

-wayne



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________