TypeError: Image data can not convert to float

前端 未结 12 665
醉话见心
醉话见心 2020-12-17 07:45

I am trying to create a 16-bit image like so:

import skimage 
import random
from random import randint                        
xrow=raw_input("Enter the          


        
相关标签:
12条回答
  • 2020-12-17 08:19

    I guess you may have this problem in Pycharm. If so, you may try this to your problem.

    Go to File-Setting-Tools-Python Scientificin Pycharm and remove the option of Show plots in tool window.

    0 讨论(0)
  • 2020-12-17 08:21

    In my case image path was wrong! So firstly, you might want to check if image path is correct :)

    0 讨论(0)
  • 2020-12-17 08:23

    I was also getting this error, and the answers given above says that we should upload them first and then use their name instead of a path - but for Kaggle dataset, this is not possible.

    Hence the solution I figure out is by reading the the individual image in a loop in mpimg format. Here we can use the path and not just the image name.

    I hope it will help you guys.

    import matplotlib.image as mpimg
    for img in os.listdir("/content/train"): 
      image = mpimg.imread(path)
      plt.imshow(image)
      plt.show()
    
    0 讨论(0)
  • 2020-12-17 08:25

    This happened for me when I was trying to plot an imagePath, instead of the image itself. The fix was to load the image, and plotting it.

    0 讨论(0)
  • 2020-12-17 08:26

    As for cv2 is concerned.

    1. You might not have provided the right file type while cv2.imread(). eg jpg instead of png.
    2. Or you are providing image path instead of image's array. eg plt.imshow(img_path),

    try cv2.imread(img_path) first then plt.imshow(img) or cv2.imshow(img).

    0 讨论(0)
  • 2020-12-17 08:27

    Try to use this,

       plt.imshow(numpy.real(A))
       plt.show()
    

    instead of plt.imshow(A)

    0 讨论(0)
提交回复
热议问题