1. A method for detecting anomalies in a new image, the method comprising: partitioning each image of a set of images into a plurality of local units; clustering all the local units in the set of images into clusters; assigning class labels to the local units based on a clustering result from clustering the local units, the local units with identical class labels having at least one substantially related image feature; assigning a weight to each of the local units based on a variation of the class labels across all images in the set of images; and categorizing the new image as anomalous based on the weight assigned to the local units.