我正在嘗試將 python 與 jupyter notebook 結合使用,想出一個方案,您可以握住智能燈泡并通過漫反射從手中獲取信息。我已經設法完成所有這些工作,并且所有這些都保存在一個變量 PIX 中:PIX = np.array(pictures)print(PIX.shape)這會像預期的那樣輸出一個 (81,480,640,3)(81 表示轉換為 RGB 的可見光譜,以便燈得到它)。但是,我現在想可視化數據,我認為 imshow 是完美的實現。我更改了一些變量,使腳本如下所示:# Plot the images on a subplots array?fig, axes =?plt.subplots(int(PIX.shape[0]/9),int(PIX.shape[0]/9))for i, ax in enumerate(axes):? ? axes[i].imshow(PIX[i,:,:,0], interpolation='none')# Render the figureplt.show()同樣,這非常簡單。但是,我收到錯誤:AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last)<ipython-input-20-a7bb604d1828> in <module>? ? ? 3?? ? ? 4 for i, ax in enumerate(axes):----> 5? ? ?axes[i].imshow(PIX[i,:,:,0], interpolation='none')? ? ? 6 # Render the figure? ? ? 7 plt.show()AttributeError: 'numpy.ndarray' object has no attribute 'imshow'?我嘗試使用 matplotlib修復'numpy.ndarray' object has no attribute 'imshow'和'numpy.ndarray' object has no attribute 'show'?,他們似乎有類似的問題。但是,這些修復似乎都不適用于我的情況。任何幫助,將不勝感激!
numpy.ndarray 對象沒有屬性 imshow
慕蓋茨4494581
2023-05-23 15:04:41