def generate_neighbours(image):
    """
    Generate all neighbours of all pixels in the image
    :param image:
    :return:
    """
    neighbour_dict = dict()
    for x in range(image.shape[0]):
        for y in range(image.shape[1]):
            neighbour_dict[str((x,y))] = list(filter(lambda pos: 0 <= pos[0] < image.shape[0] and 0 <= pos[1] < image.shape[1],
                   [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]))

    return neighbour_dict