TypeError:在plt.imshow()python中,无法将dtype对象的图像数据转换为浮点

2024-03-29 12:38:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我想读取在paths中创建的每个图像,并使用vconcat连接它们。我犯了这个错误 Traceback : in plt.imshow(im_v,cmap='inferno', aspect='auto', interpolation='nearest') TypeError: Image data of dtype object cannot be converted to float 同时运行以下代码。怎么解决呢

任何帮助都将不胜感激

if nSpectogram <3765:
            for k in range (0,22):
                paths=FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram+1)+'_'+str(k)
                for f1 in paths:
                    img = cv2.imread(f1)
                    im_v=cv2.vconcat(img)
                plt.imshow(im_v,cmap='inferno', aspect='auto', interpolation='nearest')

            plt.axis('off') 
            plt.savefig(FirstPartPathOutput+SecondPartPathOutput+'/spec_'+isPreictal+'_'+str(nSpectogram+1)+'_'+str(k+1)+'.png')

Tags: inforautopltcmappathsimshowim