MATLAB kodunu Python'a manuel olarak dönüştürüyorum ve bir satırda takılıyorum.Python Kod Dönüştürme MATLAB - imclose() issue
MATLAB kodu:
cashew_BW = threshad(cashew_GRAY(:,:,1),T);
cashew_BW = ~cashew_BW;
cashew_BW = imclose(cashew_BW, true(5));
cashew_BW = ~cashew_BW
Python kodunu dönüştürülen:
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)
Hata:
Bunu düzeltmek nasılTraceback (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'
?
Sadece np.array ([1,1,1,1,1]) 'i kontrol etmek için kullandım ve bir hatayı aldım: 'dizi için çok fazla sayıda indeks' –
Hata alıyorum 'se' pymorph geçtikten sonra .close'? Dokümanlardan “3x3 çapraz” biçiminde olmalı, bu yüzden çalışıp çalışmadığını görmek için se = pymorph.secross (r = 1) gibi bir şey deneyebilirsiniz ... –