I have the following image mask:
I want to apply something similar to cv::findContours, but that algorithm only joins connected points in the s
I suggest to use DBSCAN algorithm. It is exactly what you are looking for. Use a simple Euclidean Distance or even Manhattan Distance may work better. The input is all white points(threshold-ed). The output is a groups of points(your connected component)
Here is a DBSCAN C++ implenetation
EDIT: I tried DBSCAN my self and here is the result:
As you see, Just the really connected points are considered as one cluster.
This result was obtained using the standerad DBSCAN algorithm with EPS=3 (static no need to be tuned) MinPoints=1 (static also) and Manhattan Distance