Reputation: 1
I use OpenCV inpaint func to remove subtitle from image. But output image always have a transparent thread. How to fix it? I want output image more smoothly.
def inpaint_remove(image: 'cv2.typing.MatLike',
chunks: 'typing.Iterable[Rect]') -> 'cv2.typing.MatLike':
image_h, image_w, image_c = image.shape
assert image_c == 3, 'input must be BGR'
mask = np.zeros((image_h, image_w), dtype=np.uint8)
for chunk in chunks:
mask[chunk.top - 10:chunk.bottom + 10, chunk.left - 10:chunk.right + 10].fill(255)
return cv2.inpaint(image, mask, 5, cv2.INPAINT_TELEA)
source image:
output image:
Subtitle remove smoothly.
Upvotes: 0
Views: 76