Estimates the amount of a color relative to other colors.

    :param image: numpy.ndarray
    :param channel: int
    :returns: portion of a channel in an image
    :rtype: float

def channel_portion(image, channel):
    '''Estimates the amount of a color relative to other colors.

    :param image: numpy.ndarray
    :param channel: int
    :returns: portion of a channel in an image
    :rtype: float
    '''

    # Separate color channels
    rgb = []
    for i in range(3):
        rgb.append(image[:, :, i].astype(int))
    ch = rgb.pop(channel)

    relative_values = ch - np.sum(rgb, axis=0) / 2
    relative_values = np.maximum(np.zeros(ch.shape), relative_values)

    return float(np.average(relative_values) / 255)