The following doc seems to be wrong or there is a bug in the cv2.xphoto.inpaint function.
The doc for the mask parameter states:
mask (CV_8UC1), where non-zero pixels indicate valid image area, while zero pixels indicate area to be inpainted
However, it seems that the mask must be 255 for the valid image area and not just non-zero. Either the doc is wrong or the there is a bug in the function.
Test Code
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
from scipy.misc import imread
img = imread('C:/lenna.png')
mask = 255 * np.ones((img.shape[0], img.shape[1]), np.uint8)
mask = cv.circle(mask, (256, 256), 50, 0, -1)
res = np.zeros(img.shape, np.uint8)
cv.xphoto.inpaint(img, mask, res, cv.xphoto.INPAINT_SHIFTMAP)
plt.imshow(res)
plt.show()
If you multiply the mask with something else than 255, the output is a black image.
The documentation is right. That's how a mask should behave. How the mask is used within the implementation is wrong however. I have a PR coming with a fix shortly
Detailed description
The following doc seems to be wrong or there is a bug in the
cv2.xphoto.inpaint
function.The doc for the mask parameter states:
mask (CV_8UC1), where non-zero pixels indicate valid image area, while zero pixels indicate area to be inpainted
However, it seems that the mask must be 255 for the valid image area and not just non-zero. Either the doc is wrong or the there is a bug in the function.
Test Code
If you multiply the mask with something else than 255, the output is a black image.
Also, see this question on the opencv forum: http://answers.opencv.org/question/211657/how-to-use-cv2xphotoinpaint-in-python3/