1. A method of automatically replacing undesirable pixels in an image, said method comprising: identifying a local neighborhood of pixels around an undesirable pixel; identifying secondary neighborhoods of pixels; calculating feature values of the pixels contained in the local neighborhood and each of the secondary neighborhoods; classifying the secondary neighborhoods having feature values within a predetermined range of the local neighborhood feature value as candidates for pixel value replacement; determining a replacement pixel value from at least one of the secondary neighborhoods classified as a candidate for pixel value replacement; and replacing, by an electronic apparatus, the undesirable pixel value with the replacement pixel value.