Login  Register

ContrastEnhancer stretchHistogram doubt

Posted by Zian_Fanti on Oct 06, 2010; 3:56pm
URL: http://imagej.273.s1.nabble.com/ContrastEnhancer-stretchHistogram-doubt-tp3686702.html

Hello, i try to made a plugin to do some operations between images and then
auto adjust the brigth and contrast. For the latter I use the function
stretchHistogram in the class ContrastEnhancer. The resulting image is
displayed correctly (with the brigth and contrast enhanced) but the pixels
value don't change. The question is how can apply the enhance in the pixels
vlues? I figured out I Have to do some update or something like that, but I
can't find how.

This is the code:

ImageProcessor subtracted = imp_1.getProcessor().duplicate();
ImageProcessor ip_2 = imp_2.getProcessor();
subtracted.copyBits(ip_2, 0, 0, Blitter.SUBTRACT);

ContrastEnhancer enhancer = new ContrastEnhancer();
enhancer.stretchHistogram(subtracted, 0.5);
ImagePlus imp_3 = new ImagePlus(null, subtracted);
imp_3.show();