How to use cv2.xphoto.inpaint in Python3
I'm trying to inpaint an image using cv2.xphoto.inpaint in Python 3, however it just produces a zero image. I installed opencv=3.4.2 via conda. The docs say the images need to be in Lab colorspace, however I get the same result with RGB.
My code:
import cv2
import numpy as np
from scipy.misc import imread
import matplotlib.pyplot as plt
cow = imread('C:/cow.png')
mask = imread('C:/mask.png')
img_lab = cv2.cvtColor(src=cow, code=cv2.COLOR_RGB2Lab)
inverse_mask = np.uint8(np.max(mask == 255, axis=-1))
dst = np.zeros_like(cow)
cv2.xphoto.inpaint(src=img_lab, mask=inverse_mask, dst=dst, algorithmType=cv2.xphoto.INPAINT_SHIFTMAP)
dst = cv2.cvtColor(src=dst, code=cv2.COLOR_Lab2RGB)
plt.imshow(dst)
plt.show()
Used images: