Login  Register

Re: PlugInFilter CONVERT_TO_FLOAT Field

Posted by Michael Schmid on Mar 20, 2009; 11:16am
URL: http://imagej.273.s1.nabble.com/Missing-Classes-for-CallJavaDemo-tp3693236p3693238.html

Hi Joachim,

you are right, PlugInFilter.CONVERT_TO_FLOAT does not care about the  
calibration. The flag is meant for filtering operations such as  
convolution, smoothing etc.
When doing such an operation directly on 8-bit or 16-bit data one  
would not convert them to calibrated values before doing the  
conversion and convert them back to 8 or 16 bits after the operation,  
so it is the same behavior.

If you need calibrated values, I'd suggest not using CONVERT_TO_FLOAT  
but rather ip.getPixelValue(x,y), which returns the calibrated value.  
There will be a significant difference on RGB images, however: With  
CONVERT_TO_FLOAT, the run(ip) method is called 3 times with the color  
channels (for filtering of all the colors); with ip.getPixelValue you  
get a (weighted) average of the color channels (weighted depends on  
Edit>Options> Conversion).

---

A FloatProcessor cannot have a calibration.

Hope this helps,

Michael
________________________________________________________________

> From: Joachim Wesner
>
> Hi list,
>
> while updating some plugin of mine, I noted something:
>
> Usually, if you have an (non-float) ImageProcessor, that has a  
> calibration
> attached, that calibration will be automatically applied, when you do
> ImageProcessor.convertToFloat().
>
> (BTW, can a FloatProcessor have an extra calibration??)
>
> Now, If you want your PlugInFilter not need to fiddle with the  
> details of
> non-float input formats, you can set CONVERT_TO_FLOAT in the return  
> to the
> setup()
> method. However, that´s what I noted, it seem that this flag will  
> NOT apply
> any calibration of the input processor!
>
> So, question, what to do. Probably the current behaviour should not be
> changed, but an extra bit-field could be defined, that, when set, also
> causes the
> calibrated conversion!?
>
> Or, leave everthing as is, do NOT use CONVERT_TO_FLOAT if  
> calibration is
> important and add only a little bit of code like:
>
>             float calib[] = ip.getCalibrationTable();
>             ip = ip.duplicate();
>             ip.setCalibrationTable(calib);
>             if (!(ip instanceof FloatProcessor))
>                   ip = ip.convertToFloat();
>
> (The duplication in the code below can even be optimized away in  
> most cases
> and would only be needed
> if the input is ALREADY float, as the filter promises not to change  
> the
> input data...)
>
>
> Any suggestions?
>
>
> Mit freundlichen Grüßen / Best regards
>
> Joachim Wesner
>
> Leica Microsystems CMS GmbH | GmbH mit Sitz in Wetzlar | Amtsgericht
> Wetzlar  HRB 2432
> Geschäftsführer:  Dr. Stefan Traeger | Dr. Wolf-Otto Reuter | Dr.  
> David Roy
> Martyr | Colin Davis
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________