'**SUMMARY**
Merge channels is the oposite of splitChannels. The image takes one image for each
of the R,G,B channels and then recombines them into a single image. Optionally any of these
channels can be None.
**PARAMETERS**
* *r* - The r or last channel  of the result SimpleCV Image.
* *g* - The g or center channel of the result SimpleCV Image.
* *b* - The b or first channel of the result SimpleCV Image.
**RETURNS**
A SimpleCV Image.
**EXAMPLE**
>>> img = Image("lenna")
>>> [r,g,b] = img.splitChannels()
>>> r = r.binarize()
>>> g = g.binarize()
>>> b = b.binarize()
>>> result = img.mergeChannels(r,g,b)
>>> result.show()
**SEE ALSO**
:py:meth:`splitChannels`'

def mergeChannels(self, r=None, g=None, b=None):

    if ((r is None) and (g is None) and (b is None)):
        logger.warning('ImageClass.mergeChannels    -    we    need    at    least    one    valid    channel')
        return None
    if (r is None):
        r = self.getEmpty(1)
        cv.Zero(r)
    else:
        rt = r.getEmpty(1)
        cv.Split(r.getBitmap(), rt, rt, rt, None)
        r = rt
    if (g is None):
        g = self.getEmpty(1)
        cv.Zero(g)
    else:
        gt = g.getEmpty(1)
        cv.Split(g.getBitmap(), gt, gt, gt, None)
        g = gt
    if (b is None):
        b = self.getEmpty(1)
        cv.Zero(b)
    else:
        bt = b.getEmpty(1)
        cv.Split(b.getBitmap(), bt, bt, bt, None)
        b = bt
    retVal = self.getEmpty()
    cv.Merge(b, g, r, None, retVal)
    return Image(retVal)
