1 | initial version |
A morphological open with a small kernel to remove all small speckles
Find the largest closed contour and fit a convex hull around it.
Fill the convex hull with white, while the background is black
Use the binary mask from step 3 and copy the contents of the original image onto an all white image using the binary mask as reference.
Original_Image.copyTo(All_White_Image,Binary_Mask)