我的代码如下:
image = np.ones(content_image.shape, dtype=np.float32)
for i, curr_point in enumerate(curr_good_points):
a, b = curr_point.ravel()
for row in range(int(a - BLOCK_LENGTH/2), int(a + (BLOCK_LENGTH+1)/2)):
if row < 0 or row >= image.shape[1]:
continue
for col in range(int(b - BLOCK_LENGTH/2), int(b + (BLOCK_LENGTH+1)/2)):
if col < 0 or col >= image.shape[2]:
continue
for color_channel in range(image.shape[3]):
image[0][row][col][color_channel] = 0
基本上,对于curr_good_points中的每个a,b对,我想在每个颜色通道的每个点周围标记一个框,基本上阻止它。
如果你能帮我缩短这段代码,我真的很感激!谢谢。