在这里,我试图消除眩光。
这是我最初的形象。
这是我的面具图像。
我使用了以下代码行来使用inpaint()
inpaint(image, vthresh, out, 5.0, CV_INPAINT_NS); //CV_INPAINT_TELEA , CV_INPAINT_NS
但是我不明白为什么我不能使用inpaint()
获得任何效果结果。谁能指出原因吗?谢谢!
发布于 2017-08-28 12:46:21
给你:
#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);
}
编辑:添加标题和主函数,使其成为独立的文件
https://stackoverflow.com/questions/45917789
复制相似问题