Reading images in python

前端 未结 9 2012
北海茫月
北海茫月 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:10

    For the better answer, you can use these lines of code. Here is the example maybe help you :

    image = cv2.imread('/home/pictures/1.jpg')
    plt.imshow(image)
    plt.show()
    

    In imread() you can pass the directory .so you can also use str() and + to combine dynamic directories and fixed directory like this:

    path = '/home/pictures/'
    for i in range(2) :
        image = cv2.imread(str(path)+'1.jpg')
        plt.imshow(image)
        plt.show()
    

    Both are the same.

提交回复
热议问题