Function to extract image from white background

Extract image from white background by thresholding and then finding the
bounding box of the contours.