标签:大神 weight col sql pyplot iss tinyxml python color
type:使用的阈值类型
例子:
#python 3.5.3 蔡军生
#http://edu.csdn.net/course/detail/2592
#
import cv2
import matplotlib.pyplot as plt
img = cv2.imread(‘test1.jpg‘,0) #直接读为灰度图像
#二值化
ret,thresh1 = cv2.threshold(img,1,255,cv2.THRESH_BINARY)
ret,thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)
ret,thresh3 = cv2.threshold(img,127,255,cv2.THRESH_TRUNC)
ret,thresh4 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO)
ret,thresh5 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV)
titles = [‘img‘,‘BINARY‘,‘BINARY_INV‘,‘TRUNC‘,‘TOZERO‘,‘TOZERO_INV‘]
images = [img,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()
可见使用这个函数可以获取轮廓图案。
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://www.cnblogs.com/captainbed
标签:大神 weight col sql pyplot iss tinyxml python color
原文地址:https://www.cnblogs.com/skiwnchh/p/10167930.html