def non_maximum_suppression(angle, edge):
    (H, W) = angle.shape
    _edge = edge.copy()
    for y in range(H):
        for x in range(W):
            if (angle[(y, x)] == 0):
                (dx1, dy1, dx2, dy2) = ((- 1), 0, 1, 0)
            elif (angle[(y, x)] == 45):
                (dx1, dy1, dx2, dy2) = ((- 1), 1, 1, (- 1))
            elif (angle[(y, x)] == 90):
                (dx1, dy1, dx2, dy2) = (0, (- 1), 0, 1)
            elif (angle[(y, x)] == 135):
                (dx1, dy1, dx2, dy2) = ((- 1), (- 1), 1, 1)
            if (x == 0):
                dx1 = max(dx1, 0)
                dx2 = max(dx2, 0)
            if (x == (W - 1)):
                dx1 = min(dx1, 0)
                dx2 = min(dx2, 0)
            if (y == 0):
                dy1 = max(dy1, 0)
                dy2 = max(dy2, 0)
            if (y == (H - 1)):
                dy1 = min(dy1, 0)
                dy2 = min(dy2, 0)
            if (max(max(edge[(y, x)], edge[((y + dy1), (x + dx1))]), edge[((y + dy2), (x + dx2))]) != edge[(y, x)]):
                _edge[(y, x)] = 0
    return _edge
def non_maximum_suppression(angle, edge):
    (H, W) = angle.shape
    _edge = edge.copy()
    for y in range(H):
        for x in range(W):
            if (angle[(y, x)] == 0):
                (dx1, dy1, dx2, dy2) = ((- 1), 0, 1, 0)
            elif (angle[(y, x)] == 45):
                (dx1, dy1, dx2, dy2) = ((- 1), 1, 1, (- 1))
            elif (angle[(y, x)] == 90):
                (dx1, dy1, dx2, dy2) = (0, (- 1), 0, 1)
            elif (angle[(y, x)] == 135):
                (dx1, dy1, dx2, dy2) = ((- 1), (- 1), 1, 1)
            if (x == 0):
                dx1 = max(dx1, 0)
                dx2 = max(dx2, 0)
            if (x == (W - 1)):
                dx1 = min(dx1, 0)
                dx2 = min(dx2, 0)
            if (y == 0):
                dy1 = max(dy1, 0)
                dy2 = max(dy2, 0)
            if (y == (H - 1)):
                dy1 = min(dy1, 0)
                dy2 = min(dy2, 0)
            if (max(max(edge[(y, x)], edge[((y + dy1), (x + dx1))]), edge[((y + dy2), (x + dx2))]) != edge[(y, x)]):
                _edge[(y, x)] = 0
    return _edge