#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
int main( )
{
// 读取图像源
cv::Mat srcImage = cv::imread("..\\images\\pool.jpg");
if( srcImage.empty() )
return -1;
// 转为灰度图像
cv::Mat srcGray;
cv::cvtColor(srcImage, srcGray, CV_RGB2GRAY);
cv::imshow("srcGray", srcGray);
// 均值平滑
cv::Mat blurDstImage;
blur( srcGray, blurDstImage, cv::Size(5,5),
cv::Point(-1,-1) );
cv::imshow("blurDstImage", blurDstImage);
// 写入图像文件
cv::imwrite("blurDstImage.png", blurDstImage);
cv::waitKey(0);
return 0;
}
转载:http://blog.youkuaiyun.com/zhuwei1988
本文介绍如何利用OpenCV库进行图像处理,包括读取图像、转换为灰度图、应用均值平滑处理并将处理后的图像显示及保存。通过具体的C++代码示例,展示了图像处理的基本步骤。
17万+

被折叠的 条评论
为什么被折叠?



