This paper proposes a minimal length difference algorithm for construction of a line in an image by solving the problem of optimal contour approximation. In this algorithm, a method for finding interest points is proposed, and the object matching (classification) is done by mapping interest points onto a vector space. In cases where the lines in the representation of the images are not smooth, the algorithm converges rapidly. The results of the experiments showed that for convergence of the contour simplification, there were 5-6 iterations for n = 13. To check how close the curve approximation calculated by the algorithm above, the researchers have calculated the length of the curve simplification manually. This length was then compared to the length of the original curve. The results showed that the length of the simplified curve grew rapidly to 92%-95% of the original curve length. The further increase in the number of points does not affect this indicator. According to the obtained results, the relative difference and the relative difference distance are good metrics to match objects.