Update src/PIL/ImageOps.py

Yup you are absolutely correct; it does the job in fewer lines of code too.

Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
This commit is contained in:
Hamza 2020-07-01 19:01:53 +05:00 committed by GitHub
parent 16e804b892
commit 27c40910d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,12 +88,8 @@ def autocontrast(image, cutoff=0, ignore=None):
h[ix] = 0
if cutoff:
# cut off pixels from both ends of the histogram
if isinstance(cutoff, int):
if not isinstance(cutoff, tuple):
cutoff = (cutoff, cutoff)
elif isinstance(cutoff, tuple):
pass
else:
raise ValueError("the cutoff can only be a integer or tuple")
# get number of pixels
n = 0
for ix in range(256):