加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – opencv2 bluring图像

发布时间:2020-12-16 09:37:13 所属栏目:百科 来源:网络整理
导读:我正在尝试模糊图像,而高光模糊图像但是当我运行我的代码时最终发生的一切都是图像打开而没有模糊.任何人都可以帮我解决这个问题吗? #include opencv2/core/core.hpp#include opencv2/highgui/highgui.hpp#include opencv2/imgproc/imgproc.hpp int main()
我正在尝试模糊图像,而高光模糊图像但是当我运行我的代码时最终发生的一切都是图像打开而没有模糊.任何人都可以帮我解决这个问题吗?

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

 int main() {
//read the image
cv::Mat image= cv::imread("Space_Nebula.jpg");
cv::Mat result;
// create image window
cv::namedWindow("My Image");
//display image
cv::imshow("My Image",image);
//wait key
cv::waitKey(50000);

//blur image
cv::blur(image,result,cv::Size(5,5));
cv::imshow("My Image",image);

//smooth image
cv::GaussianBlur(image,5),1.5);
cv::imshow("My Image",image);

return 1;

}

解决方法

几件事情:您正在将图像处理到称为结果的Mat中,然后显示图像.此外,在最后两次调用imshow之后没有调用waitKey,所以你根本没有看到它们.还有一点:从主要信号完成返回0没有错误.试试这个:

//read the image
cv::Mat image= cv::imread("../../IMG_0080.JPG");
cv::Mat result;
// create image window
cv::namedWindow("My Image");
//display image
cv::imshow("My Image",image);
//wait key
cv::waitKey(0);

//blur image
cv::blur(image,result);
cv::waitKey(0);

//smooth image
cv::GaussianBlur(image,result);
cv::waitKey(0);

return 0;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读