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, two 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 two or more sets of gradient values, computing a first metric for an image environment in which the particular pixel is situated, wherein the first metric distinguishes between an edge environment, in which changes in filtered values are steep, and a gradient environment, in which changes in filtered values are gradual; based at least in part upon the two or more sets of gradient values, determining a second metric for the image environment in which the particular pixel is situated, wherein the second metric distinguishes between a detail environment, in which changes in gradient values are chaotic, and a gradient environment, in which changes in gradient values are monotonic; wherein changes in gradient values are chaotic if there is a large number of directional changes in the gradient values; and wherein changes in gradient values are monotonic if there is a small number of directional changes in the gradient values; and based at least in part upon the first metric and the second metric, computing a gradient improvement (GI) metric for the particular pixel, wherein the GI metric indicates whether the particular pixel is situated in a gradient environment in which changes in filtered values are gradual and changes in gradient values are monotonic.