0

在这里,我试图消除眩光。

这是我的原图。
在此处输入图像描述

这是我的面具图像。
在此处输入图像描述

我使用以下代码行来使用inpaint()

inpaint(image, vthresh, out, 5.0, CV_INPAINT_NS); //CV_INPAINT_TELEA , CV_INPAINT_NS

但我不明白为什么我无法使用inpaint(). 谁能指出原因?谢谢!

4

1 回答 1

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);
}

编辑:添加标题和主要功能以使其成为独立文件

于 2017-08-28T12:46:21.970 回答