'This method performs blob extraction given a binary source image that is used
to get the blob images, and a color source image.
binarymg- The binary image with the blobs.
colorImg - The color image.
minSize  - The minimum size of the blobs in pixels.
maxSize  - The maximum blob size in pixels.
* *appx_level* - The blob approximation level - an integer for the maximum distance between the true edge and the approximation edge - lower numbers yield better approximation.'

def extractFromBinary(self, binaryImg, colorImg, minsize=5, maxsize=(-1), appx_level=3):

    sys.setrecursionlimit(5000)
    if (maxsize <= 0):
        maxsize = (colorImg.width * colorImg.height)
    retVal = []
    test = binaryImg.meanColor()
    if ((test[0] == 0.0) and (test[1] == 0.0) and (test[2] == 0.0)):
        return FeatureSet(retVal)
    ptest = ((4 * 255.0) / (binaryImg.width * binaryImg.height))
    if ((test[0] <= ptest) and (test[1] <= ptest) and (test[2] <= ptest)):
        return retVal
    seq = cv.FindContours(binaryImg._getGrayscaleBitmap(), self.mMemStorage, cv.CV_RETR_TREE, cv.CV_CHAIN_APPROX_SIMPLE)
    if (not list(seq)):
        warnings.warn('Unable    to    find    Blobs.    Retuning    Empty    FeatureSet.')
        return FeatureSet([])
    try:
        retVal = self._extractFromBinary(seq, False, colorImg, minsize, maxsize, appx_level)
    except RuntimeError as e:
        logger.warning('You    exceeded    the    recursion    limit.    This    means    you    probably    have    too    many    blobs    in    your    image.    We    suggest    you    do    some    morphological    operations    (erode/dilate)    to    reduce    the    number    of    blobs    in    your    image.    This    function    was    designed    to    max    out    at    about    5000    blobs    per    image.')
    except e:
        logger.warning('SimpleCV    Find    Blobs    Failed    -    This    could    be    an    OpenCV    python    binding    issue')
    del seq
    return FeatureSet(retVal)
