title: Split objects from image using opencv
body: <p>I have a bunch of images like the following:
  <a href="https://resultados2019.registraduria.gov.co/assets/img/logo/1305.png" rel="nofollow noreferrer">https://resultados2019.registraduria.gov.co/assets/img/logo/1305.png</a></p>
  
  <p>I would like to split the party logos of each image, in this case, two separate images.</p>
  
  <p>I tried using the contours but there are many contours within each logo so I don´t know which could be a better alternative to separate the logos from this image. Sometimes there can be more than two logos as for example in this image: <a href="https://resultados2019.registraduria.gov.co/assets/img/logo/1566.png" rel="nofollow noreferrer">https://resultados2019.registraduria.gov.co/assets/img/logo/1566.png</a></p>
  
  <pre><code>web="https://resultados2019.registraduria.gov.co/assets/img/logo/1305.png"
  urlretrieve(web, "nombre.jpg")
  
  original_image = cv2.imread("nombre.jpg")
  image = original_image.copy()
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  blurred = cv2.GaussianBlur(gray, (3, 3), 0)
  canny = cv2.Canny(blurred, 120, 255, 1)
  
  # Find contours in the image
  cnts = cv2.findContours(canny.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  cnts = cnts[0] if len(cnts) == 2 else cnts[1]
  </code></pre>