opencv提取骨架找端点,根据端点去掉毛刺
opencv
OpenCV: 开源计算机视觉库
项目地址:https://gitcode.com/gh_mirrors/opencv31/opencv
免费下载资源
·
import cv2 import numpy as np from scipy import ndimage import matplotlib.pyplot as plt from tqdm import tqdm def _neighbors_conv(image): image = image.astype(np.int32) k = np.array([[255, 255, 255], [255, 0, 255], [255, 255, 255]]) neighborhood_count = ndimage.convolve(image, k, mode='constant', cval=1) neighborhood_count[~image.astype(np.bool_)] = 0 # print(neighborhood_count) return neighborhood_count def spur(image): return _neighbors_conv(image) > 255 def bwmorph(image, fn, n=1): for _ in range(n): image = fn(image) return image t = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [1, 1, 0, 0]] t = np.array(t) print('neighbor count:') print(_neighbors_conv(t)) print('after spur:') print(bwmorph(t, spur).astype(np.int_))
GitHub 加速计划 / opencv31 / opencv
77.38 K
55.71 K
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:2 个月前 )
c3747a68
Added Universal Windows Package build to CI. 6 天前
9b635da5 - 6 天前
更多推荐
已为社区贡献4条内容
所有评论(0)