Surface defect detection is one of the most widely used research areas in the field of image processing and machine vision. Detection of surface defects is used in visual inspection systems and medical image analysis. In this manuscript, an innovative method for detecting surface defects based on energy changes in co-occurrence matrices is presented in several directions. The method presented in this manuscript includes two stages of learning and testing. In the learning phase, to extract texture features, the gray level co-occurrence matrix operator is applied on the healthy image of the desired level. Then the energy value of the output matrix is calculated. In the following, changes in the amount of energy are considered as statistical characteristics that are a good representative of the image of a healthy surface. Finally, with its help, a suitable threshold for the health of the images is obtained. Then, in the test phase, with the help of the calculated quorum, the defective windows that have suffered from non-normality are distinguished from the healthy surface sections. In the results section, the efficiency of the mentioned method has been measured on medical images and stone and ceramic images, and its detection accuracy has been compared with some previous effective methods. The advantages of the presented method include high accuracy, low calculations and compatibility with all types of levels due to the use of the learning stage. The proposed approach can be used in medical applications to diagnose abnormalities such as diseases. All extracted features are statistical, so its detection speed is higher than deep neural networks.