def apply_mask(components):
    """
    Applies the mask (if exists) to the image.

    :param components: components
    :return: updated components
    """
    img = components[10]
    mask = components[11]
    if mask is not None:
        img[:, :, 0] = img[:, :, 0] * mask
        img[:, :, 1] = img[:, :, 1] * mask
        img[:, :, 2] = img[:, :, 2] * mask
        img[img == 0] = 128
    return components