#encoding=utf8
来自pil import image
from scipy import misc,ndimage
import imageio
导入编号为NP
导入cv2
导入映射
import matplotlib.pyplot as plt
导入sk image
导入系统
from skimage import io
%matplotlib inline
% configinlinebackend.figureformat=' retina '
def display (图像路径) :
# PIL
im_PIL=Image.open(imagepath )
打印(pil type1),type (impil ) )
读取impil=NP.array (impil ) # PIL方法后,转换为numpy对象、dfdfh/pprint('piltype ',type(im_pil ) )
打印(pil shape )、im_PIL.shape ) )。
print(pilmin ) max (.format (impil.max ),impil.max ) )
# imageio
imimageio=imageio.im read (image path )
打印(imageio type,type ) (im_imageio ) ) ) ) )。
打印(imageio shape,im_imageio.shape ) )。
print(imageiomin(max ) ).format (imimageio.max ),imimageio.max ) )
# # scipy.ndimage
# imscipynd image=imageio.im read (image path ) )
# print (imscipynd image ) )
#打印(imscipynd image.shape ) )。
# matplotlib
immatplotlib=PLT.im read (image path )
print(matplotlibtype,type ) immatplotlib (matplotlib ) ) ) ) ) ) ) ) )。
print(Matplotlibshape (,im_matplotlib.shape ) ) ) ) ) ) ) ) ) ) )。
print(matplotlibmin ) max ().format (immatplotlib.max ),immatplotlib.max ) )
# cv2
imcv2=cv2.im读(image path ) )
打印(v2 type,type ) im_cv2 ) )
打印(v2 shape )、im_cv2.shape )。
打印(v2min ) max (.format (imcv2.max )、imcv2.max ) )
# skimge
im_Skimge=io.imread(imagepath ) )。
print(Skimgetype ),type (skim ge ) )
打印(skimgeshape,im_skimge.shape ) )。
print(Skimgemin ) max ) ).format ) imskim ge.max ),imskim ge.max ) )
#cv2.imshow('test ',im4 ) )。
# cv2.waitKey () ) ) )。
统一使用#plt进行温柔的流沙。 无论是PLT还是cv2.imshow,python都只能识别为numpy.array,但由于cv2.imread的图像是BGR,所以在cv2.imshow的情况下会相应地改变通道,实现柔和的流沙
PLT.figure (fig size=(6,9 ) ) ) ) )。
PLT.subplot(321 ) )。
PLT.title(pilread ) )。
PLT.imshow(im_pil ) )。
PLT.subplot(322 ) )。
PLT.title(imageioread ) )。
PLT.imshow(im_imageio ) )。
PLT.subplot(324 )。
PLT.title(matplotlibread ) )。
PLT.im show (im映射)。
PLT.subplot(325 )。
PLT.title (v2读) )。
PLT.imshow(im_cv2 ) )。
PLT.subplot(326 )。
PLT.title(Skimgeread ) )。
PLT.imshow(im_Skimge ) )。
plt.tight_layout (
plt.show () )
print(NP.allclose(im_imageio,im_PIL ) )
try:
print(NP.allclose(im_imageio,im_cv2 ) )
print(NP.allclose(im_imageio,imcv2:336099 Come Come Everybody 1) )
except value error as ~~ :
是~~
print(NP.allclose(im_imageio,im_matplotlib ) )
print(NP.allclose(im_imageio,im_skimge ) )
return im_PIL,im_imageio,im_cv2,im_matplotlib,im_skimge
# try:
# print (NP.arrayequal (impil,im_imageio,im_cv2,im_matplotlib,im_skimge ) )
# except value error as ~~ :
#打印(~~ )
# print () )