title: Crop Image from all sides after edge detection
body: <p>I am new to OpenCV. I want to extract the main object from an image. So, I have applied Canny on the image to get the edges around the main object and got the following output :
  <a href="https://i.stack.imgur.com/r0FHs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/r0FHs.png" alt="enter image description here"></a></p>
  
  <p>Here is the code to get this using OpenCV in Python:</p>
  
  <pre><code>img = cv2.imread(file)
  cv2.imshow("orig", img)
  cv2.waitKey(0)
  img = cv2.blur(img,(2,2))
  gray_seg = cv2.Canny(img, 0, 50)
  </code></pre>
  
  <p>Now, I want to have the below image as the final output after getting only the main object in the image :
  <a href="https://i.stack.imgur.com/Qz1jD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Qz1jD.png" alt="enter image description here"></a></p>
  
  <p>I want to do it in an optimized manner because I have to process more that 2.5 million images.
  Can anyone help me with this?</p>