Login  Register

Trying to set a calibration table in plugin

Posted by Charles Brossollet on Apr 17, 2009; 1:09pm
URL: http://imagej.273.s1.nabble.com/Trying-to-set-a-calibration-table-in-plugin-tp3692898.html

Dear list,

I have 16 bits images, and I want to make computations on pixels and  
display the result for each pixel as I point the mouse. So the  
calibration table is perfect for this. I wrote a small plugin that  
takes sets the calibration table that I want, but it doesn't work: no  
error, but the calibrated value doesn't show in the status bar, as if  
the calibration was not active.

I use Fiji (1.42e) on Mac OS X 10.5.6

Here is the code:
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.filter.*;

public class Show_Power implements PlugInFilter {
        ImagePlus imp;

        public int setup(String arg, ImagePlus imp) {
                this.imp = imp;
                return DOES_16+DOES_STACKS;
        }

        public void run(ImageProcessor ip) {
                float[] cTable = new float[65536];
                for (int i=0; i<65536; i++)
                {
                        float i_f=1.f;
                        if (i>32768)
                                i_f=(float)(i-32768);
                        cTable[i]=10*(2*log10(i_f)+log10(0.2f)-10.51f) ;
                }
                ip.setCalibrationTable(cTable);
               
                imp.updateAndDraw();
        }
       
        private float log10(float x)
        {
          if (x > 0.0)
            return (float)(Math.log((double)(x)) / Math.log(10.));
          else
            return Float.NEGATIVE_INFINITY;
        }
}

Any help appreciated!
Thanks,

Charles