1
此代碼從圖像小波到控制檯打印出一串無窮無盡的數字。我需要限制輸出到前50或100個項目。我試圖做到這一點,但沒有得到我所需要的。如何在計算圖像小波時限制numpy陣列的打印輸出?
def waveletdbbiorone(self): #function for Wavelets computation
for filename in glob.iglob ('*.tif'):
imgwbior = mahotas.imread (filename) #read the image
arraywbior = numpy.array([imgwbior])#make an array
coefwbior = pywt.wavedec(arraywbior,'db1')#compute wavelet coefficients
arr = numpy.array([coefwbior])
np.set_printoptions(threshold=3)
# print arr
for elem in arr.flat:
print('{}\t'.format(elem)) #, end ='') #print out the result
我更傾向於這樣的ELEM在arr.flat [50]:' – Jaime