First time here? Check out the FAQ!
answered 2017-10-10 07:23:50 -0600
Yes using closing or openning does not solve your problem.
You can try connectedComponentsWithStat and use gravity center to look for nearest neighbours. Then you can can fixed a distance threshold to connect components.