I am trying to use OpenCV's built-in "inpaint" function to restore "damaged" areas of a photo (i.e: crease). However, after using the "inpaint" function, the resulting image contains a distortion in the mask area where inpaint was applied.
From my research, I believe inpainting is used to perform photo restoration. I am not sure if the distortion is occurring because I am not using the inpaint function correctly, or if there other functions/techniques that I must utilize in addition to inpaint?
Below is a code snippet that I am using to perform the inpaint: (OpenCV for iOS)
cv::Mat result;
// Convert UIImage to MAT
cv::Mat originalImage = [source CVMat3];
cv::Mat maskImage = [mask CVGrayscaleMat];
// Grayscale the mask and threshold it
cv::Mat maskMThresh;
cv::threshold(maskImage, maskMThresh, 100, 255, cv::THRESH_BINARY);
// Dilate the mask since thresholding has narrowed it slightly
cv::Mat dilatedMask;
cv::Mat dKernel(7, 7, CV_8U);
cv::dilate(maskMThresh, dilatedMask, dKernel);
// Apply inpaint effect
cv::inpaint(originalImage, dilatedMask, result, 3.0, cv::INPAINT_TELEA);
Below is a photo of the image that I am trying to restore. The mask region is colored red: