class BilinImage(Image): def __getitem__(self, (x, y)): if isinstance(x, float) and isinstance(y, float): x0, x1 = int(floor(x)), int(ceil(x)) y0, y1 = int(floor(y)), int(ceil(y)) xoff, yoff = x - x0, y - y0 return (1.0-xoff)*(1.0-yoff) * self[x0, y0] + \ (1.0-xoff)*( yoff) * self[x0, y1] + \ ( xoff)*(1.0-yoff) * self[x1, y0] + \ ( xoff)*( yoff) * self[x1, y1] else: return Image.__getitem__(self, (x, y))
class NNImage(Image): def __getitem__(self, (x, y)): return Image.__getitem__(self, (int(x + 0.5), int(y + 0.5)))