opencv学习(7)——图像平滑
来源:互联网 发布:lazada销量数据分析 编辑:程序博客网 时间:2024/05/21 12:44
#include <iostream>#include <vector>#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/imgcodecs.hpp"#include "opencv2/highgui/highgui.hpp"#include "opencv2/features2d/features2d.hpp"using namespace std;using namespace cv;/// Global Variablesint DELAY_CAPTION = 1500;int DELAY_BLUR = 100;int MAX_KERNEL_LENGTH = 31;Mat src; Mat dst;char window_name[] = "Smoothing Demo";/// Function headersint display_caption( const char* caption );int display_dst( int delay );/** * function main */int main( void ){ namedWindow( window_name, WINDOW_AUTOSIZE ); /// Load the source image src=imread("D:\\software_anz\\opencv\\opencv\\sources\\samples\\data\\fruits.jpg", 1 ); if( display_caption( "Original Image" ) != 0 ) { return 0; } dst = src.clone(); if( display_dst( DELAY_CAPTION ) != 0 ) { return 0; } /// Applying Homogeneous blur if( display_caption( "Homogeneous Blur" ) != 0 ) { return 0; } for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 ) { blur( src, dst, Size( i, i ), Point(-1,-1) ); if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } } /// Applying Gaussian blur if( display_caption( "Gaussian Blur" ) != 0 ) { return 0; } for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 ) { GaussianBlur( src, dst, Size( i, i ), 0, 0 ); if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } } /// Applying Median blur if( display_caption( "Median Blur" ) != 0 ) { return 0; } for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 ) { medianBlur ( src, dst, i ); if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } } /// Applying Bilateral Filter if( display_caption( "Bilateral Blur" ) != 0 ) { return 0; } for ( int i = 1; i < MAX_KERNEL_LENGTH; i = i + 2 ) { bilateralFilter ( src, dst, i, i*2, i/2 ); if( display_dst( DELAY_BLUR ) != 0 ) { return 0; } } /// Wait until user press a key display_caption( "End: Press a key!" ); waitKey(0); return 0;}/** * @function display_caption */int display_caption( const char* caption ){ dst = Mat::zeros( src.size(), src.type() ); putText( dst, caption, Point( src.cols/4, src.rows/2), FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255) ); imshow( window_name, dst ); int c = waitKey( DELAY_CAPTION ); if( c >= 0 ) { return -1; } return 0;}/** * @function display_dst */int display_dst( int delay ){ imshow( window_name, dst ); int c = waitKey ( delay ); if( c >= 0 ) { return -1; } return 0;}
1.putText()函数
C++: void putText(Mat& img, const string& text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=8, bool bottomLeftOrigin=false )
Parameters:
img – 显示文字所在图像.
text – 待显示的文字.
org – 文字在图像中的左下角 坐标.
font – 字体结构体.
fontFace – 字体类型, 可选择字体:FONT_HERSHEY_SIMPLEX, FONT_HERSHEY_PLAIN,FONT_HERSHEY_DUPLEX,FONT_HERSHEY_COMPLEX,FONT_HERSHEY_TRIPLEX,FONT_HERSHEY_COMPLEX_SMALL,FONT_HERSHEY_SCRIPT_SIMPLEX,orFONT_HERSHEY_SCRIPT_COMPLEX,以上所有类型都可以配合 FONT_HERSHEY_ITALIC使用,产生斜体效果。
fontScale – 字体大小,该值和字体内置大小相乘得到字体大小
color – 文本颜色
thickness – 写字的线的粗细,类似于0.38的笔尖和0.5的笔尖
lineType – 线性.
bottomLeftOrigin – true, 图像数据原点在左下角. Otherwise, 图像数据原点在左上角.
2.blur(),GaussianBlur(),medianBlur(),bilateralFilter()
参考:http://blog.csdn.net/vblittleboy/article/details/9187447
0 0
- opencv学习(7)——图像平滑
- 学习OpenCV范例(十)——图像平滑处理
- OpenCV学习笔记(4)——平滑处理图像
- 【学习OpenCV】——2.4对图像进行平滑处理
- OpenCV学习笔记(4)——平滑处理图像
- OpenCV学习之图像平滑
- OpenCV 图像处理——平滑操作
- Opencv 图像处理——平滑处理
- OpenCV-Python—图像平滑和模糊
- OpenCv学习笔记之图像平滑处理
- OpenCV学习笔记_图像平滑
- OpenCV学习笔记11-图像平滑
- openCV—Python(9)——图像平滑与滤波
- OpenCV对图像做简单处理——平滑滤波
- OpenCV入门:简单图像处理实例——平滑滤波
- 【opencv】图像平滑处理
- opencv图像平滑处理
- 基于OpenCV平滑图像
- Android使用Fragment的setUserVisibleHint方法实现延时加载
- 宅米网技术变迁——初创互联网公司的技术发展之路
- Poj 1511 Invitation Cards(spfa)
- redis系列:将redis启动宿主到Windows服务中
- 【CodeForces】222A - Shooshuns and Sequence(思维)
- opencv学习(7)——图像平滑
- <<沧浪之水>> 读书笔记
- 信号量 PK 自旋锁
- java并发锁-Lock之队列同步器
- 7
- C++ 虚函数在基类与派生类对象间的表现及其分析
- EasyUI学习总结(二)——EasyUI布局
- ubuntu 出现signature canot be verified 错误
- TCP/IP详解学习笔记(2)-数据链路层