def luma(col):
    """Calculates ITU-R 601-2 luma value for a given RGB color. This is the same formula used by `PIL.Image.Image.convert` when converting RGB to L."""
    r, g, b = col
    return r * 299/1000 + g * 587/1000 + b * 114/1000