|
|
@ -27,7 +27,7 @@ def weighted_average(p1, w1, p2, w2):
|
|
|
|
return coef * too_big
|
|
|
|
return coef * too_big
|
|
|
|
|
|
|
|
|
|
|
|
class Picture:
|
|
|
|
class Picture:
|
|
|
|
def __init__(self, data);
|
|
|
|
def __init__(self, data):
|
|
|
|
self.pixels = data
|
|
|
|
self.pixels = data
|
|
|
|
self.w = len(data[0])
|
|
|
|
self.w = len(data[0])
|
|
|
|
self.h = len(data)
|
|
|
|
self.h = len(data)
|
|
|
@ -43,18 +43,18 @@ class Picture:
|
|
|
|
for x in range(wt):
|
|
|
|
for x in range(wt):
|
|
|
|
line = []
|
|
|
|
line = []
|
|
|
|
for y in range(ht):
|
|
|
|
for y in range(ht):
|
|
|
|
line.append(Pixel(*(access[x, y][:3]))
|
|
|
|
line.append(Pixel(*(access[x, y][:3])))
|
|
|
|
data.append(line)
|
|
|
|
data.append(line)
|
|
|
|
|
|
|
|
|
|
|
|
result = cls(data)
|
|
|
|
result = cls(data)
|
|
|
|
assert result.w = wt
|
|
|
|
assert result.w == wt
|
|
|
|
assert result.h = ht
|
|
|
|
assert result.h == ht
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show(self): ...
|
|
|
|
def show(self): ...
|
|
|
|
|
|
|
|
|
|
|
|
class Interpolator
|
|
|
|
class Interpolator:
|
|
|
|
def interpolate(self, picture, new_h, new_w):
|
|
|
|
def interpolate(self, picture, new_h, new_w):
|
|
|
|
quantum_x = new_w / picture.w
|
|
|
|
quantum_x = new_w / picture.w
|
|
|
|
quantum_y = new_h / picture.h
|
|
|
|
quantum_y = new_h / picture.h
|
|
|
|