Added tests; whitespace fix

This commit is contained in:
Alex Ball 2015-05-31 10:51:19 -04:00
parent bfab360504
commit 907ac614f0
2 changed files with 10 additions and 4 deletions

View File

@ -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.

View File

@ -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")