GUI的全称是Graphical User Interface,即 图形用户接口。在以前的计算机显示界面中,都是消息展示,也就是说展示出来的界面不是图形化的,这样对创作者来说减轻了工作压力,但是增大了使用者理解难度。因此,为了让计算机界面更加人性化,程序员有必要学习GUI特性。
# coding=utf-8
import cv2
import numpy as np
img = cv2.imread('./images/1.jpg',0)
# coding=utf-8
import cv2
import numpy as np
cv2.nameWindows('image',cv2.WINDOW_NORMAL)
cv2.imread('./images/1.jpg',0)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# coding=utf-8
import cv2
import numpy as np
cv2.imwrite('xiaoyin.png',img)
# coding=utf-8
import cv2
import numpy as np
img=cv2.imread('xiaoyin.jpg',0)
cv2.imshow('img',img)
k=cv2.waitKey(0)&oxFF
if k == 27: # wait for ECS key to exit
cv2.destroyAllWindows()
elif k == ord('s'): # wait for 's' key to save and exit
cv2.imwrite('xiaojiang.png',img)
cv2.destroyAllWindows()
# coding=utf-8
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('xiaoyin.img',0)
plt.imshow(img,cmap = 'gray',interpolation = 'bicubic')
plt.xticks([]),plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
彩色图像用OpenCV加载是BGR模式,而matplotlib加载是RGB模式。故用opencv加载后的彩色图像无法在matplotlib中正确显示。