Simplify Image.color() and make in return ints instead of floats.
This commit is contained in:
parent
af351617d8
commit
dac3475579
1 changed files with 2 additions and 3 deletions
|
|
@ -18,7 +18,6 @@ import itertools
|
|||
from io import BytesIO
|
||||
|
||||
import numpy as np
|
||||
from scipy.stats.mstats import mode
|
||||
from skimage.io import imread, imsave
|
||||
|
||||
from .utils import cached_property, pairwise
|
||||
|
|
@ -170,8 +169,8 @@ class Image(object):
|
|||
return None
|
||||
mask3 = np.dstack([~self.bitmap] * 3)
|
||||
colors = np.ma.MaskedArray(self.data, mask3).reshape(-1, 3)
|
||||
modes, counts = mode(colors)
|
||||
return tuple(modes[0])
|
||||
r, g, b = colors.mean(axis=0)
|
||||
return int(r), int(g), int(b)
|
||||
|
||||
def serialize(self):
|
||||
"""Serialize the image as some hashable object."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue