image processing with python node

Hello everyone,
I use python script to detect a white box in an image my script is simple. two
point coordinates.I want to use python node for this script.but I get errors ,the format is changing ,any help please.`
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
ImageFile = r’C:\Users\MohamedTaieb MANOUBI\Desktop\python.png’
Ima = Image.open(ImageFile)

img = np.array(Ima)

gray = Ima.convert(‘L’) #conversion to gray scale
bw = gray.point(lambda x: 0 if x<1 else 255, ‘1’) #binization

bw.show()
bwnp = np.array(bw)

[x,y]=bw.size

print(x,y)
X=bwnp[:, x/2]
print(X)

print(X.size)

A=0
for i in range(x):
if X[i] == True:
A=i
break
else:
i+=i
print(A)

B=0

Y=bwnp[x/2,:]
for j in range(y):
if Y[j] == True:
B=j
break
else:
j+=j

print(B)

bwrot = bw.rotate(180)

bwrot.show()
bwrotnp = np.array(bwrot)

#area = (A,B,x,y)

#bn = bwnprot.crop(area)

#bn.show()
X2=bwrotnp[:, x/2]
print(X2)
A2=0
for k in range(x):
if X2[k] == True:
A2=k
break
else:
k+=k

B2=0
Y2=bwrotnp[x/2,:]
for l in range(y):
if Y2[l] == True:
B2=l
break
else:
l+=l
print(A2)
print(B2)
area=(B ,A, x-B2, y-A2)
finis=bw.crop(area)
finis.show()`

python

Hi @MANOUBI,

Could you please post the exact error message that is being displayed? Or, even better, upload your knime.log file? The log file contains some more technical details that we can use to help you. It can be found at knime/.metadata/knime.log in your KNIME workspace directory. You can also open it within KNIME via ViewOpen KNIME log.

Marcel