def on_edge(mask, x, y):
    """ checks if the point defined with coordinates x and y lies on the edge
        of a pedestrian on the pedestrian mask

        to lie on an edge is defined by having at least one non-pedestrian
        pixel in the surrouding of the given pixel (left, right, up or down)

        e.g. we're checking if the middle pixel is an edge one

            0 1 1
        ... 0 1 1 ... -> on_edge? True
            0 0 1

            0 1 1
        ... 1 1 1 ... -> on_edge? False
            0 1 1

        mask: array-like
            two dimensional array of binarized pixels

        x: int
            point coordinate on the x-axis

        y: int
            point coordinate on the y-axis

        returns: bool
            a boolean stating weather the point lies on the edge of the
            pedestrian
    """
    return mask[x, y] and not all([mask[x + dx, y + dy] for dx, dy in
                                   zip([-1, 1, 0, 0], [0, 0, -1, 1])])