The invention discloses a textile defect detecting algorithm based on texture gradients. Firstly, texture gradients of sub-band characteristics after wavelet transformation are calculated, marked watershed segmentation is carried out on a texture gradient image, and a textile defect detecting system based on the texture gradients is primarily finished; secondly, non-local average filtering is utilized to eliminate imaging noise in a textile image and influences of other uncorrelated details, useful texture details are highlighted, preprocessing is completed, and texture enhancement is achieved; at last, on the bases of the texture enhancement and the texture gradients, an MRF model is utilized to extract a defect zone boundary, texture defects can also be well extracted by means of the method, and the defect that in watershed marking, a threshold value needs to be chosen manually is eliminated. The textile defect detecting algorithm based on the texture gradients has the advantages of being capable of rapidly and accurately distinguishing defects of textiles and wide in application, improving the quality of the textiles, and the like.