Simplify Image.color() and make in return ints instead of floats.

This commit is contained in:
Andrey Golovizin 2014-09-02 14:33:39 +02:00
parent af351617d8
commit dac3475579

View file

@ -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."""