0

我正在寻找给定二进制图像的距离变换的 python 实现。不使用现有的库代码。

这是我到目前为止所做的 -

#function to find EUCLIDIAN distance to nearest wall from current cell
def find_len_to_nearest_wall(img,row,col):

#read binary image (white(walls) - [255,255,255], black(free space) - [0,0,0])
img = cv2.imread("4_1_map.png")
img_new = [[0 for n in len(img[0])] for n2 in len(img)]
#distance transforming...
for row in img:
    for col in row:
        if img[row][col][0] == 255:
            num = numpy.uint8(255)
        else:
            num = numpy.uint8(find_len_to_nearest_wall(img,row,col))
        img_new[row][col] = [num,num,num]

如何开始编写函数以查找到最近的墙壁/障碍物的长度

4

0 回答 0