title: How to remove small connected objects using OpenCV
body: <p>I use OpenCV and Python and I want to remove the small connected object from my image.</p>
  
  <p>I have the following binary image as input:</p>
  
  <p><a href="https://i.stack.imgur.com/cQMZm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cQMZm.png" alt="Input binary image"></a></p>
  
  <p>The image is the result of this code:</p>
  
  <pre><code>dilation = cv2.dilate(dst,kernel,iterations = 2)
  erosion = cv2.erode(dilation,kernel,iterations = 3)
  </code></pre>
  
  <p>I want to remove the objects highlighted in red:</p>
  
  <p><a href="https://i.stack.imgur.com/wc3BY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wc3BY.png" alt="enter image description here"></a></p>
  
  <p>How can I achieve this using OpenCV?</p>