Did I find the right examples for you? yes no

All Samples(4)  |  Call(4)  |  Derive(0)  |  Import(0)
Invert all pixel values above a threshold.

:param image: The image to posterize.
:param threshold: All pixels above this greyscale level are inverted.
:return: An image.

        def solarize(image, threshold=128):
    """
    Invert all pixel values above a threshold.

    :param image: The image to posterize.
    :param threshold: All pixels above this greyscale level are inverted.
    :return: An image.
    """
    lut = []
    for i in range(256):
        if i < threshold:
            lut.append(i)
        else:
            lut.append(255-i)
    return _lut(image, lut)
        


src/p/i/Pillow-2.4.0/Tests/test_imageops.py   Pillow(Download)
    ImageOps.posterize(lena("RGB"), 4)
 
    ImageOps.solarize(lena("L"))
    ImageOps.solarize(lena("RGB"))
 

src/p/i/Pillow-HEAD/Tests/test_imageops.py   Pillow(Download)
    ImageOps.posterize(lena("RGB"), 4)
 
    ImageOps.solarize(lena("L"))
    ImageOps.solarize(lena("RGB"))