Development of an algorithm for the analysis of surface defects in mechanical elements