【发布时间】:2018-02-12 09:20:15
【问题描述】:
我想保存带有轮廓的图像
这是我的代码:
img = cv2.imread('123.png')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, binary = cv2.threshold(gray, 150, 255, cv2.THRESH_BINARY)
image, contours, _ = cv2.findContours(binary, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
# some code in here
cv2.imwrite('234.jpg', cnt)
非常感谢。
【问题讨论】:
-
嗨,Ken,是的,我尝试绘制轮廓,但我想用轮廓保存图像。
-
“保存带有轮廓的图像”是什么意思?
-
嗨,Ken,我的意思是我想丢弃轮廓外的图像部分,对不起,我的说法含糊不清。