Chinaunix首页 | 论坛 | 博客
  • 博客访问: 295544
  • 博文数量: 32
  • 博客积分: 665
  • 博客等级: 上士
  • 技术积分: 370
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-25 11:20
文章分类

全部博文(32)

文章存档

2023年(1)

2021年(1)

2020年(2)

2018年(3)

2014年(1)

2013年(2)

2012年(9)

2011年(9)

2010年(2)

2009年(2)

分类: C/C++

2011-08-13 23:28:49

7. In this exercise we learn to experiment with parameters by setting good lowThresh and highThresh values in cvCanny(). Load an image with suitably interesting line structures. We’ll use three different high:low threshold settings of 1.5:1, 2.75:1,and 4:1.
 
  1. int exes7()
  2. {
  3. IplImage *img1,*img_gray,*img_edge;
  4. img1 = cvLoadImage("d:\\lines.jpg");
  5. img_gray = cvCreateImage(cvSize(img1->width,img1->height),img1->depth,1);
  6. cvCvtColor(img1,img_gray,CV_RGB2GRAY);
  7. img_edge = cvCloneImage(img_gray);
  8. cvNamedWindow("exes7_gray",CV_WINDOW_AUTOSIZE);
  9. cvNamedWindow("exes7_edgeAt1.5:1",CV_WINDOW_AUTOSIZE);
  10. cvNamedWindow("exes7_edgeAt2.75:1",CV_WINDOW_AUTOSIZE);
  11. cvNamedWindow("exes7_edgeAt4:1",CV_WINDOW_AUTOSIZE);

  12. cvShowImage("exes7_gray",img_gray);

  13. cvCanny(img_gray,img_edge,153,230);
  14. cvShowImage("exes7_edgeAt1.5:1",img_edge);
  15. cvCanny(img_gray,img_edge,83,230);
  16. cvShowImage("exes7_edgeAt2.75:1",img_edge);
  17. cvCanny(img_gray,img_edge,57,230);
  18. cvShowImage("exes7_edgeAt4:1",img_edge);
  19. cvWaitKey(0);
  20. return 0;
  21. }
 
 
上图为原始测试图像。
 
  a. 当高阀值设置小于50时你看到了什么。
以上分别为高阀值设置为45时的三种比例的cvCanny()结果。
 
  b. 当高阀值设置大于50小于100时你看到了什么。
以上分别为高阀值设置为75时的三种比例的cvCanny()结果。
 
  c. 当高阀值设置在100和150之间时你看到了什么。
以上分别为高阀值设置为125时的三种比例的cvCanny()结果。
 
  d. 当高阀值设置在150和200之间时你看到了什么。
以上分别为高阀值设置为175时的三种比例的cvCanny()结果。
 
  e. 当高阀值设置在200和250之间时你看到了什么。
以上分别为高阀值设置为230时的三种比例的cvCanny()结果。
 
  f. 总结结果,尽量提供清楚的解释。
 
阅读(2604) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~