<p>Pixels of an image (200) are coded as color vectors specified by RGB values. The image (200) is filtered by calculating new color vectors for the pixels on a pixel by pixel basis. A new color vector for a subject pixel (201) is calculated from the average of neighbor pixels (203) in a window (202) around the subject pixel (201). A first threshold is calculated from the standard deviation of the color vectors of the neighbor pixels (203) in the window (202). A second threshold is calculated from the median maximum difference between the values defining the color vectors of the respective neighbor pixels (203) in the window (202) and the standard deviation of the values. Only neighbor pixels (203) having a color vector that differs from the color vector of the subject pixel (201) by less than or the same as the first and second thresholds are used in calculation of the new color vector for the subject pixel (201).</p>