Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/PIL/ImageStat.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def _getextrema(self):
"""Get min/max values for each band in the image"""

def minmax(histogram):
n = 255
x = 0
res_min, res_max = 255, 0
for i in range(256):
if histogram[i]:
n = min(n, i)
x = max(x, i)
return n, x # returns (255, 0) if there's no data in the histogram
res_min = i
break
for i in range(255, -1, -1):
if histogram[i]:
res_max = i
break
return res_min, res_max

return [minmax(self.h[i:]) for i in range(0, len(self.h), 256)]

Expand Down