我在寫一段代碼從矩陣中提取子矩陣。作爲模塊,我導入了scipy和Image。當我運行該腳本,我得到了提取子矩陣時的問題
submatrix = im[x_min:x_max, y_min:y_max]
TypeError: an integer is required
我檢查錯誤和最小值和最大值是有效整數...你有關於如何解決這一問題有何建議?
x_min = int(x - 50)
x_max = int(x + 50)
y_min = int(y - 50)
y_max = int(y + 50)
if x_min < 0:
x_min = 0
continue
if y_min < 0:
y_min = 0
continue
if x_max > 2160:
x_max = 2160
continue
if y_max > 2592:
y_max = 2592
continue
submatrix = im[x_min:x_max, y_min:y_max]
figure(1)
imshow(submatrix)
break
我想'im'是numpy的數組? – Jakob
是的,它是通過讀取圖像獲得的矩陣:image = Image.open(「/ ... image_%03i.tif」%(index)); im = image.load() –