The result of the function matchTemplate is represented by the image matchTemplate4096.jpg. For the function, matchTemplate chose different methods, selected the best result. The image clearly shows different “luminous” points from the background: 8 points in one series, 32 series in one line, a total of 16 series lines - that is, a total of 4096 points. In the program:

```
for (int i = 115; i < 121; i++)
{
threshold(img, dst_tresh, i, 255, THRESH_BINARY);
int nccomps = connectedComponentsWithStats(dst_tresh, labels_tresh, stats_tresh, centroids_tresh);
out << i << '\t' << nccomps << endl;
imwrite(to_string(i) + "_" + to_string(nccomps) + "_" + fileName, dst_tresh);
}
```

using connectedComponentsWithStats I try to match the threshold value and correctly determine the number of points. None of the results match the number of points counted manually. The closest result is achieved at a threshold of 118-4095 points. However, in the lower right row I see 3 extraneous points, and in the first, second and fourth vertical rows of points some points are absent. Please tell me what OpenCV features can be used to improve the accuracy of determining the number of points in an image. The project project is referenced CppOpenCVstudy.zip — Яндекс.Диск