# How to remove all dots and also fill the whole 3 blocks from this binary image?

Hi everyone, I want to get rid of these white dots and also have 3 continuous blocks of white (see the image, there are 3 areas with a majority of white pixels, but also a few black ones).

I have tried the opening moph operation, i get rid of the white dots, but the three blocks I want them to be continous, are getting even worse, meaning that those 3 blocks have more black pixels than before, and I need them to be fully white. Again, i need to remove only the small white dots outside the 3 blocks and to have the 3 blocks fully white, or as much as possible.

cv::Mat structElem = getStructuringElement(cv::MORPH_CROSS, cv::Size(3, 3));
morphologyEx(neaut_vect_MAT_nou, imaOut, cv::MORPH_OPEN, structElem);


I have discovered some other suggestions with findContours and drawContours , but i do not understand how to use them. I want to mention that i need a solution in C++. Can you help me?

Many thanks!

edit retag close merge delete