Created
May 20, 2019 15:43
-
-
Save riccardodivirgilio/26f72f0749e726c43fcd0f0f2e567843 to your computer and use it in GitHub Desktop.
proposed fix for wolframclient error
This file contains 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 PIL import Image | |
import io | |
from wolframclient.language import wlexpr, wl | |
from wolframclient.evaluation import WolframLanguageSession | |
import numpy as np | |
def CurvatureFlowFilter(session, img): | |
data = session.evaluate(wl.CurvatureFlowFilter(img, 50)) | |
z = session.evaluate(wl.ExportByteArray(data, "PNG")) | |
im = np.array(Image.open(io.BytesIO(z))) | |
return im | |
def Binarize(session, img): | |
data = session.evaluate(wl.Binarize(img)) | |
z = session.evaluate(wl.ExportByteArray(data, "PNG")) | |
im = np.array(Image.open(io.BytesIO(z))) | |
return im | |
img = Image.open('/Users/rdv/Desktop/59380297_10156593903528155_315272697133137920_o.jpg') | |
with WolframLanguageSession() as session: | |
bin_img = Binarize(session, img) | |
print(bin_img) | |
curv_img = CurvatureFlowFilter(session, img) | |
print(curv_img) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment