How to adjust the brightness/contrast in Java

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

How to adjust the brightness/contrast in Java

Avital Steinberg
Hi,
In the graphical user interface of Fiji, it's very easy to adjust the
brightness/contrast automatically (or. to use window/level). However, when
I tried using java for this purpose, using the following code:

        ImagePlus imp = IJ.getImage();
        ImageProcessor ip = imp.getProcessor();

        ImageConverter ic = new ImageConverter(imp);
        ic.convertToGray8();
        ip.smooth();
        BackgroundSubtracter bgs = new BackgroundSubtracter();
        bgs.rollingBallBackground(ip, 50.0,false, false, false, true,
true);
        ContrastEnhancer ce = new ContrastEnhancer();
        ce.stretchHistogram(ip,0.5);
        imp.updateAndDraw();

It didn't do the same thing, and some of the images were not processed the
way I want. How would I do this in Java?

Thank you,
Avital

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html