您的位置:首页 > 运维架构

使用opneCV对图像进行简单的平滑处理

2019-06-17 07:11 1791 查看

这个可以通过高斯核对图像进行简单的平滑处理

#include <opencv2/opencv.hpp>
int main( int argc, char** argv ) {

// Load an image specified on the command line.
//在执行文件的时候 输入需要载入的图片
cv::Mat image = cv::imread(argv[1],-1);

//分别创建两个窗口 一个是输入窗口 一个是输出窗口
cv::namedWindow( "Example 2-5-in", cv::WINDOW_AUTOSIZE );
cv::namedWindow( "Example 2-5-out", cv::WINDOW_AUTOSIZE );

//显示输入的信号
cv::imshow( "Example 2-5-in", image );

// Create an image to hold the smoothed output
//
cv::Mat out;

// Do the smoothing
// ( Note: Could use GaussianBlur(), blur(), medianBlur() or
// bilateralFilter(). )

//第一次将输如图像运用高斯核模糊
cv::GaussianBlur( image, out, cv::Size(5,5), 3, 3);
//第二次 out由于被分配了临时空间  所以可以作为输入核输出
cv::GaussianBlur( out, out, cv::Size(5,5), 3, 3);

// Show the smoothed image in the output window
//
cv::imshow( "Example 2-5-out", out );

// Wait for the user to hit a key, windows will self destruct
//在结束之前等待用户键盘事件
cv::waitKey( 0 );

}

上一篇博客中给了CMakeLists.txt文件 这里就不再赘述
下面是运行的结果

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: