master
WIPocket 3 years ago
parent b4274ec6e3
commit 79f0281dc1
No known key found for this signature in database
GPG Key ID: 3C8207ED1C3146F8

@ -0,0 +1,23 @@
import lib
import math
class BiLinear(lib.Interpolator):
def get_pixel(self, pic, x, y, r, qx, qy):
leftx = math.floor(x)
rightx = math.ceil(x)
topy = math.floor(y)
bottomy = math.ceil(y)
left = pic.at(leftx, topy)
right = pic.at(leftx, topy)
dist = x % 1
top = (left * (1 - dist) + right * dist)
left = pic.at(leftx, bottomy)
right = pic.at(leftx, bottomy)
bottom = (left * (1 - dist) + right * dist)
dist = y % 1
pix = (top * (1 - dist) + bottom * dist)
return pix

@ -5,8 +5,8 @@ import lib
pic = lib.Picture.load(orig_file) pic = lib.Picture.load(orig_file)
pic.show() pic.show()
import nn import Linear
Interp = nn.Nearest() Interp = Linear.BiLinear()
pix = Interp.interpolate(pic, 200, 200) pix = Interp.interpolate(pic, 200, 200)
pix.show() pix.show()
pix.save(new_file) pix.save(new_file)

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Loading…
Cancel
Save