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 :
Here is the code to get this using OpenCV in Python:
img = cv2.imread(file)
cv2.imshow("orig", img)
cv2.waitKey(0)
img = cv2.blur(img,(2,2))
gray_seg = cv2.Canny(img, 0, 50)
Now, I want to have the below image as the final output after getting only the main object in the image :
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?