Open4

OpenCV 画像修復アルゴリズムを試す

3w36zj63w36zj6

https://ieeexplore.ieee.org/document/990497

import cv2
import numpy as np

img = cv2.imread(filename="input.png")
mask = cv2.imread(filename="mask.png", flags=0)

dst = cv2.inpaint(src=img, inpaintMask=mask, inpaintRadius=3, flags=cv2.INPAINT_NS)

# 表示
cv2.imshow(winname="dst", mat=dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 保存
cv2.imwrite(filename="output_ns.png", img=dst)
3w36zj63w36zj6

An Image Inpainting Technique Based on the Fast Marching Method (INPAINT_TELEA)

https://www.semanticscholar.org/paper/An-Image-Inpainting-Technique-Based-on-the-Fast-Telea/67d0cb47d14150daff08980efbea9f1267d3a4e5

import cv2
import numpy as np

img = cv2.imread(filename="input.png")
mask = cv2.imread(filename="mask.png", flags=0)

dst = cv2.inpaint(src=img, inpaintMask=mask, inpaintRadius=3, flags=cv2.INPAINT_TELEA)

# 表示
cv2.imshow(winname="dst", mat=dst)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 保存
cv2.imwrite(filename="output_telea.png", img=dst)