1. A method, comprising: performing by a computer: receiving an image to which a filter is to be applied, wherein the image comprises a plurality of pixels each having a respective pixel value; and applying the filter to a first pixel in the image, wherein the filter comprises a spatial filter and a range filter, and wherein said applying comprises: applying the spatial filter, wherein said applying the spatial filter comprises selecting a first region of pixels within the image, wherein the first region contains a plurality of pixels including the first pixel; determining a first range of pixel values including the pixel value for the first pixel, wherein the first range is greater than a range of pixel values on which the range filter operates; generating a first histogram using pixels within the first region whose respective pixel values are within the first range of pixel values, wherein the first histogram comprises a plurality of bins, wherein each bin represents a frequency of pixels within the first region having pixel values corresponding to that bin, wherein pixels within the first region whose respective pixel values are not within the first range of pixel values are not represented in the first histogram; and determining a new value for the first pixel using the first histogram, wherein said determining the new value comprises applying the range filter to the first histogram centered on the pixel value in the histogram corresponding to the first pixel.