Re: Replace NaN in 32-bit images with 0
Posted by
BenTupper on
Mar 23, 2011; 5:46pm
URL: http://imagej.273.s1.nabble.com/Replace-NaN-in-32-bit-images-with-0-tp3685307p3685313.html
Hi,
On Mar 23, 2011, at 1:03 PM, 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?
>
A simple way is to use this macro...
newValue = 0.0;
counter = 0;
for (y = 0; y < getHeight(); y++){
for (x = 0; x < getWidth(); x++){
p = getPixel(x,y);
if (isNaN(p)) {
setPixel(x, y, newValue);
counter++;
}
}
}
print("" + counter + " pixels replaced");
Cheers,
Ben
> 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!
>
> --
> View this message in context:
http://imagej.588099.n2.nabble.com/Replace-NaN-in-32-bit-images-with-0-tp6201020p6201020.html> Sent from the ImageJ mailing list archive at Nabble.com.