If floodfill does not provide you with a sufficient mask, another way could be to take the edge image from figure 1 and apply a dilation operator and then a closing operator. The mask will be slightly larger than the original due to the dilation although the dilation helps in closing black spots when applying the closing operator.
This is the result I obtained (I do not have a high enough rep to post the image in the answer. Here is the link): http://tinypic.com/view.php?pic=33jmpao&s=8#.U_cHm_mSz9s
The link below may also be useful to you. http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_morphological_ops/py_morphological_ops.html
The code I used:
// Dilation Mat se = getStructuringElement(CV_SHAPE_ELLIPSE, Size(9, 9)); dilate(edge_image, dst, se, Point(-1,-1), 1); // Closing Mat closed; Mat element = getStructuringElement(MORPH_ELLIPSE, Size(19, 19)); morphologyEx(dst, closed, MORPH_CLOSE, element, Point(-1,-1), 3);
This is my first answer on stackoverflow. I hope it helps and good luck! :)