#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp" using namespace std;
using namespace cv; /// 全局变量
int DELAY_CAPTION = ;
int DELAY_BLUR = ;
int MAX_KERNEL_LENGTH = ; Mat src; Mat dst;
char window_name[] = "Filter Demo 1"; /// 函数申明
int display_caption( char* caption );
int display_dst( int delay ); /**
* main 函数
*/
int main( int argc, char** argv )
{
namedWindow( window_name, CV_WINDOW_AUTOSIZE ); /// 载入原图像
src = imread( "../images/lena.jpg", ); if( display_caption( "Original Image" ) != ) { return ; } dst = src.clone();
if( display_dst( DELAY_CAPTION ) != ) { return ; } /// 使用 均值平滑
if( display_caption( "Homogeneous Blur" ) != ) { return ; } for ( int i = ; i < MAX_KERNEL_LENGTH; i = i + )
{ blur( src, dst, Size( i, i ), Point(-,-) );
if( display_dst( DELAY_BLUR ) != ) { return ; } } /// 使用高斯平滑
if( display_caption( "Gaussian Blur" ) != ) { return ; } for ( int i = ; i < MAX_KERNEL_LENGTH; i = i + )
{ GaussianBlur( src, dst, Size( i, i ), , );
if( display_dst( DELAY_BLUR ) != ) { return ; } } /// 使用中值平滑
if( display_caption( "Median Blur" ) != ) { return ; } for ( int i = ; i < MAX_KERNEL_LENGTH; i = i + )
{ medianBlur ( src, dst, i );
if( display_dst( DELAY_BLUR ) != ) { return ; } } /// 使用双边平滑
if( display_caption( "Bilateral Blur" ) != ) { return ; } for ( int i = ; i < MAX_KERNEL_LENGTH; i = i + )
{ bilateralFilter ( src, dst, i, i*, i/ );
if( display_dst( DELAY_BLUR ) != ) { return ; } } /// 等待用户输入
display_caption( "End: Press a key!" ); waitKey();
return ;
} int display_caption( char* caption )
{
dst = Mat::zeros( src.size(), src.type() );
putText( dst, caption,
Point( src.cols/, src.rows/),
CV_FONT_HERSHEY_COMPLEX, , Scalar(, , ) ); imshow( window_name, dst );
int c = waitKey( DELAY_CAPTION );
if( c >= ) { return -; }
return ;
} int display_dst( int delay )
{
imshow( window_name, dst );
int c = waitKey ( delay );
if( c >= ) { return -; }
return ;
}

OpenCV 图像平滑处理的更多相关文章

  1. OpenCV图像平滑处理

    图像平滑处理 目标 本教程教您怎样使用各种线性滤波器对图像进行平滑处理,相关OpenCV函数如下: blur GaussianBlur medianBlur bilateralFilter 原理 No ...

  2. 八.使用OpenCv图像平滑操作

    1.cvSmooth函数 函数 cvSmooth 可使用简单模糊.简单无缩放变换的模糊.中值模糊.高斯模糊.双边滤波的不论什么一种方法平滑图像.每一种方法都有自己的特点以及局限. 没有缩放的图像平滑仅 ...

  3. OpenCV 之 图像平滑

    1  图像平滑 图像平滑,可用来对图像进行去噪 (noise reduction) 或 模糊化处理 (blurring),实际上图像平滑仍然属于图像空间滤波的一种 (低通滤波) 既然是滤波,则图像中任 ...

  4. 图像滤波与OpenCV中的图像平滑处理

    .About图像滤波 频率:可以这样理解图像频率,图像中灰度的分布构成一幅图像的纹理.图像的不同本质上是灰度分布规律的不同.但是诸如"蓝色天空"样的图像有着大面积近似的灰度强度,而 ...

  5. OpenCV图像处理篇之图像平滑

    图像平滑算法 图像平滑与图像模糊是同一概念,主要用于图像的去噪.平滑要使用滤波器.为不改变图像的相位信息,一般使用线性滤波器,其统一形式例如以下: %20\Large%20g(i,j)=\sum_{k ...

  6. 13、OpenCV实现图像的空间滤波——图像平滑

    1.空间滤波基础概念 1.空间滤波基础 空间滤波一词中滤波取自数字信号处理,指接受或拒绝一定的频率成分,但是空间滤波学习内容实际上和通过傅里叶变换实现的频域的滤波是等效的,故而也称为滤波.空间滤波主要 ...

  7. OpenCV学习笔记(8)——图像平滑

    使用不同的低筒滤波器对图像进行模糊 使用自定义的率弄起对图像进行卷积(2D卷积) 2D卷积 与信号一样,我们也可以对2D图像实施低通滤波,高通滤波等.LPF帮助我们去除噪声,模糊图像.而HPF帮助我们 ...

  8. Python 图像处理 OpenCV (7):图像平滑(滤波)处理

    前文传送门: 「Python 图像处理 OpenCV (1):入门」 「Python 图像处理 OpenCV (2):像素处理与 Numpy 操作以及 Matplotlib 显示图像」 「Python ...

  9. OpenCV计算机视觉学习(4)——图像平滑处理(均值滤波,高斯滤波,中值滤波,双边滤波)

    如果需要处理的原图及代码,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice &q ...

随机推荐

  1. JavaScript—面向对象 贪吃蛇_2 游戏对象

    游戏对象 function Game(map) { this.map = map; this.food = new Food(this.map) this.snake = new Snake(this ...

  2. Linux-IO多路复用select函数实践

    #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/time.h ...

  3. CSS3-选中的锚链接改变指定样式

    1.css样式 主角就是:target <a> 标签的 target 属性规定在何处打开链接文档,连接文档也可以是一个样式. 如果在一个 <a> 标签内包含一个 target ...

  4. linux.linuxidc.com - /2011年资料/Android入门教程/

    本文转自 http://itindex.net/detail/15843-linux.linuxidc.com-%E8%B5%84%E6%96%99-android Shared by Yuan 用户 ...

  5. Springboot整合Junit单元测试

    1.在pom.xml中添加junit环境的依赖 <dependency> <groupId>org.springframework.boot</groupId> & ...

  6. rpc框架解释

    远程过程调用协议RPC(Remote Procedure Call Protocol) RPC是指远程过程调用,也就是说两台服务器A,B,一个应用部署在A服务器上,想要调用B服务器上应用提供的函数/方 ...

  7. go语言学习资料

    Go语言圣经(中文版): https://docs.hacknode.org/gopl-zh/index.html Go语言高级编程(Advanced Go Programming) https:// ...

  8. SpringBoot 2.2.2集成ElasticSearch 7.5.1

    前言:现在公司有一个项目要用到检索功能,检索上面现在最常用的是Solr/ES,最后经过对比选择了ElasticSearch开源组件包,因为这个是公司的一个产品项目,技术版本当然要用最新的啦,最后完全确 ...

  9. 脚本kafka-configs.sh用法解析

    引用博客来自李志涛:https://www.cnblogs.com/lizherui/p/12275193.html 前言介绍 网络上针对脚本kafka-configs.sh用法,也有一些各种文章,但 ...

  10. Golang 热编译rizla 插件

    今天在写gin接口的时候,每次添加或修改个接口都需要重启项目才能测试,感觉很麻烦. 因为beego有bee工具,bee run启动项目fsnotify会监控文件变动,经查发现在iris项目中有个插件支 ...