http://imagej.273.s1.nabble.com/TrakEM2-image-Normalization-script-error-tp5004014p5004015.html
I'd use the image filters inside trakem2. See the popup menu at adjust images - image filters.
A.
> Hi all,
>
> I am trying to normalize images in a trakEM2 project to a fixed mean and
> Std. Here is what I have so far;
>
>
> import ij.*;
> import ij.process.*;
> import ij.plugin.filter.*;
> import ij.measure.Measurements;
> import ini.trakem2.display.*;
>
>
> // parameters
> newVar = 44.0;
> newMean = 144.0;
>
> p = Display.getFront().getActive();
> imp = p.getImagePlus();
> ip = imp.getProcessor();
>
> stats = ImageStatistics.getStatistics( ip, Measurements.MEAN +
> Measurements.STD_DEV, null);
>
> fp = ip.convertToFloat();
>
> // subtract mean
> fp.subtract(stats.mean);
>
> // divide by std dev
> fp.multiply(1.0 / stats.stdDev);
>
> // multiply by the new variance
> fp.multiply( newVar );
>
> // add the new mean
> fp.add( newMean );
>
> // convert to byte
> ip = fp.convertToByte( false );
>
> imp.setProcessor( ip );
>
> At the end of the script the selected image does not update to the new
> values. In the BeanShell interpreter, I do not get any errors either. But
> the image remains the same. I checked to see if ip is actually getting
> updated to the new values and it is. I am not sure why this is happening.
>
> Could someone help with this?
>
> Thanks,
> Ashwin
>
>
>
> --
> View this message in context:
http://imagej.1557.x6.nabble.com/TrakEM2-image-Normalization-script-error-tp5004014.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html