★ Set operations on non-negative integers
posted Wed 12 Oct 2011 by Michael Galloy under IDL, OptimizationArrays of non-negative integers are encountered frequently in IDL, e.g., for index arrays and lists of ENVI file IDs to name a couple examples. Since valid data elements are non-negative integers, -1
is used to indicate an empty set. I have a few routines for efficiently computing set unions, intersections, differences, and complements.
For example, suppose I have found the valid data in an image with:
IDL> valid_ind = where(band gt 0.)
And then I find indices of the clouds in the image using my special routine FIND_CLOUD_INDICES
:
IDL> noncloud_ind = find_cloud_indices(band)
Now, if I want to find the indices of the pixels of the image that are valid and not cloud pixels, I can use my MG_SETINTERSECTION
routine:
IDL> valid_ind = mg_setintersection(valid_ind, noncloud_ind)
Download the routines or look at the documentation.