Reputation: 824
Here I am trying to remove glare.
I used the following line of code to use inpaint()
:
inpaint(image, vthresh, out, 5.0, CV_INPAINT_NS); //CV_INPAINT_TELEA , CV_INPAINT_NS
But I do not understand why I cannot get any effect result using inpaint()
.
Can anyone please point out the reason? Thanks!
Upvotes: 0
Views: 773
Reputation: 6468
Here you go:
#include "opencv2/highgui.hpp"
#include "opencv2/photo.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int args, char** argv)
{
//Read the image
Mat img = imread("/Desktop/apple.png", -1);
//create inpaint mask the size of original image
Mat inpaintMask = img.clone();
//convert mask from rgb to gray
cv::cvtColor(inpaintMask, inpaintMask, cv::COLOR_RGB2GRAY);
// convert mask from gray to binary by thresholding, you can play with 170 and 255 args to achieve desired mask
cv::threshold(inpaintMask, inpaintMask, 170, 255, cv::THRESH_BINARY);
Mat inpainted;
//finally call inpaint function and pass the args
inpaint(img, inpaintMask, inpainted, 3, INPAINT_TELEA);
imshow("image", img);
imshow("mask", inpaintMask);
imshow("inpainted image", inpainted);
cv::waitKey(0);
}
Edit: Added headers and main function to make it a standalone file
Upvotes: 3