def covariance(self, other): try: return mean( math2.vecmul(math2.vecsub(self, [], self.mean), math2.vecsub(other, [], other.mean))) except: return 0 # consider decorrelated
def box_size(self): """:return: (x,y) size""" min, max = self.box() try: min[0], max[0] # at least one dimension ? return tuple(math2.vecsub(max, min)) except: return (0, 0)
def box_size(self): """:return: (x,y) size""" a, b = self.box() try: a[0], b[0] # at least one dimension ? return tuple(math2.vecsub(b, a)) except: return (0, 0)
def __sub__(self,other): from .image import Image if isinstance(other, Image): mode=other.mode return Image(size=other.size,color=self.convert(mode),mode=mode)-other if not isinstance(other, Color): other=Color(other) return Color(math2.vecsub(self.rgb,other.rgb)) #TODO: change to other space one day