Reading images in python

前端 未结 9 1960
北海茫月
北海茫月 2021-02-03 19:59

I am trying to read a png image in python. The imread function in scipy is being deprecated and they recommend using imageio

相关标签:
9条回答
  • 2021-02-03 20:18

    I read all answers but I think one of the best method is using openCV library.

    import cv2
    
    img = cv2.imread('your_image.png',0)
    

    and for displaying the image, use the following code :

    from matplotlib import pyplot as plt
    plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
    plt.xticks([]), plt.yticks([])  # to hide tick values on X and Y axis
    plt.show()
    
    0 讨论(0)
  • 2021-02-03 20:21

    You can also use Pillow like this:

    from PIL import Image
    image = Image.open("image_path.jpg")
    image.show()
    
    0 讨论(0)
  • 2021-02-03 20:25

    If you just want to read an image in Python using the specified libraries only, I will go with matplotlib

    In matplotlib :

    import matplotlib.image
    read_img = matplotlib.image.imread('your_image.png')
    
    0 讨论(0)
提交回复
热议问题