zoukankan      html  css  js  c++  java
  • OpenCV图像处理中常用函数汇总(2)

     1 // 霍夫线变换 hough
     2     vector<Vec2f> lines;//定义一个矢量结构lines用于存放得到的线段矢量集合
     3     HoughLines(dstImage,lines,1,CV_PI/180,150);
     4     //依次在图中绘制出每条线段
     5     for (size_t i = 0;i < lines.size();i++)
     6     {
     7         float rho = lines[i][0],theta = lines[i][1];
     8         Point pt1,pt2;
     9         double a = cos(theta),b = sin(theta);
    10         double x0 = rho*a,y0 = rho*b;//A是与直线垂直的线交点 坐标为(x0,y0)=(rho*cos(theta),rho*sin(theta));
    11         //向上取整函数cvCeil、向下取整函数cvFloor、四舍五入函数cvRound;
    12 
    13         pt1.x = cvRound(x0+1000*(-b));//1000是取两点之间的距离,可操控量;
    14         pt1.y = cvRound(y0+1000*(a));//pt1是位于A较上的一个点;
    15         pt2.x = cvRound(x0-1000*(-b));//pt2是位于A较下的一个点;
    16         pt2.y = cvRound(y0-1000*(a));
    17 
    18         line(dstImage,pt1,pt2,Scalar(55,100,195),1,CV_AA);
    19     }
    20     imshow("hough检测直线图",dstImage);
    21     //waitKey(0);

     //霍夫变换线、圆
    1
    //! finds lines in the black-n-white image using the standard or pyramid Hough transform 2 CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, 3 double rho, double theta, int threshold, 4 double srn=0, double stn=0 ); 5 6 //! finds line segments in the black-n-white image using probabalistic Hough transform 7 CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines, 8 double rho, double theta, int threshold, 9 double minLineLength=0, double maxLineGap=0 ); 10 11 //! finds circles in the grayscale image using 2+1 gradient Hough transform 12 CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles, 13 int method, double dp, double minDist, 14 double param1=100, double param2=100, 15 int minRadius=0, int maxRadius=0 );
    
    
    //扩充边界函数
    //
    ! copies 2D array to a larger destination array with extrapolation of the outer part of src using the specified border mode CV_EXPORTS_W void copyMakeBorder( InputArray src, OutputArray dst, int top, int bottom, int left, int right, int borderType, const Scalar& value=Scalar() );
    
    
     // 计算非0个数  平均数 标准差
    1
    //! computes the number of nonzero array elements 2 CV_EXPORTS_W int countNonZero( InputArray src ); 3 //! returns the list of locations of non-zero pixels 4 CV_EXPORTS_W void findNonZero( InputArray src, OutputArray idx ); 5 6 //! computes mean value of selected array elements 7 CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask=noArray()); 8 //! computes mean value and standard deviation of all or selected array elements 9 CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, 10 InputArray mask=noArray());
     
  • 相关阅读:
    浅谈Lyndon分解
    【CF914G】Sum the Fibonacci(FWT)
    【洛谷6914】[ICPC2015 WF] Tours(非树边随机边权,树边边权异或)
    【洛谷7143】[THUPC2021 初赛] 线段树(动态规划)
    【洛谷7325】[WC2021] 斐波那契(数论)
    【CF666E】Forensic Examination(广义后缀自动机+线段树合并)
    【CF685C】Optimal Point(二分答案)
    【洛谷7364】有标号二分图计数(多项式开根)
    【CF679E】Bear and Bad Powers of 42(ODT+线段树)
    【洛谷5307】[COCI2019] Mobitel(动态规划)
  • 原文地址:https://www.cnblogs.com/ggYYa/p/5768042.html
Copyright © 2011-2022 走看看