def mask_image_by_color(image, color):
    """
    Mask the input image according to the rgb color.
    ALl pixels that do not have this color will be set to black.

    :param image: the PIL image to mask
    :param color: the RGB color as (r, g, b) tuple
    """

    pixels = image.load()  # create the pixel map

    masked_pixels = []

    for w in range(image.size[0]):  # for every col:
        for h in range(image.size[1]):  # For every row
            if pixels[w, h] != color:
                pixels[w, h] = (0, 0, 0)  # set the colour accordingly
                masked_pixels.append((w,h))

    return masked_pixels