#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "highgui.h"
#include <stdlib.h>
#include <stdio.h> using namespace cv; /// 全局变量
Mat src, erosion_dst, dilation_dst; int erosion_elem = ;
int erosion_size = ;
int dilation_elem = ;
int dilation_size = ;
int const max_elem = ;
int const max_kernel_size = ; /** Function Headers */
void Erosion( int, void* );
void Dilation( int, void* ); /** @function main */
int main( int argc, char** argv )
{
/// Load 图像
src = imread( argv[] ); if( !src.data )
{ return -; } /// 创建显示窗口
namedWindow( "Erosion Demo", CV_WINDOW_AUTOSIZE );
namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE );
cvMoveWindow( "Dilation Demo", src.cols, ); /// 创建腐蚀 Trackbar
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",
&erosion_elem, max_elem,
Erosion ); createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",
&erosion_size, max_kernel_size,
Erosion ); /// 创建膨胀 Trackbar
createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",
&dilation_elem, max_elem,
Dilation ); createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",
&dilation_size, max_kernel_size,
Dilation ); /// Default start
Erosion( , );
Dilation( , ); waitKey();
return ;
} /** @function Erosion */
void Erosion( int, void* )
{
int erosion_type;
if( erosion_elem == ){ erosion_type = MORPH_RECT; }
else if( erosion_elem == ){ erosion_type = MORPH_CROSS; }
else if( erosion_elem == ) { erosion_type = MORPH_ELLIPSE; } Mat element = getStructuringElement( erosion_type,
Size( *erosion_size + , *erosion_size+ ),
Point( erosion_size, erosion_size ) ); /// 腐蚀操作
erode( src, erosion_dst, element );
imshow( "Erosion Demo", erosion_dst );
} /** @function Dilation */
void Dilation( int, void* )
{
int dilation_type;
if( dilation_elem == ){ dilation_type = MORPH_RECT; }
else if( dilation_elem == ){ dilation_type = MORPH_CROSS; }
else if( dilation_elem == ) { dilation_type = MORPH_ELLIPSE; } Mat element = getStructuringElement( dilation_type,
Size( *dilation_size + , *dilation_size+ ),
Point( dilation_size, dilation_size ) );
///膨胀操作
dilate( src, dilation_dst, element );
imshow( "Dilation Demo", dilation_dst );
}

最新文章

  1. 转载 CSS3 经典教程系列:CSS3 盒阴影(box-shadow)详解
  2. django TEMPLATES
  3. step by step 之餐饮管理系统六(数据库访问模块)
  4. 移植DNS服务bind
  5. 418. Sentence Screen Fitting
  6. phpStorm 配置关联php手册
  7. 十步完全理解SQL(转)
  8. Spring Boot启动过程(六):内嵌Tomcat中StandardHost与StandardContext的启动
  9. Google Chrome 默认非安全端口列表
  10. Lettuce_webdriver 自动化测试
  11. 错误 0xc0202049: 数据流任务 1: 无法在只读列“ID”中插入数据
  12. JavaScript:在JS中截取字符串的方法
  13. 【BZOJ1026】【SCOI2009】windy数
  14. mvc 路由配置
  15. 使用sqlyog或者navicat连接mysql提示1862错误解决
  16. java web 乱码终结
  17. Jmeter调用 Json接口测试之关键点申明Content-Type类型
  18. python技巧 switch case语句
  19. C语言 位移 速度 时间 Demo
  20. centos自带的dvd中的官方base源,丢失了可以复制下面的内容

热门文章

  1. F5负载均衡综合实例详解(转)
  2. 吴裕雄--天生自然Linux操作系统:Linux 系统启动过程
  3. 从西班牙、英国出租车与Uber之争,看共享打车未来发展趋势
  4. python3.6内置模块——random详解
  5. Java--平台版本、跨平台、JVM、JDK、JRE
  6. Proe5.0导出PDF至配置文件的相关方法,VC++
  7. Windows安装使用Jenkins
  8. java threadlocal 背景 本质
  9. Opencv笔记(十六)——认识轮廓
  10. Mac中Apache常用命令