Login  Register

Re: Replace NaN in 32-bit images with 0

Posted by Michael Schmid on Mar 23, 2011; 5:40pm
URL: http://imagej.273.s1.nabble.com/Replace-NaN-in-32-bit-images-with-0-tp3685307p3685308.html

Hi anonymous,

this may look stupid, but it works at least with the NaN created by  
division by zero:
Enter in the Process>Math>Macro
     if (!(v<1) && !(v>0)) v=0;

A NaN value fulfills no inequality; all 'true' numbers are either <1  
or >0 or both.
Of course, a macro function 'isNaN(value)' would be nice to have...

Michael
________________________________________________________________

On 23 Mar 2011, at 18:03, mjlm wrote:

> Hi there,
>
> Is there a simple way to "reset" all pixels with the value "NaN" to a
> specified numeric value, e.g. 0?
>
> I couldn't find a way to do this properly in ImageJ...one ugly  
> workaround I
> came up with is to save the image as text and then simply find &  
> replace all
> occurences of NaN, but that's not a feasible option for large  
> stacks...there
> MUST be a better way.
>
> Thanks!