One of the Operators introduced with ERDAS IMAGINE 2016 was the Iterator operator. An Iterator is basically a sub-model, however the difference is that the sub-model is going to be executed n times before proceeding further into the model. The number of executions, n, is controlled by inputting to the Iterator a List. The number of entries in the List determines how many times the sub-model iterates and the values in the list are (generally) the main values used in each run of the iterations. Iterating in this fashion is useful in numerous instances and this Article is the first of several that will look at examples of using the Iterator.
This Model applies a filter to an image, a user-definable number of times, incrementally. This specific example approximates an Eliminate process to fill in holes (of class 0, produced by a Clump and Sieve process) with class values from surrounding pixels, by applying a Majority filter only at pixels of Class 0 and excluding Class 0 from the Majority calculation.
|Left View shows the original landcover classification, middle shows the results of Sieving (background set to green) and the right shows the result after running the Model to fill in the background "holes"|
To do this the Model makes use of two Iterator operators. The first iteration builds a list of “inputs” consisting of the original input image plus n-1 temporary filenames. The second Iterator then applies the filter n times, starting with the first image in the list and writing the output to the next (temp) filename in the list, and then repeating with that output as the next input. After the nth application of the filter the Model writes out the image that's last in the list. The incremental nature of applying the Majority filter "fills in" the DN 0 holes.
Screenshot below shows the contents of the "Iterator" sub-model which builds the Lists of input and output filenames
Screenshot below shows the contents of the "Iterator 2" sub-model which applies the Majority filter
The Preview option enables the user to experiment with the Count value until all holes are filled. Once a good Count has been determined the model can be Run to an output file.
Because of the use of several newly introduced Operators (including Iterator) this Model requires ERDAS IMAGINE 2016 or later to run.