'**SUMMARY**
Generate a binary mask of the image based on a range of rgb values.
A binary mask is a black and white image where the white area is kept and the
black area is removed.
This method is used by specifying two colors as the range between the minimum and maximum
values that will be masked white.
**PARAMETERS**
* *color1* - The starting color range for the mask..
* *color2* - The end of the color range for the mask.
**RETURNS**
A binary (black/white) image mask as a SimpleCV Image.
**EXAMPLE**
>>> img = Image("lenna")
>>> mask = img.createBinaryMask(color1=(0,128,128),color2=(255,255,255)
>>> mask.show()
**SEE ALSO**
:py:meth:`createBinaryMask`
:py:meth:`createAlphaMask`
:py:meth:`blit`
:py:meth:`threshold`'

def createBinaryMask(self, color1=(0, 0, 0), color2=(255, 255, 255)):

    if (((color1[0] - color2[0]) == 0) or ((color1[1] - color2[1]) == 0) or ((color1[2] - color2[2]) == 0)):
        logger.warning('No    color    range    selected,    the    result    will    be    black,    returning    None    instead.')
        return None
    if ((color1[0] > 255) or (color1[0] < 0) or (color1[1] > 255) or (color1[1] < 0) or (color1[2] > 255) or (color1[2] < 0) or (color2[0] > 255) or (color2[0] < 0) or (color2[1] > 255) or (color2[1] < 0) or (color2[2] > 255) or (color2[2] < 0)):
        logger.warning('One    of    the    tuple    values    falls    outside    of    the    range    of    0    to    255')
        return None
    r = self.getEmpty(1)
    g = self.getEmpty(1)
    b = self.getEmpty(1)
    rl = self.getEmpty(1)
    gl = self.getEmpty(1)
    bl = self.getEmpty(1)
    rh = self.getEmpty(1)
    gh = self.getEmpty(1)
    bh = self.getEmpty(1)
    cv.Split(self.getBitmap(), b, g, r, None)
    if (abs((color1[0] - color2[0])) == 255):
        cv.Zero(rl)
        cv.AddS(rl, 255, rl)
    elif (color1[0] < color2[0]):
        cv.Threshold(r, rl, color1[0], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(r, rh, color2[0], 255, cv.CV_THRESH_BINARY)
        cv.Sub(rl, rh, rl)
    else:
        cv.Threshold(r, rl, color2[0], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(r, rh, color1[0], 255, cv.CV_THRESH_BINARY)
        cv.Sub(rl, rh, rl)
    if (abs((color1[1] - color2[1])) == 255):
        cv.Zero(gl)
        cv.AddS(gl, 255, gl)
    elif (color1[1] < color2[1]):
        cv.Threshold(g, gl, color1[1], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(g, gh, color2[1], 255, cv.CV_THRESH_BINARY)
        cv.Sub(gl, gh, gl)
    else:
        cv.Threshold(g, gl, color2[1], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(g, gh, color1[1], 255, cv.CV_THRESH_BINARY)
        cv.Sub(gl, gh, gl)
    if (abs((color1[2] - color2[2])) == 255):
        cv.Zero(bl)
        cv.AddS(bl, 255, bl)
    elif (color1[2] < color2[2]):
        cv.Threshold(b, bl, color1[2], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(b, bh, color2[2], 255, cv.CV_THRESH_BINARY)
        cv.Sub(bl, bh, bl)
    else:
        cv.Threshold(b, bl, color2[2], 255, cv.CV_THRESH_BINARY)
        cv.Threshold(b, bh, color1[2], 255, cv.CV_THRESH_BINARY)
        cv.Sub(bl, bh, bl)
    cv.And(rl, gl, rl)
    cv.And(rl, bl, rl)
    return Image(rl)
