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. Licensing an IDL ActiveX control with an embedded IDL key How to determine whether or not an IDL program is running in the IDL Virtual Machine