mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-24 07:40:32 +03:00
Merge pull request #7599 from florath/ImageStat_getcount_opt
This commit is contained in:
commit
fe26900688
|
@ -21,9 +21,7 @@
|
||||||
# See the README file for information on usage and redistribution.
|
# See the README file for information on usage and redistribution.
|
||||||
#
|
#
|
||||||
|
|
||||||
import functools
|
|
||||||
import math
|
import math
|
||||||
import operator
|
|
||||||
|
|
||||||
|
|
||||||
class Stat:
|
class Stat:
|
||||||
|
@ -69,10 +67,7 @@ class Stat:
|
||||||
def _getcount(self):
|
def _getcount(self):
|
||||||
"""Get total number of pixels in each layer"""
|
"""Get total number of pixels in each layer"""
|
||||||
|
|
||||||
v = []
|
return [sum(self.h[i : i + 256]) for i in range(0, len(self.h), 256)]
|
||||||
for i in range(0, len(self.h), 256):
|
|
||||||
v.append(functools.reduce(operator.add, self.h[i : i + 256]))
|
|
||||||
return v
|
|
||||||
|
|
||||||
def _getsum(self):
|
def _getsum(self):
|
||||||
"""Get sum of all pixels in each layer"""
|
"""Get sum of all pixels in each layer"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user