'**SUMMARY**
This method acts like findBlobs, but it lets you specifiy blobs directly by
providing a mask image. The mask image must match the size of this image, and
the mask should have values > threshold where you want the blobs selected. This
method can be used with binarize, dialte, erode, floodFill, edges etc to
get really nice segmentation.
**PARAMETERS**
* *mask* - The mask image, areas lighter than threshold will be counted as blobs.
Mask should be the same size as this image.
* *threshold* - A single threshold value used when we binarize the mask.
* *minsize* - The minimum size of the returned blobs.
* *maxsize*  - The maximum size of the returned blobs, if none is specified we peg
this to the image size.
* *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.
**RETURNS**
A featureset of blobs. If no blobs are found None is returned.
**EXAMPLE**
>>> img = Image("Foo.png")
>>> mask = img.binarize().dilate(2)
>>> blobs = img.findBlobsFromMask(mask)
>>> blobs.show()
**SEE ALSO**
:py:meth:`findBlobs`
:py:meth:`binarize`
:py:meth:`threshold`
:py:meth:`dilate`
:py:meth:`erode`'

def findBlobsFromMask(self, mask, threshold=128, minsize=10, maxsize=0, appx_level=3):

    if (maxsize == 0):
        maxsize = (self.width * self.height)
    if ((mask.width != self.width) or (mask.height != self.height)):
        logger.warning('ImageClass.findBlobsFromMask    -    your    mask    does    not    match    the    size    of    your    image')
        return None
    blobmaker = BlobMaker()
    gray = mask._getGrayscaleBitmap()
    result = mask.getEmpty(1)
    cv.Threshold(gray, result, threshold, 255, cv.CV_THRESH_BINARY)
    blobs = blobmaker.extractFromBinary(Image(result), self, minsize=minsize, maxsize=maxsize, appx_level=appx_level)
    if (not len(blobs)):
        return None
    return FeatureSet(blobs).sortArea()
