图像旋转后填充黑色区域

时间:2019-08-08 06:15:58

标签: python opencv

我裁剪并旋转到图片,我想填充边界。我用黑色区域制作了面具。并填充了4点裁剪图像的平均像素。这是填充的图像:

filled

以下是裁剪和旋转后的图像:

cropped_rotated

这是我的代码:

sumarr = (cropped_image[5][5]).astype(int)+cropped_image[-5][-5].astype(int)+cropped_image[5][-5].astype(int)+cropped_image[-5][5].astype(int)
avg1 = sumarr[0]/4 
avg2 = sumarr[1]/4
avg3 = sumarr[2]/4

target_value = [0, 0, 0]
background_value = [avg1, avg2, avg3] 
mask = np.any(new_image == target_value, axis=-1)
new_image[mask] = background_value

如何删除黑线?

0 个答案:

没有答案