首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >inpaint()不会产生预期的结果。为什么?

inpaint()不会产生预期的结果。为什么?
EN

Stack Overflow用户
提问于 2017-08-28 11:21:11
回答 1查看 625关注 0票数 0

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

这是我最初的形象。

这是我的面具图像。

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

代码语言:javascript
运行
复制
inpaint(image, vthresh, out, 5.0, CV_INPAINT_NS); //CV_INPAINT_TELEA , CV_INPAINT_NS

但是我不明白为什么我不能使用inpaint()获得任何效果结果。谁能指出原因吗?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-28 12:46:21

给你:

代码语言:javascript
运行
复制
#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);
}

编辑:添加标题和主函数,使其成为独立的文件

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45917789

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档