canny边沿检测2
2016-03-24 09:27
183 查看
#include "cv.h" #include "highgui.h" char wndname[] = "Edge"; char tbarname[] = "Threshold"; int edge_thresh = 1; IplImage *image = 0, *cedge = 0, *gray = 0, *edge = 0; // 定义跟踪条的 callback 函数 void on_trackbar(int h) { cvSmooth( gray, edge, CV_BLUR, 3, 3, 0 );//////////////////////////////////////////////////////////// //cvNot( gray, edge );//////////////////////////////////////////////////////////////////////////// // 对灰度图像进行边缘检测 cvCanny(gray, edge, (float)edge_thresh, (float)edge_thresh*3, 3); cvZero( cedge ); // copy edge points cvCopy( image,cedge,edge );//掩码到彩色图像上,没这句话就是灰度图像 // 显示图像 cvShowImage(wndname, cedge); } int main( int argc, char** argv ) { image = cvLoadImage("f:\\vc\\cv\\adc.jpg", 1); // Create the output image cedge = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 3); // 将彩色图像转换为灰度图像 gray = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 1); edge = cvCreateImage(cvSize(image->width,image->height), IPL_DEPTH_8U, 1); cvCvtColor(image, gray, CV_BGR2GRAY); // Create a window cvNamedWindow(wndname, 1); // create a toolbar cvCreateTrackbar(tbarname, wndname, &edge_thresh, 100, on_trackbar); //需要手动触发 // Show the image on_trackbar(0); // Wait for a key stroke; the same function arranges events processing cvWaitKey(0); cvReleaseImage(&image); cvReleaseImage(&gray); cvReleaseImage(&edge); cvDestroyWindow(wndname); return 0; }
相关文章推荐
- 开发人员系统功能设计常用办公软件分享
- 基于.NET平台常用的框架整理 [转]
- 计算 TP90TP99TP...
- html常用代码
- POJ 1065 Wooden Sticks
- myeclipse Servlet的创建及访问
- Java内存模型FAQ(五)旧的内存模型有什么问题?
- oracle 11g不能导出空表的多种解决方法
- apache-Jmeter简单使用教程
- solr集成IK分词器
- Ubuntu14.04安装并配置Sublime Text 2
- TLD算法的优点
- 报错:jstl标签——The absolute uri: http://java.sun.com/jsp/jstl/core cannot beresolved in either web.xml o
- Hibernate开发之oracle数据库建表
- C++作业2
- 加载 资源动画遇到的问题
- 在Linux环境下配置Tomcat记录
- OAF控件及常见问题汇总
- android 解决华为系列手机调试时不能打印Logcat日志信息
- Ubuntu快捷键