我想找到轮廓或边框内像素的坐标。 这里B代表轮廓的坐标,每个例子的尺寸为38 * 2(B是计数器的坐标x y的数组)
coordinates = []
for i in range (B.shape[0]):
for j in range (B.shape[0]):
if B[i, 1] == B[j,1]:
a, b = j, B[j,1]
if B[i,0]<= B[a,0]:
for k in range (int(B[i,0]), int(B[a,0]+1)):
coordinates.append([k,b])
else:
for m in range (int(B[a,0]), int(B[i,0]+1)):
coordinates.append([m , b])
但它通常不是正确的方法,因为它通过了初始图像的坐标。