Hexagon Geospatial
MENU

Spatial Modeler Tutorials

Learn more about our products, find answers, get the latest updates, and connect with other Hexagon Geospatial product users, or get support from our professional service team.
Showing results for 
Search instead for 
Do you mean 

How to Ignore a Range of Values when Calculating Statistics

by Technical Evangelist ‎11-11-2016 01:19 PM - edited ‎03-27-2018 01:41 PM (1,123 Views)

Download model

 

Description:

 

A request was submitted to Support asking for a way in ERDAS IMAGINE to ignore a range of values when calculating image statistics. When using ImageInfo (View/Edit Image Metadata) or the Image Commands tool (Edit Image Metadata) you can identify a single value to be ignored. This is usually 0, but it could be any value representing the "background" value of the image.

 

However there are cases when more than a single value should be ignored. One of the most common cases is with imagery that has been compressed using a lossy compression technique and a software package (or format) which does not maintain a NoData (or opacity) mask separate from the data bands themselves. When imagery is lossilly compressed, background areas that were originally all 0s might become a mixture of 0s, 1s, 2s, etc. In these cases it is beneficial for image display purposes to ignore several values in the statistics of the image.

 

Consequently this Spatial Model was put together to provide a "model snippet" showing how to use a Table to specify more than a single value to feed to the Ignore port of the Statistics operator. This can be embedded into a larger model to ensure that the output imagery has statistics created in the desired fashion.

 

 stats_ignore_range_v16_1_0.gmdx
 Ignore_Range.PNG

 

 

This model was put together as a quick example of how you might use the technique. As provided, the expectation is that the user enters a value in the Less Than prompt which means that all DN values below that value will be excluded from the statistics calculation. In the example shown in the screenshot above, the Less Than value entered was 100. The input images did have pixels with DN values below this value, but interestingly it then had no pixels with DNs between 100 and 117, so the Minimum statistics value, having ignored all values less than 100, was 117.

 

The model works by dynamically constructing a Table with as many rows as the Less Than value, with values that start at 0 and increment by 1 in each subsequent row. I..e if I enter a Less Than value of 100, the model constructs a Table with 100 rows with values starting at 0 and going through to 99 on the last row. This Table is fed to the Ignore port of the Statistics operator so that all hundred values are ignored in the image statistics that are created.

 

By feeding the Raster stream through the Statistics operator itself and using the Raster Out port to then directly feed the Raster Output operator, the statistics created in the Statistics Operator are written directly into the header of the output image file (rather than the statistics being calculated on the output file as the normal post-processing step of raster file creation). If you embed this technique into a larger model remember to retain this positioning and linkage of the Statistics operator and the Raster Output to which you wish to associate the statistics.

 

It is also very easy to modify the model to cater to different "ignore" needs. Need to ignore all values greater than or equal to a specific value? Just change the Dynamic Table Input (Series) operator so that the Initial Value is the greater than value. Need to ignore discrete values (0, 5, 11, etc)? Replace the Dynamic Table Input (Series) operator with a Custom Table Input operator and define it to contain those values. Using Signed Integer data? Adjust the Initial Value appropriately. Etc.

 

One limitation of this model is that it relies on there being an output image file being created. In ERDAS IMAGINE 2016 v16.1 (or earlier) you cannot perform this task on an existing image file. However in ERDAS IMAGINE 2017 there will be an Update Statistics operator (or similar) which will enable this technique to be applied to existing image files.

 

Input parameters:

 

Input Image: Name of the input image file for which new statistics will be generated. The default is for IMG format files, but the File Chooser can be used to select from many different raster formats.

Less Than: The value below which values will be ignored. This assumes unsigned integer values, so if the value entered is 3, the values 0, 1 and 2 will be ignored.

Output Image: Name of the new output image file with statistics.

 

 Run dialog for the pre-built model:
 Ignore_Range_Run.PNG

   

 

 Update 27th March, 2018

 

Using new capabilites provided in ERDAS IMAGINE 2018 I've enhanced the model to update the original Input Image file, rather than needing to produce a new output file. This obviously saves time and disk space. 

 

Download stats_ignore_range_v16_5_0.zip

 

stats_ignore_range_v16_5_0.gmdx
statistics_model.PNG
Courses
Contributors