def get_neighbours(point, image, visited):
    """
    Get the valid unvisited neighbours for a given point.

    Arguments:
        point {tuple} -- point representation, elements order: x, y, intensity.
        image {np.array} -- the original image.
        visited {np.array} -- visited matrix (booleans).

    Returns:
        Array - includes all the valid unvisited neighbours, can be empty.
    """

    coordinate_differences = [(-1, 0), (0, -1), (1, 0), (0, 1)]

    valid_neighbours = []
    base_x, base_y, _ = point
    height = len(image)
    width = len(image[0])

    for x_offset, y_offset in coordinate_differences:
        new_x = base_x + x_offset
        new_y = base_y + y_offset

        if 0 <= new_x < width and 0 <= new_y < height:
            if visited[new_y][new_x]:
                continue
            valid_neighbours.append((new_x, new_y, image[new_y][new_x]))
            visited[new_y][new_x] = True

    return valid_neighbours