title: How do I apply dilation selectively using OpenCV?
body: <p>Actually, I want five external bounding boxes for the "white" pixels on the following binary image. Desired zones are highlighted with red color.</p>
  
  <p>To get 5th bounding box I'd dilate or blur it. However, dilation will merge zone 3 with zones 1 and 2, so I'll get a bounding box which covers almost entire image. (If I don't dilate or blur it, then <a href="http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#findcontours" rel="nofollow noreferrer"><code>cv::findContours</code></a> + <a href="http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#boundingrect" rel="nofollow noreferrer"><code>cv::boundingRect</code></a> will produce a big number of small rectangles.)</p>
  
  <p>In other words, I want only "big enough" bounding boxes.</p>
  
  <p><img src="https://i.stack.imgur.com/WoXaA.jpg" alt="Binary image"></p>
  
  <p>It's just a sample pattern. Positions of the zones may vary. Is there a way to solve the problem in a general way?</p>