【发布时间】:2020-07-24 07:16:32
【问题描述】:
当我尝试使用 connectedComponentsWithStats 时,我得到了很多标签,但它们像这个例子一样嘈杂: 这是我的代码中应该提取字母的部分:
def ExtractLetters(img):
blur_radius = 0.1
nlabel, labels,stats,centroids = cv2.connectedComponentsWithStats(img)
thresh_size=30
for i in range(1, nlabel):
img = np.zeros(img.shape, dtype=np.uint8)
if (stats[i, cv2.CC_STAT_WIDTH] > thresh_size) or (stats[i, cv2.CC_STAT_HEIGHT]>thresh_size):
img[labels == i] = 255
img = 255 - img
cv2.imshow("test", img)
cv2.waitKey()
你知道为什么会出现这些噪音吗?
【问题讨论】:
标签: python numpy opencv image-processing cv2