This paper describes a robust segmentation algorithm for the detection and localization of woven fabric defects. The essence of the presented segmentation algorithm is the localization of those events (i.e., defects) in the input images that disrupt the global homogeneity of the background texture. To this end, preprocessing modules, based on the wavelet transform and edge fusion, are employed with the objective of attenuating the background texture and accentuating the defects. Then, texture features are utilized to measure the global homogeneity of the output images. If these images are deemed to be globally nonhomogenous (i.e., defects are present), a local roughness measure is used to localize the defects. The utility of this algorithm can be extended beyond the specific application in our work, that is, defect segmentation in woven fabrics. Indeed, in a general sense, this algorithm can be used to detect and to localize anomalies that reside in images characterized by ordered texture. The efficacy of this algorithm has been tested thoroughly under realistic conditions and as a part of an on-line fabric inspection system. Using over 3700 images of fabrics, containing 26 different types of defects, the overall detection rate of our approach was 89% with a localization accuracy of less than 0.2 inches and a false alarm rate of 2.5%.