X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



8179 Rate this article:
1.7

How are NaN/Inf values interpreted when calculating statistics in ENVI?

Calculating statistics on images that contain NaN (not-a-number) or Inf (infinity) values can produce different results depending on whether or not a mask is used in the calculation. This Help Article describes why you might get different results when calculating statistics if you do or do not use a mask band, and when it might be necessary to use a mask.

In ENVI, NaN (not-a-number) and Inf (infinity) pixels in an image are ignored when calculating statistics via the /NAN keyword to TOTAL(), MIN(), and MAX(). However, the pixel count is still for the whole image. ENVI does not explicitly calculate how many NaN/Inf pixels there are in the image. Instead it will ignore any that are there. For example,

mean = total(data) / n_elements(data)

which ignores the NaN/Inf pixel values when calculating the total, but the number of pixels used as the divisor includes all pixels (including the pixels containing NaN/Inf values).

However, when you use a mask band to mask out the pixels containing NaN/Inf values, the number of pixels used in the calculation is exactly the number of pixels that are good in the mask (that are turned 'on' or have a value of 1 in the mask). The NaN/Inf pixels are then not included in the calculation, so the difference is essentially:

mean = total(data[ptr]) / n_elements(ptr)

where ptr is the pointer reference that contains the actual number of 'good' pixels to include in the statistics calculation.

If you have a lot of pixels containing NaN/Inf values in your image, then a mask should be used to obtain accurate statistics. If only a few pixels contain NaN/Inf values, the statistics will not be substantially influenced and a mask might not be necessary.

You can build a NaN/Inf mask using ENVI's Masking tool under Basic Tools -> Build Mask.

If your image contains NaN/Inf values, it is likely a mask will be necessary for most other processing in ENVI to obtain accurate results.


Review on 12/31/2013 MM

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »