我试图消除眩光。
我使用以下代码行来使用inpaint()
:
inpaint(image, vthresh, out, 5.0, CV_INPAINT_NS); //CV_INPAINT_TELEA , CV_INPAINT_NS
但我不明白为什么我不能使用inpaint()
获得任何效果。
任何人都可以指出原因吗?谢谢!
答案 0 :(得分:3)
你走了:
#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);
}
编辑:添加标题和主要功能,使其成为独立文件