mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-09 06:44:45 +03:00
Added tests; whitespace fix
This commit is contained in:
parent
bfab360504
commit
907ac614f0
|
@ -137,10 +137,10 @@ def autocontrast(image, cutoff=0, ignore=None):
|
||||||
|
|
||||||
def autocontrast_preserve(image, cutoff=0, ignore=None):
|
def autocontrast_preserve(image, cutoff=0, ignore=None):
|
||||||
"""
|
"""
|
||||||
Maximize (normalize) image contrast while preserving image tone.
|
Maximize (normalize) image contrast while preserving image tone.
|
||||||
This function calculates a histogram of the input image, removes
|
This function calculates a histogram of the input image, removes
|
||||||
**cutoff** percent of the lightest and darkest pixels from the
|
**cutoff** percent of the lightest and darkest pixels from the
|
||||||
histogram, and remaps the image so that the darkest pixel becomes
|
histogram, and remaps the image so that the darkest pixel becomes
|
||||||
black (0), and the lightest becomes white (255).
|
black (0), and the lightest becomes white (255).
|
||||||
:param image: The image to process.
|
:param image: The image to process.
|
||||||
:param cutoff: How many percent to cut off from the histogram.
|
:param cutoff: How many percent to cut off from the histogram.
|
||||||
|
|
|
@ -20,6 +20,12 @@ class TestImageOps(PillowTestCase):
|
||||||
ImageOps.autocontrast(hopper("L"), cutoff=10)
|
ImageOps.autocontrast(hopper("L"), cutoff=10)
|
||||||
ImageOps.autocontrast(hopper("L"), ignore=[0, 255])
|
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"), (0, 0, 0), (255, 255, 255))
|
||||||
ImageOps.colorize(hopper("L"), "black", "white")
|
ImageOps.colorize(hopper("L"), "black", "white")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user