У меня есть массив 2D numpy, инициализированный значением 0, и я выбрал 4 точки в этом массиве. Я хочу интерполировать значения между ними, чтобы создать замкнутую форму и заполнить эту форму значением 1. Вот код
a = np.zeros((256, 256))
depth = np.random.randint(50, 200)
corner1 = np.random.randint(0, 100)
corner2 = np.random.randint(150, 250)
top_max = depth - np.random.randint(10, 25)
bottom_max = depth + np.random.randint(10, 25)
top_max_loc = np.random.randint(corner1 + 10, corner2 - 10)
bottom_max_loc = np.random.randint(corner1 + 10, corner2 - 10)
left_point = (depth, corner1)
right_point = (depth, corner2)
top_point = (top_max, top_max_loc)
bottom_point = (bottom_max, bottom_max_loc)
a[left_point] = 1
a[right_point] = 1
a[top_point] = 1
a[bottom_point] = 1
print(left_point)
print(right_point)
print(top_point)
print(bottom_point)
и график точек

То, что я ищу, - это заполнить массив какой-то случайной формой и получить следующие результаты (только желтая форма)
