您的位置:首页 > 其它

图像读取、转为灰度图像、均值平滑、显示保存操作

2016-11-18 19:43 253 查看
#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.csdn.net/zhuwei1988
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: