给定二值图像距离变换的实现

时间:2016-12-22 18:45:49

标签: python python-2.7 image-processing euclidean-distance motion-planning

我正在寻找给定二进制图像的距离变换的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]

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

0 个答案:

没有答案