[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN103136758B - Rapid edge detecting method based on orthogonal polynomial fitting - Google Patents

Rapid edge detecting method based on orthogonal polynomial fitting Download PDF

Info

Publication number
CN103136758B
CN103136758B CN201310097073.2A CN201310097073A CN103136758B CN 103136758 B CN103136758 B CN 103136758B CN 201310097073 A CN201310097073 A CN 201310097073A CN 103136758 B CN103136758 B CN 103136758B
Authority
CN
China
Prior art keywords
edge
formula
window image
fitting
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201310097073.2A
Other languages
Chinese (zh)
Other versions
CN103136758A (en
Inventor
孙秋成
刘健豪
刘仁云
于繁华
李纯净
曹蕾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changchun Normal University
Original Assignee
Changchun Normal University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Changchun Normal University filed Critical Changchun Normal University
Priority to CN201310097073.2A priority Critical patent/CN103136758B/en
Publication of CN103136758A publication Critical patent/CN103136758A/en
Application granted granted Critical
Publication of CN103136758B publication Critical patent/CN103136758B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Image Analysis (AREA)

Abstract

基于正交多项式拟合的快速边缘检测方法属于亚像素图像边缘检测领域,该二维边缘检测方法在每次对窗口图像数值化处理时都利用空间矩计算边缘的投影方向并结合投影公式将二维边缘检测转化为一维边缘检测,避免了拟合灰度曲面所需复杂运算。运用正交多项式拟合得到计算一维边缘点位置的解析公式,有效克服了拟合法通常不能获得解析解的难题,该解析公式形式简单,含有较少的内积计算,最终结合检测得到的边缘点位置和边缘法线方向,确定窗口图像中边缘直线的位置。该方法大幅提高了运算速度,能够适应实时性要求较高的二维边缘检测过程,还兼备了基于矩的方法或插值法运算速度快以及拟合法对图像噪声不敏感的特性,能大幅提高边缘检测的精度和速度。

The fast edge detection method based on orthogonal polynomial fitting belongs to the field of sub-pixel image edge detection. This two-dimensional edge detection method uses the spatial moment to calculate the projection direction of the edge and combines the projection formula to calculate the projection direction of the edge every time the window image is numerically processed. The one-dimensional edge detection is transformed into one-dimensional edge detection, which avoids the complex operation required for fitting the gray surface. The analytical formula for calculating the position of one-dimensional edge points is obtained by using orthogonal polynomial fitting, which effectively overcomes the problem that the fitting method cannot usually obtain an analytical solution. The point position and edge normal direction determine the position of the edge line in the window image. This method greatly improves the calculation speed and can adapt to the two-dimensional edge detection process with high real-time requirements. It also has the characteristics of fast calculation speed of the moment-based method or interpolation method and the insensitivity of the fitting method to image noise, which can greatly improve the edge detection process. Accuracy and speed of detection.

Description

基于正交多项式拟合的快速边缘检测方法A Fast Edge Detection Method Based on Orthogonal Polynomial Fitting

技术领域technical field

本发明属于亚像素图像边缘检测领域,具体涉及一种基于正交多项式拟合的快速边缘检测方法。The invention belongs to the field of sub-pixel image edge detection, in particular to a fast edge detection method based on orthogonal polynomial fitting.

背景技术Background technique

图像的最基本特征是边缘,所谓边缘是指其周围像素灰度有阶跃变化或屋顶变化的那些像素的集合,早期使用的边缘检测方法多为像素级的,这些方法的定位精度为整像素,即,能判断出边缘位置处于某一个像素内,但无法在该像素内再进行细分,然而随着工业检测对测量精度要求的不断提高,像素级精度已经不能满足实际检测的要求,亚像素方法应运而生。The most basic feature of an image is the edge. The so-called edge refers to the collection of pixels whose surrounding pixel gray levels have step changes or roof changes. The edge detection methods used in the early days are mostly pixel-level, and the positioning accuracy of these methods is an integer pixel. , that is, it can be judged that the edge position is in a certain pixel, but it cannot be further subdivided in this pixel. However, with the continuous improvement of the measurement accuracy requirements of industrial inspection, the pixel-level accuracy can no longer meet the actual detection requirements. The pixel method came into being.

现有的亚像素级的边缘检测方法可以归纳为三种:基于矩的方法,基于最小二乘法的拟合法和基于插值的方法,基于最小二乘法的拟合法其鲁棒性较强,对噪声不敏感,因此检测边缘相对准确,但是由于需要非线性的拟合运算,所以计算速度相对较慢,无法满足实时检测的加工和监测场合。而基于矩的方法或基于插值的方法,二者的计算速度均比较快,但这两种检测方法又都对图像噪声更为敏感,在图像噪声较多的情况下,其二者的检测精度都会受到较大影响。The existing sub-pixel-level edge detection methods can be summarized into three types: the method based on moments, the method based on least squares and the method based on interpolation. Insensitive, so the detection edge is relatively accurate, but due to the need for nonlinear fitting operations, the calculation speed is relatively slow, which cannot meet the processing and monitoring occasions of real-time detection. The moment-based method or the interpolation-based method both have faster calculation speeds, but these two detection methods are more sensitive to image noise. In the case of more image noise, the detection accuracy of the two will be greatly affected.

与本发明较为接近的现有技术较多,比如,李庆利等的《一种基于多项式插值改进的亚像素细分算法》[J].北京科技大学学报,2003,25(3):280-283,该方法应用在经典Sobel算子基础上构造出的方向模板,对灰度图像进行处理,得到梯度图像,然后在梯度图像上沿目标边缘的梯度方向进行多项式插值法亚像素细分计算,对目标边缘进行亚像素精确定位。然而,该方法继承了插值法对图像噪声敏感的特性,在图像噪声较多的情况下,其边缘检测精度就会受到严重干扰。There are many existing technologies that are relatively close to the present invention, such as "A Subpixel Subdivision Algorithm Based on Polynomial Interpolation Improvement" by Li Qingli et al. [J]. Journal of Beijing University of Science and Technology, 2003, 25 (3): 280-283 , this method applies the direction template constructed on the basis of the classic Sobel operator to process the gray image to obtain a gradient image, and then performs sub-pixel subdivision calculations on the gradient image along the gradient direction of the target edge by polynomial interpolation method. Sub-pixel accurate localization of object edges. However, this method inherits the characteristic that the interpolation method is sensitive to image noise, and its edge detection accuracy will be seriously disturbed when the image is noisy.

王建民等在《空间矩亚像素细分算法的研究》[J]光学技术.1999,No,4,3-6。提出了一种基于空间矩的亚像素边缘检测算法,能够较快的实现亚像素边缘检测。该方法的基本模型是阶跃边缘模型,然而在实际成像过程中受到成像噪声的作用,边缘模型往往不严格阶跃的,而是模糊的,因此该方法容易受到噪声的干扰,从而影响边缘的定位精度。Wang Jianmin et al. in "Research on Sub-pixel Subdivision Algorithm of Spatial Moment" [J] Optical Technology. 1999, No, 4, 3-6. A sub-pixel edge detection algorithm based on spatial moments is proposed, which can achieve sub-pixel edge detection quickly. The basic model of this method is a step-edge model. However, in the actual imaging process, affected by imaging noise, the edge model is often not strictly step-like, but fuzzy. Therefore, this method is easily disturbed by noise, which affects the edge positioning accuracy.

又如,陈静等在《快速多项式拟合亚像素边缘检测算法的研究》[J].应用光学2011,32(1):91-95.DOI:10.3969/j.issn.1002-2082.2011.01.020中介绍了一种基于多项式拟合的快速亚像素边缘检测算法,该算法根据图像的灰度分布,运用三次多项式拟合图像的边缘实现亚像素定位,从而达到较高的定位精度。该方法虽然也利用了多项式拟合消除噪声干扰,但它给出的计算公式中含有较多复杂的内积运算,会导致求解过程较慢,因此该检测方法的求解过程较慢,无法适应对实效性要求较高的实时边缘检测。此外,二维边缘检测是实现亚像素边缘定位的主要应用手段,而该方法仅限于对一维边缘检测方法的讨论,并未给出如何将其一维检测方法应用在二维边缘检测上的方法。Another example, Chen Jing et al. in "Research on Fast Polynomial Fitting Sub-pixel Edge Detection Algorithm" [J]. Applied Optics 2011, 32(1):91-95.DOI:10.3969/j.issn.1002-2082.2011.01.020 A fast sub-pixel edge detection algorithm based on polynomial fitting is introduced in this paper. According to the gray distribution of the image, the algorithm uses a cubic polynomial to fit the edge of the image to achieve sub-pixel positioning, so as to achieve high positioning accuracy. Although this method also uses polynomial fitting to eliminate noise interference, the calculation formula it gives contains more complicated inner product operations, which will lead to a slow solution process. Therefore, the solution process of this detection method is slow and cannot adapt to the Real-time edge detection with high effectiveness requirements. In addition, two-dimensional edge detection is the main application method to realize sub-pixel edge localization, but this method is limited to the discussion of one-dimensional edge detection method, and does not give how to apply its one-dimensional detection method to two-dimensional edge detection method.

孙秋成等在《一种亚像素精度的边缘检测方法》北京工业大学学报.2009.10.35(10),1332-1337.提出了一种基于贝塞尔边缘拟合模型的亚像素边缘检测算法,通过拟合修正贝塞尔边缘模型,得到图像边缘的亚像素位置。该拟合方法对噪声具有较好的鲁棒性,具有较高的边缘定位精度。但是由于不存在计算边缘的解析公式,每次检测过程中都需要进行拟合运算,会导致拟合方法检测速度较慢,尤其当该方法应用到二维边缘检测时,需要拟合三维灰度曲面,由于拟合函数过于复杂,检测速度会更慢。Sun Qiucheng et al. proposed a sub-pixel edge detection algorithm based on the Bessel edge fitting model in "A Sub-pixel Accurate Edge Detection Method", Journal of Beijing University of Technology. 2009.10.35(10), 1332-1337. By fitting and correcting the Bessel edge model, the sub-pixel position of the image edge is obtained. The fitting method has good robustness to noise and high edge location accuracy. However, since there is no analytical formula for calculating the edge, a fitting operation is required in each detection process, which will cause the detection speed of the fitting method to be slow, especially when the method is applied to two-dimensional edge detection, it is necessary to fit the three-dimensional grayscale For curved surfaces, the detection speed will be slower due to the complexity of the fitting function.

发明内容Contents of the invention

为了解决现有亚像素边缘检测方法中,基于矩或基于插值的方法都相对容易受到图像噪声的干扰,而现有拟合类方法因为不存在计算边缘点的解析公式,从而导致在每次一维边缘检测过程中都需要进行拟合运算,特别是在二维边缘检测中需要进行曲面拟合运算,由此造成其运算过程复杂,求解速度慢,无法适应实时性要求较高的二维边缘检测的技术问题,本发明提供一种基于正交多项式拟合的快速边缘检测方法。In order to solve the existing sub-pixel edge detection methods, the methods based on moments or interpolation are relatively susceptible to interference from image noise, and the existing fitting methods do not have an analytical formula for calculating edge points, which leads to In the process of two-dimensional edge detection, fitting operation is required, especially in two-dimensional edge detection, surface fitting operation is required, which makes the operation process complicated, the solution speed is slow, and it cannot adapt to the two-dimensional edge with high real-time requirements. To solve the technical problem of detection, the present invention provides a fast edge detection method based on orthogonal polynomial fitting.

本发明解决技术问题所采取的技术方案如下:The technical solution adopted by the present invention to solve the technical problems is as follows:

基于正交多项式拟合的快速边缘检测方法包括如下步骤:A fast edge detection method based on orthogonal polynomial fitting includes the following steps:

步骤一:图像整像素边缘检测和定位:利用Canny边缘检测算子对图像进行边缘检测,获取图像边缘所在的所有整像素方格的坐标及灰度;Step 1: Image integer pixel edge detection and positioning: Use the Canny edge detection operator to perform edge detection on the image, and obtain the coordinates and gray levels of all integer pixel squares where the image edge is located;

步骤二:提取窗口图像:以步骤一所述的含有边缘的整像素方格为中心,提取图像边缘所在区域的一个局部方形灰度矩阵Am×m,即窗口图像,窗口图像中包含一小段待检测边缘直线;Step 2: Extract the window image: take the integer pixel square containing the edge described in step 1 as the center, extract a local square grayscale matrix A m×m of the area where the edge of the image is located, that is, the window image, and the window image contains a small segment Edge line to be detected;

步骤三:窗口图像的数值化处理,具体包括以下步骤:Step 3: Numerical processing of the window image, specifically including the following steps:

步骤3.1:以步骤二所述的窗口图像的中心为原点,建立xoy直角坐标系,其中横轴为x轴,纵轴为y轴;坐标系的单位长度是1个像素;Step 3.1: Taking the center of the window image described in step 2 as the origin, establish a xoy rectangular coordinate system, wherein the horizontal axis is the x axis and the vertical axis is the y axis; the unit length of the coordinate system is 1 pixel;

步骤3.2:设窗口图像中每个像素方格中心点在如步骤3.1所述直角坐标系中的坐标为(x,y),则将整像素方格的灰度值作为该点对应的灰度值,并在原平面直角坐标系中加入与该平面直角坐标系垂直的Z轴构成空间立体坐标系,Z轴表示像素点对应的灰度值,由此获得关于灰度值随坐标点变化的离散灰度分布函数I(x,y);Step 3.2: Set the coordinates of the center point of each pixel grid in the window image in the Cartesian coordinate system as described in step 3.1 to be (x, y), then use the gray value of the entire pixel grid as the gray value corresponding to the point value, and add the Z axis perpendicular to the plane rectangular coordinate system to the original plane rectangular coordinate system to form a spatial three-dimensional coordinate system, and the Z axis represents the gray value corresponding to the pixel point, thus obtaining the discrete value of the gray value changing with the coordinate point Gray distribution function I(x,y);

步骤3.3:在直角坐标系平面内存在一条通过坐标系原点并垂直于待检测的边缘直线的直线,该直线为边缘的法线,并定义该边缘法线与水平横轴的夹角为θ;Step 3.3: There is a straight line passing through the origin of the coordinate system and perpendicular to the straight line of the edge to be detected in the plane of the rectangular coordinate system. This straight line is the normal line of the edge, and the angle between the normal line of the edge and the horizontal horizontal axis is defined as θ;

步骤四:确定边缘法线的方向,其具体步骤为:Step 4: Determine the direction of the edge normal, the specific steps are:

步骤4.1:利用空间矩计算公式,计算步骤3.1中提取的方形窗口图像内接圆对应的各阶空间矩MpqStep 4.1: Using the calculation formula of spatial moments, calculate the spatial moments M pq of each order corresponding to the inscribed circle of the square window image extracted in step 3.1:

Mm pqpq == ∫∫ ∫∫ xx 22 ++ ythe y 22 ≤≤ rr xx pp ythe y qq ff (( xx ,, ythe y )) dxdydxdy ,, pp ,, qq == 0,10,1 ,, .. .. .. ,, NN ·&Center Dot; ·&Center Dot; ·&Center Dot; ·&Center Dot; ·· ·&Center Dot; (( 11 ))

式(1)中f(x,y)表示图像像素的连续灰度分布函数,p和q表示空间矩的阶数,是正整数,r表示内接圆的半径;In formula (1), f(x, y) represents the continuous gray scale distribution function of image pixels, p and q represent the order of spatial moments, which are positive integers, and r represents the radius of the inscribed circle;

步骤4.2:将步骤4.1所述连续灰度分布函数f(x,y)以步骤3.2所述Z轴为中心旋转如步骤3.3所述的θ角,在窗口图像内会得到新的连续灰度分布函数,此时窗口图像内接圆对应的各阶空间矩的数值发生改变;Step 4.2: Rotate the continuous grayscale distribution function f(x, y) described in step 4.1 around the Z axis described in step 3.2 by the angle θ as described in step 3.3, and a new continuous grayscale distribution will be obtained in the window image function, at this time, the value of the spatial moment of each order corresponding to the inscribed circle of the window image changes;

步骤4.3:根据空间矩旋转不变性理论,得到旋转后内接圆对应的空间矩M'pq与未旋转之前的空间矩Mpq的关系如下:Step 4.3: According to the theory of spatial moment rotation invariance, the relationship between the spatial moment M' pq corresponding to the inscribed circle after rotation and the spatial moment M pq before rotation is obtained as follows:

Mm pqpq ′′ == ΣΣ ii == 00 pp ΣΣ sthe s == 00 qq pp ii qq sthe s (( -- 11 )) qq -- sthe s (( coscos θθ )) pp -- ii ++ sthe s ×× (( sinsin θθ )) qq ++ ii -- sthe s Mm pp ++ qq -- ii -- sthe s ,, ii ++ sthe s ·· ·· ·· ·· ·· ·· (( 22 ))

i表示从0到p的整数,s表示从0到q的整数,当连续灰度分布函数f(x,y)旋转θ角后,窗口图像中的待检测的边缘直线与步骤3.1所述坐标系横轴x垂直,即旋转后窗口图像内接圆对应的灰度函数关于横轴x对称,根据空间矩计算公式可知,旋转后窗口图像内接圆对应的空间矩M'01=0,此时p=0,q=1,利用式(2)求出:i represents an integer from 0 to p, s represents an integer from 0 to q, when the continuous gray distribution function f(x, y) is rotated by the angle θ, the edge line to be detected in the window image and the coordinates described in step 3.1 The horizontal axis x is vertical, that is, the grayscale function corresponding to the inscribed circle of the window image after rotation is symmetrical about the horizontal axis x. According to the calculation formula of the space moment, the space moment M' 01 corresponding to the inscribed circle of the window image after rotation is 0 = 0. When p=0, q=1, use formula (2) to get:

M'01=-sinθ·M10+cosθ·M01=0……(3)M' 01 =-sinθ·M 10 +cosθ·M 01 =0...(3)

其中M10和M01表示未旋转之前内接圆对应的空间矩;Among them, M 10 and M 01 represent the space moment corresponding to the inscribed circle before rotation;

步骤4.4:利用空间矩计算模板代替公式(1),并将窗口图像内接圆中像素点的离散灰度函数I(x,y)代入到上述的离散模板公式中,以计算式(3)中的空间矩M01和M10的值;Step 4.4: Use the spatial moment calculation template to replace formula (1), and substitute the discrete grayscale function I(x, y) of the pixels in the inscribed circle of the window image into the above discrete template formula to calculate formula (3) The values of spatial moments M 01 and M 10 in ;

步骤4.5:根据式(3)得到式(4),将步骤4.4得到的空间矩M01和M10的值代入式(4),求得θ角的值:Step 4.5: Obtain formula (4) according to formula (3), and substitute the values of spatial moments M 01 and M 10 obtained in step 4.4 into formula (4) to obtain the value of angle θ:

θθ == arctanarctan Mm 0101 Mm 1010 ·· ·· ·· ·&Center Dot; ·&Center Dot; ·&Center Dot; (( 44 ))

步骤4.6:设边缘法线为新的水平横轴X,以步骤4.5中的θ角作为投影角,则步骤3.2所述的所有点在像素平面内的像素坐标(x,y)与边缘法线所在横轴上点坐标X存在如下投影公式:Step 4.6: Set the edge normal as the new horizontal horizontal axis X, and take the θ angle in step 4.5 as the projection angle, then the pixel coordinates (x, y) of all points described in step 3.2 in the pixel plane and the edge normal The point coordinate X on the horizontal axis has the following projection formula:

X=xcosθ+ysinθ……(5)X=xcosθ+ysinθ...(5)

式(5)中X值表示窗口图像内的被投影点按投影角θ投影后,对应投影点在步骤4.6所述的新横轴X上的坐标读数值;The X value in formula (5) represents the coordinate reading value of the projected point on the new horizontal axis X described in step 4.6 after the projected point in the window image is projected according to the projection angle θ;

步骤五:基于正交多项式拟合的一维边缘点检测,确定边缘法线与待检测边缘直线的交点位置,其包括如下步骤:Step 5: Based on one-dimensional edge point detection based on orthogonal polynomial fitting, determine the intersection position of the edge normal and the edge line to be detected, which includes the following steps:

步骤5.1:将步骤3.2所述Z轴与步骤4.6所述水平横轴X重新构成一个一维边缘点检测所需的平面直角坐标系XOZ,即投影平面;Step 5.1: reconstitute the Z-axis described in step 3.2 and the horizontal horizontal axis X described in step 4.6 into a plane Cartesian coordinate system XOZ required for one-dimensional edge point detection, that is, the projection plane;

根据投影公式(5)将窗口图像内各个像素方格的中心点投影到步骤4.6所述的水平横轴X上;在平面直角坐标系XOZ中,得到边缘法线上投影点灰度值的离散灰度分布函数(Xi,Zi),i=1,...,2n+1;According to the projection formula (5), the center point of each pixel grid in the window image is projected onto the horizontal horizontal axis X described in step 4.6; in the plane Cartesian coordinate system XOZ, the discrete gray value of the projected point on the edge normal is obtained Gray distribution function (X i , Z i ), i=1,...,2n+1;

步骤5.2:投影点坐标的归一化,若如步骤5.1所述横轴X上形成的投影点数目为2n+1个,设 L = X 2 n + 1 - X 1 2 , 并令 x i = X i L i = 1 , . . . , 2 n + 1 , 则有xi∈[-1,1];Step 5.2: Normalization of the projection point coordinates, if the number of projection points formed on the horizontal axis X as described in step 5.1 is 2n+1, set L = x 2 no + 1 - x 1 2 , and order x i = x i L i = 1 , . . . , 2 no + 1 , Then there are x i ∈ [-1,1];

步骤5.3:计算正交多项式系,利用schemite正交化方法计算在[-1,1]区间上关于权函数ρ(x)=1的正交多项式系;Step 5.3: Calculate the orthogonal polynomial system, and use the schemite orthogonalization method to calculate the orthogonal polynomial system about the weight function ρ(x)=1 on the [-1,1] interval;

步骤5.4:取步骤5.3中的前四阶正交基函数 Step 5.4: Take the first four order orthogonal basis functions in step 5.3

以式(7)作为拟合基底进行三次正交多项式拟合,则拟合多项式的方程为:Using formula (7) as the fitting basis to carry out cubic orthogonal polynomial fitting, the equation of fitting polynomial is:

式(8)中的拟合多项式的系数{a1,a2,a3,a4}为待求的拟合参数;The coefficients {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial in formula (8) are the fitting parameters to be found;

步骤5.5:利用式(8)可推导出拟合多项式的方程对应的法方程组如下:Step 5.5: Using formula (8), the normal equations corresponding to the equations for fitting polynomials can be deduced as follows:

式(9)中表示离散向量与自身的内积,Z=[Z1,Z2,……,Z2n+1]T是离散灰度值向量,表示Z与的内积;In formula (9) represents a discrete vector Inner product with itself, Z=[Z 1 ,Z 2 ,……,Z 2n+1 ] T is a discrete gray value vector, Indicates that Z and inner product;

步骤5.6:利用方程组式(9)得出拟合多项式的系数{a1,a2,a3,a4}计算公式:Step 5.6: Use equation (9) to obtain the calculation formula of the coefficient {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial:

将各已知量代入式(10),分别得a0、a1、a2和a3的结果;Substituting each known quantity into formula (10), the results of a 0 , a 1 , a 2 and a 3 are obtained respectively;

步骤5.7:将步骤5.6所述拟合多项式的结果作为已知量代入式(8),拟合多项式方程变为:Step 5.7: Substitute the result of the polynomial fitting described in step 5.6 into equation (8) as a known quantity, and the polynomial fitting equation becomes:

步骤5.8:计算三次多项式式(11)的二阶导数为零点,即:Step 5.8: Compute the second order derivative of the cubic polynomial (11) to zero, namely:

求解并获得上述使式(12)的二阶导数为零的点的坐标;Solve and obtain the coordinates of the point where the second order derivative of the above formula (12) is zero;

步骤5.9:求解式(12)并将计算结果反归一化,获得一维边缘点在横轴X上的位置坐标R,即:Step 5.9: Solve formula (12) and denormalize the calculation results to obtain the position coordinate R of the one-dimensional edge point on the horizontal axis X, namely:

式(13)即为计算一维边缘点位置的解析公式,该边缘点为边缘法线与待检测边缘直线的交点;Equation (13) is the analytical formula for calculating the position of a one-dimensional edge point, which is the intersection point of the edge normal and the edge line to be detected;

步骤六:利用式(13)确定窗口图像内过原点边缘法线与待检测边缘直线的交点位置,利用步骤4.5获得边缘法线的方向角θ,确定待检测的边缘直线在xoy坐标系中的方程,从而实现在窗口图像中待检测的边缘直线的亚像素定位;Step 6: Use formula (13) to determine the intersection position of the edge normal passing through the origin in the window image and the edge straight line to be detected, use step 4.5 to obtain the direction angle θ of the edge normal, and determine the edge straight line to be detected in the xoy coordinate system equation, so as to realize the sub-pixel positioning of the edge line to be detected in the window image;

步骤七:由操作者重新选择步骤一所述整像素方格,并重复步骤二至步骤六,以获取新取得的窗口图像中待检测的边缘直线的亚像素定位;Step 7: The operator reselects the whole pixel grid described in step 1, and repeats steps 2 to 6 to obtain the sub-pixel positioning of the edge line to be detected in the newly obtained window image;

步骤八:当操作者判定已完成对整幅图像上所需边缘位置的亚像素定位时,检测方法结束。Step 8: When the operator determines that the sub-pixel positioning of the desired edge position on the entire image has been completed, the detection method ends.

本发明的有益效果是:本发明的快速边缘检测方法可以直接应用于二维边缘检测,该方法在每次对窗口图像数值化处理时都利用空间矩计算边缘的投影方向,并结合投影公式将二维边缘检测转化为一维边缘检测,避免了在每次一维边缘检测过程中都重复进行拟合灰度曲面所需的复杂运算。运用正交多项式拟合得到计算一维边缘点位置的解析公式,有效克服了拟合的方法通常不能获得解析解的难题,该解析公式形式简单,含有较少的内积计算,最终结合检测得到的边缘点位置和边缘法线方向,确定窗口图像中边缘直线的位置。该方法大幅提高了运算速度,能够适应实时性要求较高的二维边缘检测过程,还兼备了基于矩的方法或插值法运算速度快以及拟合法对图像噪声不敏感的特性,能够大幅提高边缘检测的精度和速度。The beneficial effects of the present invention are: the fast edge detection method of the present invention can be directly applied to two-dimensional edge detection, the method uses the spatial moment to calculate the projection direction of the edge each time the window image is numerically processed, and combines the projection formula to The two-dimensional edge detection is transformed into one-dimensional edge detection, which avoids repeating the complex operation required for fitting the gray surface in each one-dimensional edge detection process. The analytical formula for calculating the position of one-dimensional edge points is obtained by using orthogonal polynomial fitting, which effectively overcomes the problem that the fitting method usually cannot obtain analytical solutions. The analytical formula is simple in form and contains less inner product calculations. The position of the edge point and the direction of the edge normal determine the position of the edge line in the window image. This method greatly improves the calculation speed and can adapt to the two-dimensional edge detection process with high real-time requirements. It also has the characteristics of fast calculation speed of the moment-based method or interpolation method and the insensitivity of the fitting method to image noise, which can greatly improve the edge detection process. Accuracy and speed of detection.

附图说明Description of drawings

图1是本发明基于正交多项式拟合的快速边缘检测方法流程图;Fig. 1 is the flow chart of the fast edge detection method based on orthogonal polynomial fitting of the present invention;

图2是本发明步骤三的流程图;Fig. 2 is the flowchart of step 3 of the present invention;

图3是本发明步骤四的流程图;Fig. 3 is the flowchart of step 4 of the present invention;

图4是本发明步骤五的流程图;Fig. 4 is the flowchart of step 5 of the present invention;

图5是本发明窗口图像上像素点按投影角θ向边缘法线所在横轴X投影的应用示意图。Fig. 5 is a schematic diagram of the application of projection of pixels on the window image to the horizontal axis X where the edge normal is located according to the projection angle θ.

具体实施方式Detailed ways

下面结合附图对本发明做进一步详细说明。The present invention will be described in further detail below in conjunction with the accompanying drawings.

如图1所示,本发明基于正交多项式拟合的快速边缘检测方法包括如下步骤:As shown in Figure 1, the fast edge detection method based on orthogonal polynomial fitting of the present invention comprises the following steps:

步骤一:图像整像素边缘检测和定位:利用Canny边缘检测算子对图像进行边缘检测,获取图像边缘所在的所有整像素方格的坐标及灰度,从而定位图像中待检测的边缘在像素坐标平面内的大体方位和范围。Step 1: Image integer pixel edge detection and positioning: use the Canny edge detection operator to perform edge detection on the image, and obtain the coordinates and gray levels of all the integer pixel squares where the image edge is located, so as to locate the pixel coordinates of the edge to be detected in the image The general orientation and range in the plane.

步骤二:提取窗口图像:以步骤一所述的含有边缘的整像素方格为中心,提取图像边缘所在区域的一个局部方形灰度矩阵Am×m,即窗口图像2。在微观层次下窗口图像2内待检测边缘可近似看做一小段直线。如图5所示,本实施例中,以5×5个整像素方格所形成的图像区域作为窗口图像2,从图像中提取含有一小段待检测边缘直线1的正方形图像。Step 2: Extracting the window image: centering on the whole-pixel square containing the edge described in Step 1, extract a local square grayscale matrix A m×m of the area where the edge of the image is located, that is, the window image 2 . At the microscopic level, the edge to be detected in the window image 2 can be approximately regarded as a small straight line. As shown in FIG. 5 , in this embodiment, an image area formed by 5×5 integer pixel squares is used as a window image 2 , and a square image containing a small section of edge line 1 to be detected is extracted from the image.

步骤三:窗口图像2的数值化处理,具体包括如图2所示的以下子步骤:Step 3: Numerical processing of window image 2, specifically including the following sub-steps as shown in Figure 2:

步骤3.1:如图5所示,以步骤二所述的窗口图像2的中心为原点,建立xoy直角坐标系,其中横轴为x轴,纵轴为y轴。坐标系的单位长度是1个像素,那么由步骤一可知,待检测的边缘位于该坐标系中。Step 3.1: As shown in Figure 5, take the center of the window image 2 described in step 2 as the origin, establish a xoy rectangular coordinate system, where the horizontal axis is the x axis and the vertical axis is the y axis. The unit length of the coordinate system is 1 pixel, then it can be seen from step 1 that the edge to be detected is located in the coordinate system.

步骤3.2:如图5所示,设窗口图像2中每个像素方格中心点在如步骤3.1所述直角坐标系中的坐标为(x,y),则将整像素方格的灰度值作为该点对应的灰度值,并在原xoy平面直角坐标系中加入Z轴,表示像素点对应的灰度值,由此获得关于灰度值随坐标点变化的离散灰度分布函数I(x,y)。Step 3.2: As shown in Figure 5, set the coordinates of the center point of each pixel grid in the window image 2 in the Cartesian coordinate system as described in step 3.1 to be (x, y), then set the gray value of the entire pixel grid As the gray value corresponding to the point, and adding the Z axis to the original xoy plane Cartesian coordinate system, it represents the gray value corresponding to the pixel point, thus obtaining the discrete gray distribution function I(x ,y).

步骤3.3:如图5所示,在xoy直角坐标系平面内存在一条通过坐标系原点o并垂直于待检测边缘的直线,该直线为边缘的法线,并定义该边缘法线3与水平横轴的夹角为θ。Step 3.3: As shown in Figure 5, there is a straight line passing through the origin o of the coordinate system and perpendicular to the edge to be detected in the plane of the xoy rectangular coordinate system. The angle between the axes is θ.

步骤四:确定边缘法线3方向,其具体包括如图3所示的以下子步骤:Step 4: Determine the direction of the edge normal 3, which specifically includes the following sub-steps as shown in Figure 3:

步骤4.1:利用空间矩计算公式,可以计算步骤3.1中提取的方形窗口图像2内接圆对应的各阶空间矩MpqStep 4.1: Using the spatial moment calculation formula, the spatial moment M pq of each order corresponding to the inscribed circle of the square window image 2 extracted in step 3.1 can be calculated:

Mm pqpq == ∫∫ ∫∫ xx 22 ++ ythe y 22 ≤≤ rr xx pp ythe y qq ff (( xx ,, ythe y )) dxdydxdy ,, pp ,, qq == 0,10,1 ,, .. .. .. ,, NN ·&Center Dot; ·&Center Dot; ·&Center Dot; ·· ·&Center Dot; ·&Center Dot; (( 11 ))

式(1)中f(x,y)表示图像像素灰度的连续分布函数,正整数p和q分别表示空间矩的阶数,r表示内接圆的半径。In formula (1), f(x, y) represents the continuous distribution function of image pixel grayscale, positive integers p and q represent the order of spatial moments, and r represents the radius of the inscribed circle.

步骤4.2:将步骤4.1所述连续灰度分布函数f(x,y)以步骤3.2所述Z轴为中心旋转如步骤3.3所述的θ角,在窗口图像2内会得到新的连续灰度分布函数,此时窗口图像2内接圆对应的各阶空间矩的数值发生改变。Step 4.2: Rotate the continuous grayscale distribution function f(x, y) described in step 4.1 around the Z axis described in step 3.2 by the angle θ as described in step 3.3, and a new continuous grayscale will be obtained in window image 2 Distribution function, at this time, the value of the space moment of each order corresponding to the inscribed circle of window image 2 changes.

步骤4.3:根据空间矩旋转不变性理论,可以得到旋转后内接圆对应的空间矩M'pq与未旋转之前的矩Mpq的关系如下:Step 4.3: According to the theory of spatial moment rotation invariance, the relationship between the spatial moment M' pq corresponding to the inscribed circle after rotation and the moment M pq before rotation can be obtained as follows:

Mm pqpq ′′ == ΣΣ ii == 00 pp ΣΣ sthe s == 00 qq pp ii qq sthe s (( -- 11 )) qq -- sthe s (( coscos θθ )) pp -- ii ++ sthe s ×× (( sinsin θθ )) qq ++ ii -- sthe s Mm pp ++ qq -- ii -- sthe s ,, ii ++ sthe s ·· ·&Center Dot; ·&Center Dot; ·&Center Dot; ·· ·&Center Dot; (( 22 ))

i表示从0到p的整数,s表示从0到q的整数,当连续灰度分布函数f(x,y)旋转如图5所示的θ角后,窗口图像2中的待检测的边缘直线1与步骤3.1所述坐标系横轴x垂直,即旋转后窗口图像2内接圆对应的灰度函数关于横轴x对称,根据空间矩计算公式可知,旋转后窗口图像2内接圆对应的空间矩M'01=0,此时p=0,q=1,利用式(2)还可以求出:i represents an integer from 0 to p, s represents an integer from 0 to q, when the continuous gray distribution function f(x, y) is rotated by the angle θ as shown in Figure 5, the edge to be detected in the window image 2 The straight line 1 is perpendicular to the horizontal axis x of the coordinate system described in step 3.1, that is, the grayscale function corresponding to the inscribed circle of the window image 2 after rotation is symmetrical about the horizontal axis x. According to the calculation formula of the space moment, the inscribed circle of the window image 2 after rotation corresponds to The spatial moment M' 01 =0, at this time p=0, q=1, using formula (2) can also be obtained:

M'01=-sinθ·M10+cosθ·M01=0……(3)M' 01 =-sinθ·M 10 +cosθ·M 01 =0...(3)

其中M10,(p=1,q=0)和M01,(p=0,q=1)表示未旋转之前内接圆对应的空间矩。Where M 10 , (p=1, q=0) and M 01 , (p=0, q=1) represent the spatial moment corresponding to the inscribed circle before rotation.

步骤4.4:由于在窗口图像中的像素灰度值I(x,y)是离散的,即并不存在连续的灰度函数f(x,y),因此利用空间矩计算模板代替公式(1),并将窗口图像内接圆中像素点的离散灰度值I(x,y)代入到上述的空间矩计算模板公式中,以计算式(3)中的空间矩M01和M10的值。所述空间矩计算模板是由LyversEP,MitchellOR.在其著作Precisionedgecontrastandorientationestimation[J],IEEETrans.PatternAnal.Mach.Intell,1988,10(6):927-937.[1]中提供的空间矩计算模板。Step 4.4: Since the pixel grayscale value I(x,y) in the window image is discrete, that is, there is no continuous grayscale function f(x,y), the spatial moment calculation template is used to replace the formula (1) , and substitute the discrete gray value I(x,y) of the pixel in the inscribed circle of the window image into the above-mentioned space moment calculation template formula to calculate the values of space moments M 01 and M 10 in formula (3) . The spatial moment calculation template is provided by LyversEP, Mitchell OR. in their book Precisionedgecontrastandorientationestimation[J], IEEETrans.PatternAnal.Mach.Intell, 1988, 10(6):927-937.[1].

步骤4.5:根据式(3)得到式(4),将步骤4.4得到的空间矩M01和M10的值代入式(4),求得θ角的值:Step 4.5: Obtain formula (4) according to formula (3), and substitute the values of spatial moments M 01 and M 10 obtained in step 4.4 into formula (4) to obtain the value of angle θ:

θθ == arctanarctan Mm 0101 Mm 1010 ·&Center Dot; ·· ·· ·· ·&Center Dot; ·&Center Dot; (( 44 ))

当θ角被求得后,则如步骤3.3所述的边缘法线3在xoy坐标系中的位置就被确定,成为已知量了。After the θ angle is obtained, the position of the edge normal 3 in the xoy coordinate system as described in step 3.3 is determined and becomes a known quantity.

步骤4.6:如图5所示,设边缘法线3为新的水平横轴X,以步骤4.5中的θ角作为投影角,则步骤3.2所述的所有点在像素平面内的像素坐标(x,y)与边缘法线3所在横轴上点坐标X存在如下投影公式:Step 4.6: As shown in Figure 5, set the edge normal 3 as the new horizontal axis X, and take the θ angle in step 4.5 as the projection angle, then the pixel coordinates of all points in the pixel plane described in step 3.2 (x , y) and the point coordinate X on the horizontal axis of the edge normal 3 have the following projection formula:

X=xcosθ+ysinθ……(5)X=xcosθ+ysinθ...(5)

式(5)中X值表示窗口图像2内的被投影点按投影角θ投影后,对应投影点4在步骤4.6所述的新横轴X上的坐标读数值。由于在该投影方向上,连续灰度分布函数f(x,y)不发生改变,因此新横轴上点的灰度值与对应投影点灰度值5相同。The X value in formula (5) represents the coordinate reading value of the corresponding projected point 4 on the new horizontal axis X described in step 4.6 after the projected point in the window image 2 is projected according to the projection angle θ. Since the continuous grayscale distribution function f(x, y) does not change in this projection direction, the grayscale value of the point on the new horizontal axis is the same as the grayscale value 5 of the corresponding projected point.

通过步骤四,可以将二维采样窗口内的像素点全部投影到过窗口图像矩阵原点的边缘法线上,进而将该二维边缘检测问题转变为一维边缘检测问题,然后再利用以下步骤即可定位和获得边缘直线的位置。Through step four, all the pixels in the two-dimensional sampling window can be projected onto the edge normal of the origin of the window image matrix, and then the two-dimensional edge detection problem is transformed into one-dimensional edge detection problem, and then the following steps are used: The position of the edge line can be located and obtained.

步骤五:进行基于正交多项式拟合的一维边缘点检测,以确定边缘法线3与待检测边缘直线1的交点位置,其包括如图4所示的以下子步骤:Step 5: Carry out one-dimensional edge point detection based on orthogonal polynomial fitting to determine the intersection position of the edge normal 3 and the edge line 1 to be detected, which includes the following sub-steps as shown in Figure 4:

步骤5.1:如图5所示,将步骤3.2所述Z轴与步骤4.6所述水平横轴X重新构成一个一维边缘点检测所需的平面直角坐标系XOZ,即投影平面6,新XOZ坐标系是一维平面坐标系,其XOZ原点与原xoy坐标系原点位置重合,因此,在新坐标中投影点4的坐标为(X,Z)。Step 5.1: As shown in Figure 5, reconstruct the Z axis described in step 3.2 and the horizontal horizontal axis X described in step 4.6 into a plane Cartesian coordinate system XOZ required for one-dimensional edge point detection, that is, the projection plane 6, the new XOZ coordinates The system is a one-dimensional plane coordinate system, and its XOZ origin coincides with the origin of the original xoy coordinate system. Therefore, the coordinates of projected point 4 in the new coordinates are (X, Z).

根据投影公式(5)将窗口图像2内各个像素方格的中心点投影到步骤4.6所述的水平横轴X上,由于窗口图像内沿投影方向θ的像素点对应的灰度值是相同的,因此投影点的灰度值与被投影点相同,因此在平面直角坐标系XOZ中,可以得到边缘法线3上投影像素点灰度值5的离散分布函数(Xi,Zi),i=1,...,2n+1。According to the projection formula (5), project the center point of each pixel grid in the window image 2 onto the horizontal horizontal axis X described in step 4.6, since the gray values corresponding to the pixels along the projection direction θ in the window image are the same , so the gray value of the projected point is the same as the projected point, so in the plane Cartesian coordinate system XOZ, the discrete distribution function (X i ,Z i ), i =1,...,2n+1.

步骤5.2:投影点坐标的归一化,若如步骤5.1所述的横轴X上的投影点4的数目为2n+1个,根据方形矩阵投影的对称性,上述投影点4在横轴上X两侧是对称分布的。如果设 L = X 2 n + 1 - X 1 2 , 并令 x i = X i L i = 1 , . . . , 2 n + 1 , 则有xi∈[-1,1],这样就使得投影点在X轴的范围是[-1,1]。Step 5.2: Normalization of the projection point coordinates. If the number of projection points 4 on the horizontal axis X as described in step 5.1 is 2n+1, according to the symmetry of the square matrix projection, the above projection points 4 are on the horizontal axis Both sides of X are symmetrically distributed. if set L = x 2 no + 1 - x 1 2 , and order x i = x i L i = 1 , . . . , 2 no + 1 , Then there is x i ∈ [-1,1], so that the range of the projection point on the X axis is [-1,1].

步骤5.3:计算正交多项式系,利用schemite正交化方法计算在[-1,1]区间上关于权函数ρ(x)=1的正交多项式系,所述多项式系如下:Step 5.3: Calculate the orthogonal polynomial system, use the schemite orthogonalization method to calculate the orthogonal polynomial system about the weight function ρ(x)=1 on the [-1,1] interval, the polynomial system is as follows:

步骤5.4:取步骤5.3中的前四阶正交基函数 Step 5.4: Take the first four order orthogonal basis functions in step 5.3

以式(7)作为拟合基底进行三次正交多项式拟合,则拟合多项式的方程为Using equation (7) as the fitting base to carry out cubic orthogonal polynomial fitting, the equation of fitting polynomial is

式(8)中的拟合多项式的系数{a1,a2,a3,a4}为待求的拟合参数。The coefficients {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial in formula (8) are the fitting parameters to be obtained.

步骤5.5:根据最小二乘拟合原理以及正交多项式的正交性质,利用式(8)可推导出拟合多项式的方程对应的法方程组如下:Step 5.5: According to the least squares fitting principle and the orthogonality property of orthogonal polynomials, the normal equations corresponding to the equations of fitting polynomials can be deduced as follows:

式(9)中表示离散向量与自身的内积,Z=[Z1,Z2,……,Z2n+1]T是离散灰度值向量,表示Z与的内积。In formula (9) represents a discrete vector Inner product with itself, Z=[Z 1 ,Z 2 ,……,Z 2n+1 ] T is a discrete gray value vector, Indicates that Z and inner product.

步骤5.6:利用方程组式(9)可以得出拟合多项式的系数{a1,a2,a3,a4}计算公式:Step 5.6: Use the equation (9) to obtain the calculation formula of the coefficients {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial:

将各已知量代入式(10),分别得a0、a1、a2和a3的结果。Substituting each known quantity into formula (10), the results of a 0 , a 1 , a 2 and a 3 are obtained respectively.

步骤5.7:将步骤5.6所述拟合多项式的结果作为已知量代入式(8),拟合多项式方程变为:Step 5.7: Substitute the result of the polynomial fitting described in step 5.6 into equation (8) as a known quantity, and the polynomial fitting equation becomes:

步骤5.8:由于式(11)为三次多项式,因此存在唯一的二阶导数为零点,计算三次多项式式(11)的二阶导数为零点,即:Step 5.8: Since equation (11) is a cubic polynomial, there is only a second-order derivative that is zero, and the second-order derivative of the cubic polynomial (11) is zero, namely:

求解并获得上述使式(12)的二阶导数为零的点的坐标。Solve and obtain the coordinates of the above point where the second derivative of equation (12) is zero.

步骤5.9:求解式(12)并将计算结果反归一化,即可获得一维边缘点的在横轴X上的位置坐标R,即:Step 5.9: Solve formula (12) and denormalize the calculation results to obtain the position coordinate R of the one-dimensional edge point on the horizontal axis X, namely:

式(13)即为计算一维边缘点位置的解析公式,该边缘点为边缘法线3与待检测边缘直线1的交点。Equation (13) is an analytical formula for calculating the position of a one-dimensional edge point, which is the intersection point of the edge normal 3 and the edge line 1 to be detected.

通过步骤五所述方法,我们就能通过该公式计算边缘点在X轴上的位置,也就是边缘直线与法线的交点位置。Through the method described in step five, we can use this formula to calculate the position of the edge point on the X-axis, that is, the intersection position of the edge line and the normal.

步骤六:利用式(13)确定窗口图像2内过原点边缘法线3与待检测边缘直线1的交点位置,利用步骤4.5获得边缘法线3的方向角θ,确定待检测的边缘直线1在xoy坐标系中的方程,从而实现在窗口图像2中待检测的边缘直线1的亚像素定位;Step 6: Use formula (13) to determine the intersection position of the edge normal 3 passing through the origin in the window image 2 and the edge line 1 to be detected, use step 4.5 to obtain the direction angle θ of the edge normal 3, and determine the edge line 1 to be detected at The equation in the xoy coordinate system, thereby realizing the sub-pixel positioning of the edge straight line 1 to be detected in the window image 2;

步骤七:由操作者重新选择步骤一所述整像素方格,并重复步骤二至步骤六,以获取新取得的窗口图像2中待检测的边缘直线1的亚像素定位;Step 7: The operator reselects the integer pixel grid described in step 1, and repeats steps 2 to 6 to obtain the sub-pixel positioning of the edge line 1 to be detected in the newly obtained window image 2;

步骤八:当操作者判定已完成对整幅图像上所需边缘位置的亚像素定位时,检测方法结束。Step 8: When the operator determines that the sub-pixel positioning of the desired edge position on the entire image has been completed, the detection method ends.

本发明基于正交多项式拟合的快速边缘检测方法可直接应用于二维边缘检测,其利用空间矩旋转时的不变性获得边缘的投影方向θ,并得出投影公式,从而把窗口图像中的像素点及其对应的灰度值都通过该投影公式投影到以边缘法线为横轴,以灰度为纵轴的平面中,进而将二维边缘检测问题转化为一维边缘检测问题,通过基于正交多项式拟合的一维边缘检测方法获得窗口图像内的边缘法线与边缘的交点坐标位置,最终结合检测得到边缘法线方向θ,确定窗口图像中边缘直线的位置。The fast edge detection method based on orthogonal polynomial fitting of the present invention can be directly applied to two-dimensional edge detection. It uses the invariance of space moment rotation to obtain the projection direction θ of the edge, and obtains the projection formula, so that the window image Pixels and their corresponding gray values are projected to the plane with the edge normal as the horizontal axis and the gray value as the vertical axis through the projection formula, and then the two-dimensional edge detection problem is transformed into a one-dimensional edge detection problem, through The one-dimensional edge detection method based on orthogonal polynomial fitting obtains the coordinate position of the intersection point of the edge normal and the edge in the window image, and finally combines the detection to obtain the edge normal direction θ to determine the position of the edge line in the window image.

本发明的检测方法在对每次窗口图像数值化处理过程中,利用空间矩理论,首先计算出边缘的投影方向θ,结合投影公式将二维边缘检测问题转化为一维边缘检测问题,避免了在每次一维边缘检测过程中都重复进行拟合灰度曲面所需的复杂运算。根据正交多项式拟合理论,可得到计算一维边缘点位置的解析公式,有效克服了拟合的方法通常不能获得解析解的难题,利用该解析公式只需要带入边缘位置的灰度值即可非常便捷的得到相关边缘点位置的解析解,由于解析公式形式简单,含有较少的内积计算,大幅提高了运算速度,因而能够适应实效性要求较高的实时工况边缘检测过程。In the detection method of the present invention, during the numerical processing of each window image, the spatial moment theory is used to first calculate the projection direction θ of the edge, and the two-dimensional edge detection problem is converted into a one-dimensional edge detection problem in combination with the projection formula, avoiding the problem of The complex operations required to fit the grayscale surface are repeated in each one-dimensional edge detection process. According to the theory of orthogonal polynomial fitting, an analytical formula for calculating the position of one-dimensional edge points can be obtained, which effectively overcomes the problem that the fitting method usually cannot obtain an analytical solution. Using this analytical formula, only the gray value of the edge position needs to be brought in. The analytical solution of the position of the relevant edge points can be obtained very conveniently. Since the analytical formula is simple in form and contains less inner product calculations, the calculation speed is greatly improved, so it can adapt to the edge detection process of real-time working conditions with high requirements for effectiveness.

此外,本发明的检测方法很好地融合了基于矩以及基于拟合法的两种亚像素检测法,不但继承了基于矩的方法或插值法运算速度快的特性,更兼具了拟合法对图像噪声不敏感的优点,能够较好地降低图像噪声对结果的干扰和影响,从而大幅提高边缘检测的精度和速度。In addition, the detection method of the present invention well integrates two sub-pixel detection methods based on moment and fitting method, not only inherits the characteristics of fast calculation speed of the method based on moment or interpolation method, but also has the advantages of fitting method for image The advantage of noise insensitivity can better reduce the interference and influence of image noise on the result, thereby greatly improving the accuracy and speed of edge detection.

Claims (1)

1.基于正交多项式拟合的快速边缘检测方法,其特征在于:该方法包括如下步骤:1. based on the fast edge detection method of orthogonal polynomial fitting, it is characterized in that: the method comprises the steps: 步骤一:图像整像素边缘检测和定位:利用Canny边缘检测算子对图像进行边缘检测,获取图像边缘所在的所有整像素方格的坐标及灰度;Step 1: Image integer pixel edge detection and positioning: use the Canny edge detection operator to perform edge detection on the image, and obtain the coordinates and gray levels of all integer pixel squares where the image edge is located; 步骤二:提取窗口图像:以步骤一得到的含有边缘的整像素方格为中心,提取图像边缘所在区域的一个局部方形灰度矩阵Am×m,即窗口图像(2),窗口图像(2)中包含一小段待检测边缘直线(1);Step 2: Extract the window image: take the integer pixel square with the edge obtained in Step 1 as the center, extract a local square grayscale matrix A m×m of the area where the edge of the image is located, that is, the window image (2), the window image (2 ) contains a small section of edge straight line (1) to be detected; 步骤三:窗口图像(2)的数值化处理,具体包括以下步骤:Step 3: numerical processing of the window image (2), specifically including the following steps: 步骤3.1:以步骤二所述的窗口图像(2)的中心为原点,建立xoy直角坐标系,其中横轴为x轴,纵轴为y轴;坐标系的单位长度是1个像素;Step 3.1: take the center of the window image (2) described in step 2 as the origin, establish a xoy rectangular coordinate system, wherein the horizontal axis is the x axis, and the vertical axis is the y axis; the unit length of the coordinate system is 1 pixel; 步骤3.2:设窗口图像(2)中每个像素方格中心点在如步骤3.1所述直角坐标系中的坐标为(x,y),则将整像素方格的灰度值作为该点对应的灰度值,并在原平面直角坐标系中加入与该平面直角坐标系垂直的Z轴构成空间立体坐标系,Z轴表示像素点对应的灰度值,由此获得关于灰度值随坐标点变化的离散灰度分布函数I(x,y);Step 3.2: Set the coordinates of the center point of each pixel grid in the window image (2) in the Cartesian coordinate system as described in step 3.1 to be (x, y), then use the gray value of the entire pixel grid as the corresponding point gray value, and add the Z axis perpendicular to the plane rectangular coordinate system to the original plane rectangular coordinate system to form a spatial three-dimensional coordinate system. Varying discrete grayscale distribution function I(x,y); 步骤3.3:在直角坐标系平面内存在一条通过坐标系原点并垂直于待检测的边缘直线(1)的直线,该直线为边缘的法线,并定义该边缘法线(3)与水平横轴的夹角为θ;Step 3.3: There is a straight line passing through the origin of the coordinate system and perpendicular to the edge line (1) to be detected in the plane of the rectangular coordinate system. This line is the normal line of the edge, and the edge normal line (3) and the horizontal horizontal axis are defined The included angle is θ; 步骤四:确定边缘法线(3)的方向,其具体步骤为:Step 4: Determine the direction of the edge normal (3), the specific steps are: 步骤4.1:利用空间矩计算公式,计算步骤3.1中提取的方形窗口图像(2)内接圆对应的各阶空间矩MpqStep 4.1: Using the calculation formula of spatial moments, calculate the spatial moments M pq of each order corresponding to the inscribed circle of the square window image (2) extracted in step 3.1: Mm pqpq == ∫∫ ∫∫ xx 22 ++ ythe y 22 ≤≤ rr xx pp ythe y qq ff (( xx ,, ythe y )) dxdudxdu ,, pp ,, qq == 0,10,1 ,, .. .. .. ,, NN .. .. .. .. .. .. (( 11 )) 式(1)中f(x,y)表示图像像素的连续灰度分布函数,正整数p和q分别表示空间矩的阶数,r表示内接圆的半径;In formula (1), f(x, y) represents the continuous gray scale distribution function of image pixels, positive integers p and q represent the order of spatial moments, and r represents the radius of the inscribed circle; 步骤4.2:将步骤4.1所述连续灰度分布函数f(x,y)以步骤3.2所述Z轴为中心旋转如步骤3.3所述的θ角,在窗口图像(2)内会得到新的连续灰度分布函数,此时窗口图像(2)内接圆对应的各阶空间矩的数值发生改变;Step 4.2: Rotate the continuous grayscale distribution function f(x, y) described in step 4.1 around the Z axis described in step 3.2 by the θ angle described in step 3.3, and a new continuous grayscale distribution function f(x, y) will be obtained in the window image (2). Gray distribution function, at this time, the value of the space moment of each order corresponding to the inscribed circle of the window image (2) changes; 步骤4.3:旋转后内接圆对应的空间矩M'pq与未旋转之前的空间矩Mpq的关系如下:Step 4.3: The relationship between the spatial moment M' pq corresponding to the inscribed circle after rotation and the spatial moment M pq before rotation is as follows: Mm pqpq ′′ == ΣΣ ii == 00 pp ΣΣ sthe s == 00 qq pp ii qq sthe s (( -- 11 )) qq -- sthe s (( coscos θθ )) pp -- ii ++ sthe s (( sinsin θθ )) qq ++ ii ++ sthe s Mm pp ++ 11 -- ii -- sthe s ,, ii ++ sthe s .. .. .. .. .. .. (( 22 )) i表示从0到p的整数,s表示从0到q的整数,当连续灰度分布函数f(x,y)旋转θ角后,窗口图像(2)中的待检测的边缘直线(1)与步骤3.1所述坐标系横轴x垂直,即旋转后窗口图像(2)内接圆对应的灰度函数关于横轴x对称,根据空间矩计算公式可知,旋转后窗口图像(2)内接圆对应的空间矩M'01=0,此时p=0,q=1,利用式(2)求出:i represents an integer from 0 to p, s represents an integer from 0 to q, when the continuous gray distribution function f(x, y) is rotated by θ, the edge line (1) to be detected in the window image (2) It is perpendicular to the horizontal axis x of the coordinate system described in step 3.1, that is, the grayscale function corresponding to the inscribed circle of the rotated window image (2) is symmetrical about the horizontal axis x. According to the calculation formula of the space moment, the rotated window image (2) is inscribed The space moment M' 01 =0 corresponding to the circle, at this time p=0, q=1, can be obtained by formula (2): M'01=-sinθ·M10+cosθ·M01=0……(3)M' 01 =-sinθ·M 10 +cosθ·M 01 =0...(3) 其中M10和M01表示未旋转之前内接圆对应的空间矩;Among them, M 10 and M 01 represent the space moment corresponding to the inscribed circle before rotation; 步骤4.4:利用空间矩计算模板代替公式(1),并将窗口图像(2)内接圆中像素点的离散灰度函数I(x,y)代入到上述的空间矩计算模板公式中,以计算式(3)中的空间矩M01和M10的值;Step 4.4: Use the spatial moment calculation template to replace the formula (1), and substitute the discrete grayscale function I(x, y) of the pixels in the inscribed circle of the window image (2) into the above-mentioned spatial moment calculation template formula, with Calculate the value of spatial moments M 01 and M 10 in formula (3); 步骤4.5:根据式(3)得到式(4),将步骤4.4得到的空间矩M01和M10的值代入式(4),求得θ角的值:Step 4.5: Obtain formula (4) according to formula (3), and substitute the values of spatial moments M 01 and M 10 obtained in step 4.4 into formula (4) to obtain the value of angle θ: θθ == arctanarctan Mm 0101 Mm 1010 .. .. .. .. .. .. (( 44 )) 步骤4.6:设边缘法线(3)为新的水平横轴X,以步骤4.5中的θ角作为投影角,则步骤3.2所述的窗口图像(2)中每个像素方格的中心点在像素平面内的像素坐标(x,y)与边缘法线(3)所在横轴上点坐标X存在如下投影公式:Step 4.6: Set the edge normal (3) as the new horizontal axis X, and take the angle θ in step 4.5 as the projection angle, then the center point of each pixel grid in the window image (2) described in step 3.2 is at The pixel coordinates (x, y) in the pixel plane and the point coordinate X on the horizontal axis where the edge normal (3) is located have the following projection formula: X=xcosθ+ysinθ……(5)X=xcosθ+ysinθ...(5) 式(5)中X值表示窗口图像(2)内的被投影点按投影角θ投影后,对应投影点(4)在步骤4.6所述新的水平横轴X上的坐标读数值;In the formula (5), after the X value represents the projected point in the window image (2) by the projection angle θ projection, the coordinate reading value of the corresponding projected point (4) on the new horizontal horizontal axis X described in step 4.6; 步骤五:基于正交多项式拟合的一维边缘点检测,确定边缘法线(3)与待检测边缘直线(1)的交点位置,其包括如下步骤:Step 5: Based on the one-dimensional edge point detection of orthogonal polynomial fitting, determine the intersection position of the edge normal (3) and the edge line (1) to be detected, which includes the following steps: 步骤5.1:将步骤3.2所述Z轴与步骤4.6所述水平横轴X重新构成一个一维边缘点检测所需的平面直角坐标系XOZ,即投影平面(6);Step 5.1: reconstitute the Z-axis described in step 3.2 and the horizontal horizontal axis X described in step 4.6 into a plane Cartesian coordinate system XOZ required for one-dimensional edge point detection, i.e. the projection plane (6); 根据投影公式(5)将窗口图像(2)内各个像素方格的中心点投影到步骤4.6所述的水平横轴X上;在平面直角坐标系XOZ中,得到边缘法线(3)上投影点灰度值(5)的离散灰度分布函数(Xi,Zi),i=1,...,2n+1;According to the projection formula (5), the center point of each pixel grid in the window image (2) is projected onto the horizontal horizontal axis X described in step 4.6; in the plane Cartesian coordinate system XOZ, the projection on the edge normal (3) is obtained Discrete gray distribution function (X i , Z i ) of point gray value (5), i=1,...,2n+1; 步骤5.2:投影点坐标的归一化,若如步骤5.1所述横轴X上形成的投影点(4)数目为2n+1个,设并令i=1,...,2n+1,则有xi∈[-1,1];Step 5.2: Normalization of the projection point coordinates, if the number of projection points (4) formed on the horizontal axis X as described in step 5.1 is 2n+1, set and order i=1,...,2n+1, then x i ∈[-1,1]; 步骤5.3:计算正交多项式系,利用schemite正交化方法计算在[-1,1]区间上关于权函数ρ(x)=1的正交多项式系;Step 5.3: Calculate the orthogonal polynomial system, and use the schemite orthogonalization method to calculate the orthogonal polynomial system about the weight function ρ(x)=1 on the [-1,1] interval; 步骤5.4:取步骤5.3中的前四阶正交基函数 Step 5.4: Take the first four order orthogonal basis functions in step 5.3 以式(7)作为拟合基底进行三次正交多项式拟合,则拟合多项式的方程为:Using formula (7) as the fitting base to carry out cubic orthogonal polynomial fitting, then the equation of fitting polynomial is: 式(8)中的拟合多项式的系数{a1,a2,a3,a4}为待求的拟合参数;The coefficients {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial in formula (8) are the fitting parameters to be found; 步骤5.5:利用式(8)可推导出拟合多项式的方程对应的法方程组如下:Step 5.5: Utilize formula (8) to deduce the corresponding normal equation group of the equation of fitting polynomial as follows: 式(9)中表示离散向量(i=0,1,2,3)与自身的内积,Z=[Z1,Z2,……,Z2n+1]T是离散灰度值向量,表示Z与的内积;In formula (9) represents a discrete vector Inner product of (i=0,1,2,3) and itself, Z=[Z 1 ,Z 2 ,…,Z 2n+1 ] T is a discrete gray value vector, Indicates that Z and inner product; 步骤5.6:利用方程组式(9)得出拟合多项式的系数{a1,a2,a3,a4}计算公式:Step 5.6: Use equation (9) to obtain the calculation formula of the coefficient {a 1 , a 2 , a 3 , a 4 } of the fitting polynomial: 将各已知量代入式(10),分别得a0、a1、a2和a3的结果;Substituting each known quantity into formula (10), the results of a 0 , a 1 , a 2 and a 3 are obtained respectively; 步骤5.7:将步骤5.6所述拟合多项式的结果作为已知量代入式(8),拟合多项式方程变为:Step 5.7: Substituting the result of the polynomial fitting described in step 5.6 into formula (8) as a known quantity, the polynomial fitting equation becomes: 步骤5.8:计算三次多项式式(11)的二阶导数为零点,即:Step 5.8: Calculate the second order derivative of the cubic polynomial (11) as zero, namely: 求解并获得使式(12)的二阶导数为零的点的坐标;Solve and obtain the coordinates of the point that makes the second order derivative of formula (12) zero; 步骤5.9:求解式(12)并将计算结果反归一化,获得一维边缘点在横轴X上的位置坐标R,即:Step 5.9: Solve formula (12) and denormalize the calculation results to obtain the position coordinate R of the one-dimensional edge point on the horizontal axis X, namely: 式(13)即为计算一维边缘点位置的解析公式,该边缘点为边缘法线(3)与待检测边缘直线(1)的交点;Equation (13) is an analytical formula for calculating the position of a one-dimensional edge point, which is the intersection of the edge normal (3) and the edge line (1) to be detected; 步骤六:利用式(13)确定窗口图像(2)内过原点边缘法线(3)与待检测边缘直线(1)的交点位置,利用步骤4.5获得边缘法线(3)的方向角θ,确定待检测的边缘直线(1)在xoy坐标系中的方程,从而实现在窗口图像(2)中待检测的边缘直线(1)的亚像素定位;Step 6: Use formula (13) to determine the intersection position of the edge normal (3) passing through the origin in the window image (2) and the edge line (1) to be detected, and use step 4.5 to obtain the direction angle θ of the edge normal (3), Determine the equation of the edge straight line (1) to be detected in the xoy coordinate system, thereby realizing the sub-pixel positioning of the edge straight line (1) to be detected in the window image (2); 步骤七:由操作者重新选择步骤一所述整像素方格,并重复步骤二至步骤六,以获取新取得的窗口图像(2)中待检测的边缘直线(1)的亚像素定位;Step 7: The operator reselects the whole pixel grid described in step 1, and repeats steps 2 to 6 to obtain the sub-pixel positioning of the edge line (1) to be detected in the newly obtained window image (2); 步骤八:当操作者判定已完成对整幅图像上所需边缘位置的亚像素定位时,检测方法结束。Step 8: When the operator determines that the sub-pixel positioning of the desired edge position on the entire image has been completed, the detection method ends.
CN201310097073.2A 2013-03-25 2013-03-25 Rapid edge detecting method based on orthogonal polynomial fitting Expired - Fee Related CN103136758B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310097073.2A CN103136758B (en) 2013-03-25 2013-03-25 Rapid edge detecting method based on orthogonal polynomial fitting

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310097073.2A CN103136758B (en) 2013-03-25 2013-03-25 Rapid edge detecting method based on orthogonal polynomial fitting

Publications (2)

Publication Number Publication Date
CN103136758A CN103136758A (en) 2013-06-05
CN103136758B true CN103136758B (en) 2015-05-27

Family

ID=48496548

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310097073.2A Expired - Fee Related CN103136758B (en) 2013-03-25 2013-03-25 Rapid edge detecting method based on orthogonal polynomial fitting

Country Status (1)

Country Link
CN (1) CN103136758B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104715491B (en) * 2015-04-09 2017-07-21 大连理工大学 A sub-pixel edge detection method based on one-dimensional gray moment
CN105005985B (en) * 2015-06-19 2017-10-31 沈阳工业大学 Backlight image micron order edge detection method
CN105740869B (en) * 2016-01-28 2019-04-12 北京工商大学 A kind of rectangular operator edge extracting method and system based on multiple dimensioned multiresolution
CN105761256B (en) * 2016-02-05 2019-02-26 成都康烨科技有限公司 The sub-pixel edge straight line acquisition methods and device of image
CN106408583B (en) * 2016-08-25 2019-01-25 凌云光技术集团有限责任公司 A kind of multiple edge defect inspection method and device
CN106651828B (en) * 2016-09-21 2020-05-26 哈尔滨工业大学 Method for measuring sub-pixel of product size under industrial small-scale motion blur imaging condition
CN108256522B (en) * 2018-01-09 2020-05-19 北京航空航天大学 Two-dimensional identification method for SPR (surface plasmon resonance) and waveguide mixed absorption spectrum characteristic position
CN109522893B (en) * 2018-10-08 2022-12-06 武汉工程大学 Method for rapidly detecting key points of aerial non-cooperative target balloons
CN109934820B (en) * 2019-03-22 2020-10-09 大连大学 A method for sub-pixel detection of straight line edges in images of parts to be welded by laser tailor welding
CN111667534B (en) * 2020-05-21 2023-06-27 常州大学 Quick subpixel dent positioning method and device applied to high-speed drawing-in machine

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
Edge Detection with Sub-pixel Accuracy Based on Approximation of Edge with Erf Function;Miroslav HAGARA and Peter KULLA;《RADIOENGINEERING》;20110630;第20卷(第2期);全文 *
一种亚像素精度的边缘检测方法;孙秋成 等;《北京工业大学学报》;20091031;第35卷(第10期);全文 *
一种基于多项式插值改进的亚像素细分算法;李庆利 等;《北京科技大学学报》;20030630;第25卷(第3期);全文 *
基于空间矩的圆标记中心亚像素定位算法;郭玉波 等;《吉林大学学报(工学版)》;20090131;第39卷(第1期);全文 *
改进的空间矩亚像素边缘检测算法;王社阳 等;《哈尔滨工业大学学报》;20060630;第38卷(第6期);全文 *

Also Published As

Publication number Publication date
CN103136758A (en) 2013-06-05

Similar Documents

Publication Publication Date Title
CN103136758B (en) Rapid edge detecting method based on orthogonal polynomial fitting
CN104359403B (en) Planar part dimension measurement method based on sub-pixel edge algorithm
Li et al. A stable direct solution of perspective-three-point problem
CN104748683B (en) A kind of on-line automatic measurement apparatus of Digit Control Machine Tool workpiece and measuring method
CN105913489A (en) Indoor three-dimensional scene reconstruction method employing plane characteristics
CN110189314A (en) Image positioning method of automobile instrument panel based on machine vision
CN104268857A (en) Rapid sub pixel edge detection and locating method based on machine vision
WO2013107076A1 (en) Adaptive window fourier phase extraction method in optical three-dimensional measurement
CN107742289A (en) A detection method of rotating body workpiece based on machine vision
CN104715487A (en) A Subpixel Edge Detection Method Based on Pseudo-Zernike Moments
CN102661708A (en) High-density packaged element positioning method based on speeded up robust features (SURFs)
CN102222332A (en) Geometric calibration method of camera under linear model
CN104268837B (en) Electronic speckle interference fringe pattern phase information extracting method
Pei et al. Phase-to-coordinates calibration for fringe projection profilometry using Gaussian process regression
CN104715491A (en) A sub-pixel edge detection method based on one-dimensional gray moment
CN107063130A (en) A kind of workpiece automatic soldering method based on optical grating projection three-dimensionalreconstruction
CN104123725B (en) A kind of computational methods of single line array camera homography matrix H
CN106408531A (en) GPU acceleration-based hierarchical adaptive three-dimensional reconstruction method
CN114299079A (en) A method for acquiring engine blade section line data for dense point cloud data
Abdel-All et al. Intersection curves of two implicit surfaces in R3
CN104318555A (en) Accurate positioning method of center projection point in target image
CN106989672A (en) A kind of workpiece measuring based on machine vision
CN103411562B (en) A kind of structured light strip center extraction method based on dynamic programming and average drifting
CN105551048A (en) Space surface patch-based three-dimensional corner detection method
CN108537810B (en) Improved Zernike moment sub-pixel edge detection method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
ASS Succession or assignment of patent right

Owner name: CHANGCHUN NORMAL UNIVERSITY

Free format text: FORMER OWNER: CHANGCHUN POLYTECHNIC UNIV.

Effective date: 20150324

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 130012 CHANGCHUN, JILIN PROVINCE TO: 130032 CHANGCHUN, JILIN PROVINCE

TA01 Transfer of patent application right

Effective date of registration: 20150324

Address after: 130032 Jilin city two district Changchun Changji Road No. 677

Applicant after: CHANGCHUN NORMAL University

Address before: 130012 Yanan street, Jilin, Chaoyang District, No. 2055, No.

Applicant before: Changchun University of Technology

C53 Correction of patent of invention or patent application
CB03 Change of inventor or designer information

Inventor after: Sun Qiucheng

Inventor after: Liu Jianhao

Inventor after: Liu Renyun

Inventor after: Yu Fanhua

Inventor after: Li Chunjing

Inventor after: Cao Lei

Inventor before: Sun Qiucheng

Inventor before: Li Chunjing

Inventor before: Cao Lei

COR Change of bibliographic data

Free format text: CORRECT: INVENTOR; FROM: SUN QIUCHENG LI CHUNJING CAO LEI TO: SUN QIUCHENG LIU JIANHAO LIU RENYUN YU FANHUA LI CHUNJING CAO LEI

C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150527

CF01 Termination of patent right due to non-payment of annual fee