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

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

#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文件 这里就不再赘述
下面是运行的结果
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值