The invention discloses a method for automatic segmentation of a defective image. The method comprises the steps that A, image data are clustered through two-layer subtraction clustering; B, arrangement is conducted on center sets from big to small; C, a central point set V is initialized through first c elements; D, an efficiency analysis index of clustering is calculated; E, c=c+1 and an iterative computation is conducted until c>cmax; F, the value of V is determined when FXB (U,V,c) is the least value; G, U is calculated again through the value of V and image segmentation is conducted according to the formula that uik=max{u1k, u2k,...,uck} and xi belongs to the ith type. The method can overcome the shortages of the prior art, automatic segmentation in random walking mode is achieved, the image processing quality is improved, operation time is shortened, and the work efficiency is improved.