我正在手动将 MATLAB 代码转换为 Python,但我被困在一行中。
MATLAB代码:
cashew_BW = threshad(cashew_GRAY(:,:,1),T);
cashew_BW = ~cashew_BW;
cashew_BW = imclose(cashew_BW, true(5));
cashew_BW = ~cashew_BW
Python转换后的代码:
T = 112
se = [[1,1,1,1,1]]*5
cashew_BW = pymorph.threshad(cashew_GRAY, T, f2=None)
cashew_BW = np.logical_not(cashew_BW)
cashew_BW = 1*(cashew_BW)
cashew_BW = pymorph.close(cashew_BW, se)
cashew_BW = np.logical_not(cashew_BW)
cashew_BW = 1*(cashew_BW)
错误:
Traceback (most recent call last):
File "check1.py", line 22, in <module>
cashew_BW = pymorph.close(cashew_BW, se)
File "/home/keerthi/anaconda2/lib/python2.7/site-packages/pymorph-0.96-py2.7.egg/pymorph/mmorph.py", line 1303, in close
return erode(dilate(f,Bc ),Bc )
File "/home/keerthi/anaconda2/lib/python2.7/site-packages/pymorph-0.96-py2.7.egg/pymorph/mmorph.py", line 1580, in dilate
x,v = mat2set(B)
File "/home/keerthi/anaconda2/lib/python2.7/site-packages/pymorph-0.96-py2.7.egg/pymorph/mmorph.py", line 4392, in mat2set
if len(A.shape) == 1: A = A[newaxis,:]
AttributeError: 'list' object has no attribute 'shape'
我该如何纠正?