diff --git a/PIL/ImageOps.py b/PIL/ImageOps.py index 5521f81d3..b8f81321b 100644 --- a/PIL/ImageOps.py +++ b/PIL/ImageOps.py @@ -137,10 +137,10 @@ def autocontrast(image, cutoff=0, ignore=None): def autocontrast_preserve(image, cutoff=0, ignore=None): """ - Maximize (normalize) image contrast while preserving image tone. - This function calculates a histogram of the input image, removes - **cutoff** percent of the lightest and darkest pixels from the - histogram, and remaps the image so that the darkest pixel becomes + Maximize (normalize) image contrast while preserving image tone. + This function calculates a histogram of the input image, removes + **cutoff** percent of the lightest and darkest pixels from the + histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255). :param image: The image to process. :param cutoff: How many percent to cut off from the histogram. diff --git a/Tests/test_imageops.py b/Tests/test_imageops.py index 396f0da6c..8c649c868 100644 --- a/Tests/test_imageops.py +++ b/Tests/test_imageops.py @@ -20,6 +20,12 @@ class TestImageOps(PillowTestCase): ImageOps.autocontrast(hopper("L"), cutoff=10) ImageOps.autocontrast(hopper("L"), ignore=[0, 255]) + ImageOps.autocontrast_preserve(hopper("L")) + ImageOps.autocontrast_preserve(hopper("RGB")) + + ImageOps.autocontrast_preserve(hopper("L"), cutoff=10) + ImageOps.autocontrast_preserve(hopper("L"), ignore=[0, 255]) + ImageOps.colorize(hopper("L"), (0, 0, 0), (255, 255, 255)) ImageOps.colorize(hopper("L"), "black", "white")