gpt4 book ai didi

python - 查找轮廓不准确

转载 作者:行者123 更新时间:2023-12-02 16:08:35 24 4
gpt4 key购买 nike

我有一个问题要找到这个图像的轮廓我用过 findcontour 不是很准确我做错了吗?

Here's my result but its not accurate.

Here's the image I've used

gs = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
blur = cv2.GaussianBlur(gs, (3,3),0)
ret_otsu,im_bw_otsu = cv2.threshold(blur,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)

kernel = np.ones((50,50),np.uint8)
closing = cv2.morphologyEx(im_bw_otsu, cv2.MORPH_CLOSE, kernel)
_, contours, hierarchy = cv2.findContours(closing,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

plottedContour = cv2.drawContours(gs,contours,-1,(0,255,0),2)
cv2.imshow('CONTOUR',plottedContour)

最佳答案

看起来您可能想查看其他轮廓,

cv2.drawContours(gs,contours,-1,(0,255,0),2)
cv2.drawContours(gs,contours,0,(0,255,0),2)
cv2.drawContours(gs,contours,1,(0,255,0),2)
cv2.drawContours(gs,contours,2,(0,255,0),2)
...

关于python - 查找轮廓不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60178751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com