def makeannotatedimage(masks, colors):
    ' Combine layers and create an image combining several annotations\n\n    :param masks: list of images used as masks\n    :param colors: list of colors\n    :return:\n    '
    if (len(masks) != len(colors)):
        print('Error: annotation and colors do not match.')
        return False
    elif (len(masks) == 0):
        print('Error: no mask to combine.')
        return False
    else:
        combo = np.zeros(masks[0].shape, dtype='uint8')
        i = 0
        bins = []
        for mask in masks:
            bin = binarize(mask)
            bins.append(bin)
        firstmask = bins[:1]
        combo = makecoloredlayer(combo, firstmask[0], colors[i])
        if (len(bins) > 1):
            other_masks = bins[1:]
            for mask in other_masks:
                i += 1
                newmask = binarize(combo)
                markedout = makemarkedmask(newmask, mask)
                combo = applymark(combo, markedout)
                newlayer = makecoloredlayer(combo, mask, colors[i])
                combo = cv2.bitwise_or(combo, newlayer)
        return combo
Combine layers and create an image combining several annotations

:param masks: list of images used as masks
:param colors: list of colors
:return:
def makeannotatedimage(masks, colors):
    ' Combine layers and create an image combining several annotations\n\n    :param masks: list of images used as masks\n    :param colors: list of colors\n    :return:\n    '
    if (len(masks) != len(colors)):
        print('Error: annotation and colors do not match.')
        return False
    elif (len(masks) == 0):
        print('Error: no mask to combine.')
        return False
    else:
        combo = np.zeros(masks[0].shape, dtype='uint8')
        i = 0
        bins = []
        for mask in masks:
            bin = binarize(mask)
            bins.append(bin)
        firstmask = bins[:1]
        combo = makecoloredlayer(combo, firstmask[0], colors[i])
        if (len(bins) > 1):
            other_masks = bins[1:]
            for mask in other_masks:
                i += 1
                newmask = binarize(combo)
                markedout = makemarkedmask(newmask, mask)
                combo = applymark(combo, markedout)
                newlayer = makecoloredlayer(combo, mask, colors[i])
                combo = cv2.bitwise_or(combo, newlayer)
        return combo