问题:
使用jupyter编写程序时,使用代码可以显出出图片
代码如下:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
%matplotlib inline
# Read in the image
image = mpimg.imread('images/car_green_screen.jpg')
# Print out the image dimensions (height, width, and depth (color))
print('Image dimensions:', image.shape)
# Display the image
plt.imshow(image)
但是使用Anaconda却无法显示图片 即无法调用matplotlib函数。
解决方案
加入 plt.show()
具体代码如下:
import matplotlib.pyplot as plt
import matplotlib.pyplot as mping
import sys
import numpy as np
import cv2
## read in the image
image = mping.imread('images/car_green_screen.jpg')
#print out image dimensions (height,width, and depth(color))
print('image dimensions:',image.shape)
#display the image
plt.imshow(image)
plt.show()