1. A device comprising a plurality of elements, including logical elements, wherein the elements are configured to perform the operations of: in a neighborhood of pixels surrounding and including a particular pixel, applying a filter to multiple groups of pixels in the neighborhood to generate a set of filtered values; generating, based at least in part upon the set of filtered values, one or more sets of gradient values, wherein each set of gradient values reflects changes in the set of filtered values in a particular direction; based at least in part upon the one or more sets of gradient values, computing a gradient improvement (GI) metric for the particular pixel, wherein the GI metric indicates whether the particular pixel is situated in an image environment in which changes in filtered values are gradual and monotonic.