Last active
September 2, 2017 11:34
-
-
Save mehdidc/09ce1aa8fe8d4e02e89cad27bf0861c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.svm import SVR | |
def smooth_image(x, y, z, w=100, h=100, model=SVR()): | |
X = np.vstack((x, y)).T | |
model.fit(X, z) | |
x, y = np.meshgrid( | |
np.linspace(x.min(), x.max(), w), | |
np.linspace(y.min(), y.max(), h) | |
) | |
x = x.flatten() | |
y = y.flatten() | |
xs = np.vstack((x, y)).T | |
zs = model.predict(xs) | |
zs = zs.reshape((w, h)) | |
return zs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment