'**SUMMARY**
This method uses the color palette to generate a binary (black and white) image. Palaette selection
is a list of color tuples retrieved from img.getPalette(). The provided values will be drawn white
while other values will be black.
**PARAMETERS**
palette_selection - color triplets selected from our palette that will serve turned into blobs
These values can either be a 3xN numpy array, or a list of RGB triplets.
**RETURNS**
This method returns a black and white images, where colors that are close to the colors
in palette_selection are set to white
**EXAMPLE**
>>> img = Image("lenna")
>>> p = img.getPalette()
>>> b = img.binarizeFromPalette( (p[0],p[1],[6]) )
>>> b.show()
**SEE ALSO**
:py:meth:`rePalette`
:py:meth:`drawPaletteColors`
:py:meth:`palettize`
:py:meth:`getPalette`
:py:meth:`binarizeFromPalette`
:py:meth:`findBlobsFromPalette`'

def binarizeFromPalette(self, palette_selection):

    if (self._mPalette == None):
        logger.warning('Image.binarizeFromPalette:    No    palette    exists,    call    getPalette())')
        return None
    retVal = None
    img = self.palettize(self._mPaletteBins, hue=self._mDoHuePalette)
    if (not self._mDoHuePalette):
        npimg = img.getNumpy()
        white = np.array([255, 255, 255])
        black = np.array([0, 0, 0])
        for p in palette_selection:
            npimg = np.where((npimg != p), npimg, white)
        npimg = np.where((npimg != white), black, white)
        retVal = Image(npimg)
    else:
        npimg = img.getNumpy()[:, :, 1]
        white = np.array([255])
        black = np.array([0])
        for p in palette_selection:
            npimg = np.where((npimg != p), npimg, white)
        npimg = np.where((npimg != white), black, white)
        retVal = Image(npimg)
    return retVal
