【发布时间】:2015-02-25 15:33:23
【问题描述】:
我运行这段代码:
import cv2
import numpy as np
from matplotlib import pyplot as plt
im=cv2.imread('1.jpg')
#mask=np.zeros(img.shape[:2],np.uint8)
imgray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh=cv2.threshold(imgray,200,200,200)
countours,hierarchy=cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(im,countours,-1,(0,255,0),3)
cv2.imshow("begueradj",im)
cv2.waitKey(0)
cv2.destroyAllWindows()
在这2张图片上(我展示的是原图和结果图):
图一:
图二:
结果 1:
结果 2:
我的问题:
在结果 1 中,threshold()
达到了我的预期。
但是为什么在 Result 2 中有那个绿色方块?根据我对threshold()
函数的理解,只能显示绿色圆圈。为什么是这样 ?我对这个功能有什么不明白的地方?
【问题讨论】:
标签: python python-2.7 opencv threshold