aihot  2017-05-18 01:46:45  图像处理 |   查看评论   

 求多边形或轮廓的凸包(Hull)

在图像处理和分析中,通常会遇到求物体的凸包或某类型形状的凸包,以下函数可以实现该功能:

 

[cpp]   
 
 
  1. void get_hull(cv::Mat& src,int thresh)  
  2. {  
  3.  Mat src_copy = src.clone();  
  4.  Mat threshold_output;  
  5.  vector<vector<Point> > contours;  
  6.  vector<Vec4i> hierarchy;  
  7.  /// 使用阈值检测边  
  8.  threshold( src_gray, threshold_output, thresh, 255, THRESH_BINARY );  
  9.  /// 查找轮廓 
  10.  findContours( threshold_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );  
  11.  /// 找到每个轮廓的凸包对象 
  12.  vector<vector<Point> >hull( contours.size() );  
  13.  forint i = 0; i < contours.size(); i++ )  
 

除特别注明外,本站所有文章均为 赢咖4注册 原创,转载请注明出处来自求多边形或轮廓的凸包(Hull)

留言与评论(共有 0 条评论)
   
验证码:
[lianlun]1[/lianlun]