计算两个点间的欧式距离
def getGrayDiff(img,currentPoint,tmpPoint):
return abs(int(img[currentPoint.x,currentPoint.y]) - int(img[tmpPoint.x,tmpPoint.y]))
def selectConnects§:
if p == 8:
connects = [Point(-1, -1), Point(0, -1), Point(1, -1), Point(1, 0), Point(1, 1),
Point(0, 1), Point(-1, 1), Point(-1, 0)]#八邻域
else:
connects = [ Point(0, -1), Point(1, 0),Point(0, 1), Point(-1, 0)]#四邻
return connects
def regionGrow(img,seeds,thresh):
#读取图像的宽高,并建立一个和原图大小相同的seedMark
height, width = img.shape
seedMark = np.zeros(img.shape)
#将定义的种子点放入种子点序列seedList
seedList = []
for seed in seeds:
seedList.append(seed)
label = 1
#选择邻域
#c
鼠标交互与区域生长
最新推荐文章于 2022-07-16 10:29:47 发布
本文介绍了区域生长算法,通过计算像素间欧式距离并设定阈值来连接相似点。算法首先从用户指定的种子点开始,然后在四邻域内进行像素比较,将满足条件的相邻点加入生长点序列,直至序列为空。最后,该算法应用于图像'peppa.jpg',进行图像分割。
摘要由CSDN通过智能技术生成