import cv2 import numpy as np import matplotlib.pyplot as plt %matplotlib inline img = cv2.imread('dargon.JPG',1) GrayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #GrayImage = np.array(dst).reshape(800,800).astype(np.uint8) ret,thresh1=cv2.threshold(GrayImage,10,255,cv2.THRESH_BINARY) ret,thresh2=cv2.threshold(GrayImage,10,255,cv2.THRESH_BINARY_INV) ret,thresh3=cv2.threshold(GrayImage,10,255,cv2.THRESH_TRUNC) ret,thresh4=cv2.threshold(GrayImage,10,255,cv2.THRESH_TOZERO) ret,thresh5=cv2.threshold(GrayImage,10,255,cv2.THRESH_TOZERO_INV) titles = ['Gray Image','BINARY','BINARY_INV','TRUNC','TOZERO','TOZERO_INV'] images = [GrayImage, thresh1, thresh2, thresh3, thresh4, thresh5] for i in range(6): plt.subplot(2,3,i+1),plt.imshow(images[i],'gray') plt.title(titles[i]) plt.xticks([]),plt.yticks([]) plt.show()
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » 06_OpenCV二值化处理
发表评论 取消回复