当前位置:   article > 正文

Python中imread()函数_pythonimread

pythonimread

5种方式:
1、调用opencv
import cv2
image_path = “绝对路径”
image = cv2.imread(image_path)
cv2.imshow(“cv2_image”, image)
cv2.waitKey()
2、PIL方式(Python Image Library)
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
image_path=“绝对路径”
img=Image.open(image_path)
img=np.array(img)
plt.imshow(img)
plt.show()
3、matplotlib.image
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
image_path=“绝对路径”
img=mpimg.imread(image_path)
plt.imshow(img)
plt.show()
4、skimage.io
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
image_path=“绝对路径”
img=io.imread(image_path)
plt.imshow(img)
plt.show()
5、scipy.misc
from scipy.misc import imread, imshow, imsave
import matplotlib.pyplot as plt
image_path=“绝对路径”
img=io.imread(image_path)
plt.imshow(img)
plt.show()
imsave(“路径”, img)
统一使用plt进行显示,不管是plt还是cv2.imshow,在python中只认numpy.array,但是由于cv2.imread的图片是BGR,cv2.imshow时相应的换通道显示

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/86791
推荐阅读
相关标签
  

闽ICP备14008679号