如何使用自适应阈值获得实体形状

问题描述

是否可以通过自适应阈值获得实体形状?在我的情况下(A)我只能得到空心形状,但在某些情况下(B)似乎可以得到实心形状。 (见下图)

enter image description here

输入要实现实体形状有什么要求?

下面是我的A代码

import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt

img_path = 'F:\\Coding Stuff\\Python\\Projects\\Open CV\\'
img = cv.imread(img_path + 'test_1.jpg')
img_gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
thresh = cv.adaptiveThreshold(img_gray,255,cv.ADAPTIVE_THRESH_GAUSSIAN_C,cv.THRESH_BINARY,11,2)
cv.imwrite('output.jpg',thresh)

这是输入图片

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)