It is difficult to detect simultaneously both the local defects such as scratch and the global defects such as obscure dirt with sufficient sensitivity by image processing. In order to solve such a problem, a method for detecting globally distributed defects by using learning with Mahalanobis distance is proposed in this paper. First, n-dimensional hierarchical average processing is performed in a image, and the n-dimensional feature space is parallelly defined corresponding to all pixels of the image. Through this procedure, the information with more global circumstances could be included in each pixel as the dimension goes up. Continuously, if the training sample image is learned by using this n-dimensional feature space, the super-boundary surface given by the equal discriminant with the Mahalanobis distance in n-dimensional feature space of each pixel will become a super-ellipse. Then both the local defects such as scratch and global defects such as obscure dirt or stain are simultaneously detected with high sensitivity by using the discriminant super-boundary surface.