title: Detecting clusters of white pixels in an image using openCV
body: <p>Input Image:
  <img src="https://i.stack.imgur.com/R2TsZ.png" alt="enter image description here"></p>
  
  <p>Expected Output:
  <img src="https://i.stack.imgur.com/k9lMw.png" alt="enter image description here"></p>
  
  <p>I intend to fit three (or some number of)  polygons (for this case, rectangles) to signify the "big" white blobs in this image. The rectangles drawn in the output image are as per my perception of the white regions. I do not expect the algorithm to come up with these same bouding regions. What I wish for is to fit some number of tight polygons around the clusters of white pixels.</p>
  
  <p>My initial solution consisted of finding contours for this image, and fitting a closed convex polygon around each contour, by finding the convex hull of the points in each contour. </p>
  
  <p>However, since the white regions are highly fragmented with black regions within and ridged around the edges, the number of contours returned by cv2.findContours is very high (around 500 or so). Due to this, fitting a convex hull does not improve the shape of the white regions. The white regions mostly retain their original abstract shapes. My goal would be to merge the many small contours of a white region into one whole containing contour over which I can then fit a convex hull.</p>
  
  <p>How do I solve this problem? Should I use a clustering algorithm on the contour points initially to find the contours that are close by each other?</p>