Image straight line intersection point detection method, system and readable storage medium
By optimizing multi-scale gradient fields and joint probability models, the accuracy and robustness issues of line intersection detection in existing technologies are solved, achieving high-precision, adaptive line intersection detection that is applicable to fields such as industrial automation and machine vision.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU HUICUI INTELLIGENT TECH CO LTD
- Filing Date
- 2026-05-28
- Publication Date
- 2026-06-26
AI Technical Summary
Existing line intersection detection methods rely on binarized edge detection, which leads to limited accuracy, parameter sensitivity, poor robustness to line segment breaks and noise, and a lack of global optimization and adaptive capabilities.
A weighted guided edge map is generated using a multi-scale gradient field. A candidate point set is obtained through support region growth and iterative competition. A dual-line-intersection joint probability model is constructed and optimized using the expectation-maximization algorithm to generate high-precision intersection detection results.
It improves detection accuracy and robustness, reduces dependence on empirical parameters, can handle discontinuous line segments and complex structures, provides sub-pixel accuracy and uncertainty assessment, adapts to complex scenarios, and has high computational efficiency.
Smart Images

Figure CN122289389A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically, to a method, system, and readable storage medium for detecting the intersection of straight lines in an image. Background Technology
[0002] In fields such as industrial automation, machine vision, precision measurement, and intelligent transportation, detecting two straight lines (or linear features) and accurately calculating their intersection coordinates is a fundamental and crucial vision task. For example, in PCB component positioning, it is necessary to detect cross marks on pads to determine the center position; in the aerospace field, it is necessary to measure cross lines on workpieces; in autonomous driving, it is necessary to detect the intersection points (vanishing points) of lane lines to estimate vehicle attitude and road geometry; and in biomedical image analysis, it is necessary to locate the intersection points of cell slices or tissue structures.
[0003] Therefore, developing a robust, accurate, and efficient visual measurement method for line intersections has broad application value. Summary of the Invention
[0004] The purpose of this invention is to provide an image line intersection detection method, system, and readable storage medium to solve the problems of limited accuracy, parameter sensitivity, and poor robustness to line segment breaks and noise caused by the reliance on binarized edge detection and independent line fitting in existing line intersection detection methods.
[0005] The first aspect of this invention provides a method for detecting the intersection points of straight lines in an image, comprising the following steps:
[0006] The original input image is acquired, and multi-scale gradient field calculations are performed to generate a weighted guided edge map.
[0007] Seed points are selected from the weighted guided edge map to generate a support region, and two candidate point sets are obtained through iterative competition based on the support region.
[0008] A dual-line-disclosure joint probability model is constructed based on the two candidate point sets, wherein the points in the candidate point sets are used as latent variables to be estimated, and the point set in the weighted guided edge map is used as observation data.
[0009] The detection results are obtained by solving the dual-line-intersection joint probability model based on the expectation-maximization algorithm, wherein the detection results include at least the coordinates of the image intersection points.
[0010] In this scheme, the step of acquiring the input original image and performing multi-scale gradient field calculation to generate a weighted guided edge map specifically includes:
[0011] Obtain the original input image The gradient is calculated by smoothing using two Gaussian kernels of different scales, where the calculated gradient includes a fine-scale gradient and a coarse-scale gradient.
[0012] Calculate the local orientation consistency metric for each pixel and synthesize weights based on the constructed weight function, wherein the weight function is related to the coarse-scale gradient;
[0013] The weighted guided edge map is generated based on the synthesized weights, the calculated gradient, and the initial distance. The weighted guided edge map includes a triplet data field, and is calculated as follows:
[0014] ;
[0015] in, For triplet data fields, For the composite weights, For fine-scale gradients, This is the initial distance.
[0016] In this scheme, the step of selecting seed points from the weighted guided edge map to generate a support region, and then iteratively competing based on the support region to obtain two candidate point sets, specifically includes:
[0017] Pixels representing the target quantity value are selected from the weighted guided edge map as the initial seed point set. ;
[0018] With each seed point in the initial seed point set Centered on the seed point, the orientation consistency and spatial affinity of pixels within the calculation area are used to form the initial region. ;
[0019] Based on the initial region, regional competition and merging are performed, the principal direction and linearity of each region are calculated, and iterative merging is carried out to form two supporting regions. and ;
[0020] Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point in the candidate point set includes a position, weight, and local gradient direction.
[0021] In this scheme, the construction of the dual-line-interface joint probability model based on the two candidate point sets specifically includes:
[0022] Construct a dual-linear-disclosure joint probability model, in which,
[0023] Based on the normal parametric representation of two lines, the intersection coordinates are... The equation of the straight line is as follows:
[0024] ;
[0025] ;
[0026] in, , Two straight lines It is a straight line The direction angle, It is a straight line Direction angle;
[0027] Let the model parameter set be denoted as ,in, These describe the points surrounding the line. and Noise parameters related to the degree of dispersion of the distribution;
[0028] Introduce an attribution tag latent variable Determine each point in the candidate point set. The straight line belongs to, where For point coordinate, For point Weight, For point Local gradient direction, the line belonging to includes straight lines Or a straight line .
[0029] In this scheme, the construction of the dual-line-intersection joint probability model based on the two candidate point sets further includes:
[0030] Observation model parameter set and attribution tags Time The joint probability, wherein the joint probability includes the geometric distance probability and the orientation consistency probability;
[0031] The distance calculation formula in the geometric distance probability is as follows:
[0032] ;
[0033] in, For point to its corresponding straight line vertical distance, For point to its corresponding straight line The direction angle, For point coordinate, Disclosure of coordinates;
[0034] The formula for calculating the direction in the direction consistency probability is as follows:
[0035] ;
[0036] in, Due to differences in direction, For point Local gradient direction, For point to its corresponding straight line Direction angle;
[0037] Weighted based on distance likelihood and direction likelihood Get points The complete weighted likelihood is calculated as follows:
[0038] ;
[0039] ;
[0040] ;
[0041] in, For a complete weighted likelihood, For distance likelihood, For directional likelihood, For the set of model parameters, For the attribution label, a hidden variable. This is a concentration parameter.
[0042] In this scheme, the step of obtaining the detection result by solving the dual-line-disclosure joint probability model based on the expectation-maximization algorithm specifically includes:
[0043] Initialize the attribution probability and estimate it given parameters. In this case, calculate each point Belongs to a straight line or straight line Post-hoc responsibility The calculation formula is as follows:
[0044] ;
[0045] in, , It is a linear mixing coefficient. For the attribution label, a hidden variable. For the given model parameters;
[0046] Based on the aforementioned posterior responsibility Update model parameter set The detection results are obtained based on the model parameters at the time of model convergence, and the detection results include the intersection coordinates, line parameters and confidence level.
[0047] A second aspect of the present invention also provides an image line intersection detection system, including a memory and a processor. The memory includes an image line intersection detection method program, which, when executed by the processor, performs the following steps:
[0048] The original input image is acquired, and multi-scale gradient field calculations are performed to generate a weighted guided edge map.
[0049] Seed points are selected from the weighted guided edge map to generate a support region, and two candidate point sets are obtained through iterative competition based on the support region.
[0050] A dual-line-disclosure joint probability model is constructed based on the two candidate point sets, wherein the points in the candidate point sets are used as latent variables to be estimated, and the point set in the weighted guided edge map is used as observation data.
[0051] The detection results are obtained by solving the dual-line-intersection joint probability model based on the expectation-maximization algorithm, wherein the detection results include at least the coordinates of the image intersection points.
[0052] In this scheme, the step of acquiring the input original image and performing multi-scale gradient field calculation to generate a weighted guided edge map specifically includes:
[0053] Obtain the original input image The gradient is calculated by smoothing using two Gaussian kernels of different scales, where the calculated gradient includes a fine-scale gradient and a coarse-scale gradient.
[0054] Calculate the local orientation consistency metric for each pixel and synthesize weights based on the constructed weight function, wherein the weight function is related to the coarse-scale gradient;
[0055] The weighted guided edge map is generated based on the synthesized weights, the calculated gradient, and the initial distance. The weighted guided edge map includes a triplet data field, and is calculated as follows:
[0056] ;
[0057] in, For triplet data fields, For the composite weights, For fine-scale gradients, This is the initial distance.
[0058] In this scheme, the step of selecting seed points from the weighted guided edge map to generate a support region, and then iteratively competing based on the support region to obtain two candidate point sets, specifically includes:
[0059] Pixels representing the target quantity value are selected from the weighted guided edge map as the initial seed point set. ;
[0060] With each seed point in the initial seed point set Centered on the seed point, the orientation consistency and spatial affinity of pixels within the calculation area are used to form the initial region. ;
[0061] Based on the initial region, regional competition and merging are performed, the principal direction and linearity of each region are calculated, and iterative merging is carried out to form two supporting regions. and ;
[0062] Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point in the candidate point set includes a position, weight, and local gradient direction.
[0063] In this scheme, the construction of the dual-line-interface joint probability model based on the two candidate point sets specifically includes:
[0064] Construct a dual-linear-disclosure joint probability model, in which,
[0065] Based on the normal parametric representation of two lines, the intersection coordinates are... The equation of the straight line is as follows:
[0066] ;
[0067] ;
[0068] in, , Two straight lines It is a straight line The direction angle, It is a straight line Direction angle;
[0069] Let the model parameter set be denoted as ,in, These describe the points surrounding the line. and Noise parameters related to the degree of dispersion of the distribution;
[0070] Introduce an attribution tag latent variable Determine each point in the candidate point set. The straight line belongs to, where For point coordinate, For point Weight, For point Local gradient direction, the line belonging to includes straight lines Or a straight line .
[0071] In this scheme, the construction of the dual-line-intersection joint probability model based on the two candidate point sets further includes:
[0072] Observation model parameters and attribution tags Time The joint probability, wherein the joint probability includes the geometric distance probability and the orientation consistency probability;
[0073] The distance calculation formula in the geometric distance probability is as follows:
[0074] ;
[0075] in, For point to its corresponding straight line vertical distance, For point to its corresponding straight line The direction angle, For point coordinate, Disclosure of coordinates;
[0076] The formula for calculating the direction in the direction consistency probability is as follows:
[0077] ;
[0078] in, Due to differences in direction, For point Local gradient direction, For point to its corresponding straight line Direction angle;
[0079] Weighted based on distance likelihood and direction likelihood Get points The complete weighted likelihood is calculated as follows:
[0080] ;
[0081] ;
[0082] ;
[0083] in, For a complete weighted likelihood, For distance likelihood, For directional likelihood, For the set of model parameters, For the attribution label, a hidden variable. This is a concentration parameter.
[0084] In this scheme, the step of obtaining the detection result by solving the dual-line-disclosure joint probability model based on the expectation-maximization algorithm specifically includes:
[0085] Initialize the attribution probability and estimate it given parameters. In this case, calculate each point Belongs to a straight line or straight line Post-hoc responsibility The calculation formula is as follows:
[0086] ;
[0087] in, , It is a linear mixing coefficient. For the attribution label, a hidden variable. For the given model parameters;
[0088] Based on the aforementioned posterior responsibility Update model parameter set The detection results are obtained based on the model parameters at the time of model convergence, and the detection results include the intersection coordinates, line parameters and confidence level.
[0089] A third aspect of the present invention provides a computer-readable storage medium comprising a machine program for detecting the intersection of lines in an image, wherein when executed by a processor, the program implements the steps of the image line intersection detection method as described in any of the preceding claims.
[0090] The present invention discloses an image line intersection point detection method, system, and readable storage medium, which have the following beneficial effects:
[0091] 1. Higher measurement accuracy and robustness: This invention generates a weighted guided edge map, which retains multi-dimensional information such as gradient magnitude, direction and local consistency, and quantifies the reliability of each point with weights. This avoids the information loss and threshold sensitivity problems caused by traditional binarized edge detection. In the subsequent joint probability model, the high-weight points have a greater impact on parameter estimation, making the algorithm more tolerant to noise and false edges. Thus, it can obtain more stable and accurate line and intersection point estimates in low-contrast, high-noise or complex texture images.
[0092] 2. Stronger adaptability and fewer empirical parameters: This invention reduces the dependence on a series of sensitive parameters such as Canny double threshold and Hough transform accumulator threshold. The construction of the weighted guided edge map and the growth process of the supporting region are mainly based on the statistical characteristics of the data itself.
[0093] 3. Intelligent processing of discontinuous line segments and complex structures: This invention, through the soft growth and competition mechanism of the support region, can naturally gather spatially discontinuous but oriented edge segments together to form support for a complete straight line. The joint probability model further allows points to support a certain straight line in a soft-attribution manner. Even if there are gaps or local distortions in the point cloud, the model can infer the optimal straight line path through global optimization. It is more flexible and robust than the line segment merging method based on a fixed threshold and can effectively deal with the situation where the target straight line is partially occluded or broken.
[0094] 4. Globally optimized intersection point estimation, which is the core advantage of this invention. By constructing a joint probability model of two lines and intersection points and optimizing it with the EM algorithm, we unify the detection of two lines and the solution of intersection points under one framework. The optimization process not only utilizes the geometric information of all relevant points, but also combines their local orientation information. Furthermore, through soft attribution, we achieve a “competitive interpretation” of the point set by the two lines. The final intersection point is the optimal fusion result of all support point information under global constraints. Its accuracy surpasses the method of simply fitting two lines independently and then finding their intersection. At the same time, sub-pixel accuracy is the inherent goal of the model, requiring no additional post-processing steps.
[0095] 5. Provides measurement information and uncertainty assessment. The probabilistic model framework naturally provides a measure of the uncertainty of the estimation results. The noise parameter reflects the degree of dispersion of the points around the line and can be used to evaluate the quality of the line fitting. By calculating the covariance matrix of the parameter estimates, the confidence ellipse or standard deviation of the intersection coordinates can be derived, providing users with a quantitative indicator of measurement reliability, which is extremely valuable in precision measurement and testing applications.
[0096] 6. Excellent computational efficiency and scalability: Although the probabilistic model and EM optimization appear complex, the data has been effectively filtered and condensed by the weighted guided edge map and support region generation steps, significantly reducing the number of points actually participating in the EM iteration. At the same time, the EM algorithm itself is an efficient iterative optimization method, which usually converges with only a few iterations. Therefore, the overall scheme can meet the needs of many real-time or near-real-time applications while maintaining high accuracy. In addition, the framework is easy to extend, for example, it can incorporate more complex noise models, prior distributions (such as known angles between two lines), or be extended to detect more lines and their intersection networks. Attached Figure Description
[0097] Figure 1 A flowchart of an image line intersection detection method according to the present invention is shown;
[0098] Figure 2 This diagram illustrates a weighted guided edge map visualization of an image line intersection detection method according to the present invention.
[0099] Figure 3 A schematic diagram of the support region generation in an image line intersection detection method according to the present invention is shown;
[0100] Figure 4 This diagram illustrates the joint probability model optimization of an image line intersection detection method according to the present invention.
[0101] Figure 5 A block diagram of an image line intersection detection system according to the present invention is shown. Detailed Implementation
[0102] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.
[0103] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0104] Specifically, from the theoretical perspective of image processing and machine vision, the problem of detecting the intersection of two straight lines can be decomposed into two core sub-problems: 1) Line detection: accurately extracting the two straight line segments or straight line models that constitute the intersection point from a two-dimensional digital image containing noise, texture, uneven lighting, and partial occlusion; 2) Intersection calculation: solving the intersection coordinates through geometric operations based on the extracted straight line model parameters, and performing uncertainty assessment or optimization on the results.
[0105] Existing technical solutions mainly revolve around these two sub-problems, and their evolution is closely related to the development of feature extraction, model fitting, and optimization algorithms. Early methods relied on manual or semi-automatic edge point selection and least-squares fitting, resulting in low automation. With the popularization of Hough Transform and its variants (such as probabilistic Hough Transform), automated line detection became possible. Subsequently, scale-invariant feature transformations (such as LSD - Line SegmentDetector) and deep learning methods further improved the performance of line detection in complex scenes. At the intersection point calculation level, the approach has evolved from simply solving linear equations to considering detection uncertainties and employing robust estimation or global optimization strategies to address noise and outlier interference.
[0106] Specifically, in the existing technology, a widely adopted implementation scheme that is similar to this invention can be summarized as "a scheme for double-line detection and intersection point solving based on edge enhancement and probabilistic Hough transform". This scheme represents a mature and robust mainstream method in current industrial vision systems. Its core process typically includes the following steps: image preprocessing and edge extraction, line detection based on probabilistic Hough transform, line grouping and filtering, intersection point calculation, and post-processing and verification. However, the existing technology still has the following technical problems in application:
[0107] 1. The contradiction between accuracy and noise sensitivity: Existing solutions rely heavily on the quality of early edge detection. Gaussian filtering smooths edges while suppressing noise, resulting in blurred edge localization and affecting the accuracy of subsequent line parameter estimation. The dual threshold settings of operators such as Canny need to be adjusted according to the image content, lacking adaptability and easily leading to edge breakage (missed detection) or the introduction of noisy edges (false detection). Especially for images with low contrast, weak edges, or texture interference, the uncertainty of edge extraction will be directly transmitted and amplified into the calculation error of intersection coordinates.
[0108] 2. The sensitivity and robustness of parameter settings are insufficient. The probabilistic Hough transform and its screening steps involve multiple empirical thresholds. These parameters need to be manually adjusted according to specific application scenarios, resulting in poor generalization ability. When imaging conditions change (such as changes in illumination, lens distortion, and reflection on the workpiece surface), a fixed set of parameters may lead to detection failure (such as missing straight lines or falsely detecting irrelevant straight lines). The logic for grouping and screening straight lines is usually based on simple rules or clustering. For cases with partial occlusion, edge breakage near intersections, or multiple approximately parallel interference lines, the robustness is poor, which can easily lead to incorrect grouping and misjudgment of intersections.
[0109] 3. The handling of broken and non-collinear line segments is rudimentary. In actual images, due to occlusion, uneven lighting, or uneven materials, the target straight line may appear as multiple discontinuous short line segments of varying lengths. Existing solutions usually use simple distance and angle thresholds to merge line segments. This heuristic rule-based method is prone to errors in complex situations, either over-merging (merging line segments that do not belong to the same straight line) or under-merging (failing to restore the complete straight line structure), thus affecting the accuracy of the final straight line model.
[0110] 4. Ignoring global structural information and context, this scheme is essentially a "bottom-up" process: from pixel-level edges to local line segments, and then to the global straight line model. In the process, it does not explicitly use the high-level prior knowledge of "two lines intersecting" for global constraints and joint optimization. For example, when solving for the intersection point, it only estimates the two lines independently and then calculates the intersection, without considering the common contribution of all possible edge points belonging to these two lines to the intersection point estimation, as well as the reverse constraint of the intersection point estimation result on the attribution of these points.
[0111] 5. Subpixel accuracy enhancement methods are isolated and computationally complex. To obtain the intersection point with subpixel accuracy, independent post-processing (such as gradient interpolation and region fitting) is usually performed after obtaining the pixel-level intersection point. These steps are separated from the previous line detection process, which increases the computational complexity and may not be able to fully utilize the information in the original image data.
[0112] The purpose of this invention is to overcome the shortcomings of the prior art and propose a novel machine vision method for measuring line intersections that is more robust, more accurate, and adaptable to complex scenarios. Specifically, the purpose of this invention is:
[0113] 1. Improve accuracy and robustness: Design a straight line feature extraction mechanism that is less dependent on the quality of initial edge detection and can better suppress noise and interference;
[0114] 2. Enhanced adaptability: Reduces reliance on manual empirical parameters, enabling the system to adapt to a wider range of imaging conditions and target morphology changes;
[0115] 3. Intelligent handling of line segment discontinuities: Proposes a more advanced method for line segment clustering and straight line model reconstruction, which can robustly handle broken and discontinuous edge line segments and accurately restore complete straight lines;
[0116] 4. Achieve global joint optimization: Incorporate the detection and intersection point solution of two lines into a unified probabilistic framework or optimization model, and use the prior of "two lines intersecting" for global reasoning to improve overall consistency;
[0117] 5. Achieve high efficiency and high precision integration: Subpixel precision estimation is naturally embedded into the core algorithm process, directly outputting high-precision intersection coordinates without excessively increasing the computational burden.
[0118] Specifically, Figure 1 A flowchart of an image line intersection detection method according to this application is shown.
[0119] like Figure 1 As shown, this application discloses a method for detecting the intersection points of straight lines in an image, including the following steps:
[0120] S102, acquire the input original image and perform multi-scale gradient field calculation to generate a weighted guided edge map;
[0121] S104, Select seed points from the weighted guided edge map to generate a support region, and perform iterative competition based on the support region to obtain two candidate point sets;
[0122] S106, Construct a dual-line-interface joint probability model based on the two candidate point sets;
[0123] S108, the detection results are obtained by solving the dual-line-disclosure joint probability model based on the expectation-maximization algorithm.
[0124] It should be noted that, in this embodiment, firstly, multi-scale gradient analysis is performed on the input original image to construct a weighted oriented edge map (WOEM) to achieve high-fidelity representation of edge features. Then, seed points are selected from the weighted oriented edge map to generate supporting regions. Specifically, through a direction-guided region growing and competition mechanism, two sets of candidate points supporting two straight lines are extracted from the WOEM. Subsequently, a dual-line-intersection joint probability model is constructed based on the two candidate point sets. Specifically, a dual-line joint probability model is established with intersection coordinates and line direction as parameters, and point set assignment is used as a latent variable, incorporating weighted likelihood of geometric distance and direction consistency. Finally, the expectation-maximization algorithm is used to iteratively optimize the model parameters to solve the dual-line-intersection joint probability model and obtain the detection result. In this process, the soft assignment of point sets and the line intersection estimation are updated simultaneously until convergence, and the intersection coordinates with sub-pixel accuracy and uncertainty metric are output as the detection result.
[0125] According to an embodiment of the present invention, the step of acquiring the input original image and performing multi-scale gradient field calculation to generate a weighted guided edge map specifically includes:
[0126] Obtain the original input image The gradient is calculated by smoothing using two Gaussian kernels of different scales, where the calculated gradient includes a fine-scale gradient and a coarse-scale gradient.
[0127] Calculate the local orientation consistency metric for each pixel and synthesize weights based on the constructed weight function, wherein the weight function is related to the coarse-scale gradient;
[0128] The weighted guided edge map is generated based on the synthesized weights, the calculated gradient, and the initial distance. The weighted guided edge map includes a triplet data field, and is calculated as follows:
[0129] ;
[0130] in, For triplet data fields, For the composite weights, For fine-scale gradients, This is the initial distance.
[0131] It should be noted that, in this embodiment, for the original image Using two different scales ( ,in The gradient is smoothed using a Gaussian kernel, and then the gradient is calculated to obtain the fine-scale gradient. and coarse-scale gradient Among them, fine-scale gradients are more accurate for edge localization but are sensitive to noise, while coarse-scale gradients are more robust to structure but have less accurate localization. The gradient magnitude of each pixel is calculated. and direction .
[0132] Furthermore, in this embodiment, to measure the confidence level of each pixel as an "ideal straight line edge point," a weighting function is described. It can simultaneously consider gradient magnitude and direction consistency, where is defined in pixels. A local neighborhood centered on (For example, one along the gradient direction) Consistency measure of gradient direction within an extended rectangular window : ,in, It is the imaginary unit. It is the number of pixels in the neighborhood, this consistency measure The value is between [0, 1]. A larger value indicates that the gradient direction is more consistent in that region (more likely to be part of a straight line). Meanwhile, the coarse-scale gradient magnitude is used... To suppress isolated noise points, the final synthesis weight is defined as follows: ,in, It is a small constant used to prevent the denominator from being zero, and the weights are... Larger values are taken in regions with high edge strength, consistent orientation, and high coarse-scale confidence, such as... Figure 2 As shown, the resulting WOEM is not a binary image, but a triplet data field. ,in, For triplet data fields, For the composite weights, For fine-scale gradients, The initial distance is given. It can be set to a large value. WOEM retains all potential edge information and uses weights to characterize its reliability, providing a rich and high-quality data foundation for subsequent processing.
[0133] According to an embodiment of the present invention, the step of selecting seed points from the weighted guided edge map to generate a support region, and obtaining two candidate point sets through iterative competition based on the support region, specifically includes:
[0134] Pixels representing the target quantity value are selected from the weighted guided edge map as the initial seed point set. ;
[0135] With each seed point in the initial seed point set Centered on the seed point, the orientation consistency and spatial affinity of pixels within the calculation area are used to form the initial region. ;
[0136] Based on the initial region, regional competition and merging are performed, the principal direction and linearity of each region are calculated, and iterative merging is carried out to form two supporting regions. and ;
[0137] Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point in the candidate point set includes a position, weight, and local gradient direction.
[0138] It should be noted that, in this embodiment, the weights are selected from WOEM. highest One (e.g.) Pixels as the initial seed point set For each seed point With it as the center, according to its direction Define a narrow "guided search window" within which the direction of the pixel point is consistent with that of the seed point. And spatial proximity, to calculate an affinity. and based on affinity and weight Based on the criteria, an initial region is grown. This is a soft assignment process, where a pixel may belong to multiple regions with different membership degrees.
[0139] Furthermore, in this embodiment, each initial region is then calculated. The principal direction (measured by weighted directional average within the region) and a rough linearity (e.g., by eigenvalue ratio from principal component analysis) are then used to determine the dominant supporting region. A competition is then conducted: for spatially overlapping regions with similar principal directions, they are merged based on their linearity and total weight, retaining those regions with high linearity and high total weight. After several rounds of iterative competition, two dominant supporting regions are obtained. and , specifically Figure 3 As shown, these correspond to the two target lines in the image, and each region contains a set of pixels. Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point has its position. Weight and local gradient direction .
[0140] According to an embodiment of the present invention, the construction of a dual-line-intersection joint probability model based on two candidate point sets specifically includes:
[0141] Construct a dual-linear-disclosure joint probability model, in which,
[0142] Based on the normal parametric representation of two lines, the intersection coordinates are... The equation of the straight line is as follows:
[0143] ;
[0144] ;
[0145] in, , Two straight lines It is a straight line The direction angle, It is a straight line Direction angle;
[0146] Let the model parameter set be denoted as ,in, These describe the points surrounding the line. and Noise parameters related to the degree of dispersion of the distribution;
[0147] Introduce an attribution tag latent variable Determine each point in the candidate point set. The straight line belongs to, where For point coordinate, For point Weight, For point Local gradient direction, the line belonging to includes straight lines Or a straight line .
[0148] It should be noted that, in this embodiment, the two straight lines are assumed to be... and It uses the normal form of a straight line as a parameter, but introduces an intersection point constraint, where the coordinates of the intersection point are assumed to be... Since both lines pass through the intersection point, each line can be determined with only one direction parameter. Let... The direction angle is , The direction angle is Then the equations of the two lines can be written as: Note that here a straight line is defined as passing through the point... An infinitely long straight line.
[0149] Furthermore, in this embodiment, the set of model parameters is denoted as... ,in, These describe the points surrounding the line. and The noise parameter represents the degree of dispersion of the distribution, and an attribution label latent variable is introduced. Determine each point in the candidate point set. The straight line belongs to, where For point coordinate, For point Weight, For point Local gradient direction, the line belonging to includes straight lines Or a straight line .
[0150] According to an embodiment of the present invention, the construction of the dual-line-interface joint probability model based on the two candidate point sets further includes:
[0151] Observation model parameter set and attribution tags Time The joint probability, wherein the joint probability includes the geometric distance probability and the orientation consistency probability;
[0152] The distance calculation formula in the geometric distance probability is as follows:
[0153] ;
[0154] in, For point to its corresponding straight line vertical distance, For point to its corresponding straight line The direction angle, For point coordinate, Disclosure of coordinates;
[0155] The formula for calculating the direction in the direction consistency probability is as follows:
[0156] ;
[0157] in, Due to differences in direction, For point Local gradient direction, For point to its corresponding straight line Direction angle;
[0158] Weighted based on distance likelihood and direction likelihood Get points The complete weighted likelihood is calculated as follows:
[0159] ;
[0160] ;
[0161] ;
[0162] in, For a complete weighted likelihood, For distance likelihood, For directional likelihood, For the set of model parameters, For the attribution label, a hidden variable. This is a concentration parameter.
[0163] It should be noted that, in this embodiment, the observation model parameter set and attribution tags Time The joint probability consists of two parts: the geometric distance probability and the orientation consistency probability, where the geometric distance probability is: point to its corresponding straight line vertical distance It should conform to a mean of 0 and a variance of . The Gaussian distribution has the following distance calculation formula: Therefore, the distance likelihood is: .
[0164] Furthermore, in this embodiment, the probability of directional consistency is: point Local gradient direction It should be with the straight line to which it belongs normal direction ( Similar to, or similar to the tangent direction ( Similar perpendicularity, but different defined directions (mold Suppose this difference follows a centralized distribution (such as a von Mises distribution or a truncated Gaussian distribution), and the corresponding directional likelihood is: ,in, It is a concentration parameter.
[0165] Furthermore, in this embodiment, the weight of each point is taken into account. To characterize its reliability, weights are incorporated into the likelihood function, and a point is defined. The complete weighted likelihood is: , exponentiation This makes higher-weighted points contribute more to the likelihood and lower-weighted points contribute less, which enhances the model's emphasis on reliable data. Specifically, it assumes that all observations are conditionally independent, thus assigning all points to specific data. At that time, the joint likelihood of the observed data is: ,in, This represents the set of all observation points. The goal of this embodiment is to find the optimal model parameters and soft attribution probability distribution that maximize the expected log-likelihood.
[0166] According to an embodiment of the present invention, the step of obtaining the detection result by solving the dual-line-disclosure joint probability model based on the expectation-maximization algorithm specifically includes:
[0167] Initialize the attribution probability and estimate it given parameters. In this case, calculate each point Belongs to a straight line or straight line Post-hoc responsibility The calculation formula is as follows:
[0168] ;
[0169] in, , It is a linear mixing coefficient. For the attribution label, a hidden variable. For the given model parameters;
[0170] Based on the aforementioned posterior responsibility Update model parameter set The detection results are obtained based on the model parameters at the time of model convergence, and the detection results include the intersection coordinates, line parameters and confidence level.
[0171] It should be noted that, in this embodiment, the Expectation-Maximization (EM) algorithm is used to solve the above-mentioned probabilistic model containing latent variables. The EM algorithm iteratively optimizes the parameters through E-steps (expectation steps) and M-steps (maximization steps). First, initialization is performed for the two support regions. and Given a set of points, two initial lines are independently fitted using the weighted least squares method to obtain the initial points. And solve for their intersection point as the initial intersection point. ,initialization Initialize the attribution probability by the standard deviation of the weighted distance from each region's point set to the initial line: for each region Let the point be. For the region Let the point be. This provides a starting point for a soft partition.
[0172] Furthermore, in this embodiment, step E (the t-th iteration): given parameter estimation In this case, calculate each observation point Belongs to a straight line or Post-hoc responsibility The calculation formula is as follows:
[0173] ;
[0174] in, , It is the linear mixing coefficient (which can be initialized to 0.5 or updated during iteration, reflecting the "weight" of each line). For the attribution label, a hidden variable. Given the model parameters, at the same time, Calculated using the aforementioned weighted joint observation probability formula.
[0175] Furthermore, in this embodiment, step M (the t-th iteration): using the responsibility calculated in step E. Update model parameters To maximize the expected log-likelihood of the complete data Due to model parameters Appears in the distance item In the process, the update requires solving a weighted nonlinear optimization problem, specifically using the Gauss-Newton method or the Levenberg-Marquardt (LM) method as the preset algorithm for iterative solution. Specifically, the following weighted objective function is minimized:
[0176] ;
[0177] in, and Indicates when point Belongs to a straight line At that time, according to the current The calculated distance and direction difference are fixed in M steps. And current estimates ,right Optimize to reduce Then, update the noise parameters: Mixing coefficient It can also be updated to: Repeat the E-step and M-step until the parameter change is less than a preset threshold or the maximum number of iterations is reached. Finally, the model converges to the optimal parameters. The final intersection coordinates are obtained through optimization. Because the model performs joint optimization across the entire point set and considers the weight and orientation information of each point, the intersection point achieves sub-pixel accuracy; line parameters: The precise directions of the two lines are given, with confidence level: parameters. And by calculating the Hessian matrix in The covariance matrix obtained by inverse covariance can provide confidence intervals or uncertainty measures for the intersection coordinates and line direction estimates, which are important indicators for quality assessment. For example, Figure 4 As shown, the EM algorithm iterative process demonstrates how the two straight lines (red and blue dashed lines) and their intersection (yellow stars) are gradually adjusted from the initial estimate (left figure) and finally converge to the optimal position (right figure). The background color indicates the responsibility of each point for the two straight lines.
[0178] Figure 5 A block diagram of an image line intersection detection system according to the present invention is shown.
[0179] like Figure 5 As shown, this invention discloses an image line intersection detection system, including a memory and a processor. The memory includes an image line intersection detection method program, which, when executed by the processor, performs the following steps:
[0180] The original input image is acquired, and multi-scale gradient field calculations are performed to generate a weighted guided edge map.
[0181] Seed points are selected from the weighted guided edge map to generate a support region, and two candidate point sets are obtained through iterative competition based on the support region.
[0182] A dual-line-disclosure joint probability model is constructed based on the two candidate point sets, wherein the points in the candidate point sets are used as latent variables to be estimated, and the point set in the weighted guided edge map is used as observation data.
[0183] The detection results are obtained by solving the dual-line-intersection joint probability model based on the expectation-maximization algorithm, wherein the detection results include at least the coordinates of the image intersection points.
[0184] It should be noted that when the image line intersection detection system disclosed in this application is applied, the specific process corresponds to the image line intersection detection method described in the above embodiments. Since the specific implementation of the system application is consistent with the content of the above image line intersection detection method, no further details will be provided in this embodiment.
[0185] A third aspect of the present invention provides a computer-readable storage medium including a program for detecting the intersection of lines in an image, wherein when executed by a processor, the program implements the steps of the method for detecting the intersection of lines in an image as described in any of the preceding claims.
[0186] This invention discloses an image line intersection detection method, system, and readable storage medium, which can significantly improve the accuracy and robustness of image line intersection detection. It effectively overcomes the problems of traditional methods, such as excessive reliance on edge detection quality, sensitivity to parameter settings, and weak line segment breakage handling capabilities. Even under complex imaging conditions, it can still output intersection coordinates with sub-pixel accuracy and includes built-in uncertainty assessment. It achieves an integrated high-precision, adaptive processing flow from feature extraction to result output. The key points and protections of this invention mainly include the following aspects:
[0187] 1. Construction method of weighted guided edge map (WOEM): Preserving and utilizing multi-scale gradient information and local orientation consistency to calculate pixel weights. And form a triplet characteristic field The methods used for subsequent processing of the underlying data specifically include: multi-scale gradient calculation and directional consistency measures based on complex exponential summation. and the weighting formula This is a fundamental innovation that improves the robustness and accuracy of algorithms;
[0188] 2. Intelligent generation method for straight-line support regions based on WOEM: This method preserves the two main support regions corresponding to the target straight line by selecting seed points from WOEM, guiding region growth based on direction and spatial affinity, and a competitive merging mechanism between regions based on linearity and total weight. and This method solves the problem of integrating straight line features in cases of broken and discontinuous line segments.
[0189] 3. Specific construction of the joint probability model of two straight lines and intersection points: protecting the coordinates of the intersection points and the direction angle of the line As a core parameter, the observation points are assigned to As a latent variable, and defined to include geometric distance likelihood and directional consistency likelihood Weighted joint observation probability The model form, especially the weights As a likelihood index, this design, which emphasizes the contribution of reliable observation points, is key to improving accuracy.
[0190] 4. Solution process for joint parameter optimization based on the Expectation-Maximization (EM) algorithm: The specific steps for optimizing the above joint probability model using the EM algorithm include: initializing parameters and soft attribution probabilities using the support region; calculating the posterior responsibility of the point to the two lines based on the current parameters in the E-step. In the M-step, the weighted objective function is minimized. Update the intersection point coordinates and line direction parameters, and simultaneously update the noise parameters. and mixing coefficient The optimization mechanism, which involves iterating until convergence, is the core of achieving high-precision global intersection point estimation.
[0191] 5. Output including uncertainty metric: Protects the final intersection coordinates in the output. and straight line direction Simultaneously, output noise parameters And / or methods that estimate the uncertainty of the intersection point (such as standard deviation or confidence ellipse) derived from the parametric covariance matrix, which provide a basis for quality assessment of the measurement results;
[0192] 6. The complete system and method formed by combining the above key points 1 to 5: protect the entire machine vision measurement process from image input to high-precision intersection coordinates (and uncertainty) output. This process is based on weighted guided edge maps as features, support region generation as data preparation, joint probability models as the theoretical core, and EM optimization as the solution method.
[0193] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0194] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0195] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0196] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0197] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
Claims
1. A method for detecting the intersection points of straight lines in an image, characterized in that, Includes the following steps: The original input image is acquired, and multi-scale gradient field calculations are performed to generate a weighted guided edge map. Seed points are selected from the weighted guided edge map to generate a support region, and two candidate point sets are obtained through iterative competition based on the support region. A dual-line-disclosure joint probability model is constructed based on the two candidate point sets, wherein the points in the candidate point sets are used as latent variables to be estimated, and the point set in the weighted guided edge map is used as observation data. The detection results are obtained by solving the dual-line-intersection joint probability model based on the expectation-maximization algorithm, wherein the detection results include at least the coordinates of the image intersection points.
2. The image line intersection detection method according to claim 1, characterized in that, The process of acquiring the input original image and performing multi-scale gradient field calculations to generate a weighted guided edge map specifically includes: Obtain the original input image The gradient is calculated by smoothing using two Gaussian kernels of different scales, where the calculated gradient includes a fine-scale gradient and a coarse-scale gradient. Calculate the local orientation consistency metric for each pixel and synthesize weights based on the constructed weight function, wherein the weight function is related to the coarse-scale gradient; The weighted guided edge map is generated based on the synthesized weights, the calculated gradient, and the initial distance. The weighted guided edge map includes a triplet data field, and is calculated as follows: ; in, For triplet data fields, For the composite weights, For fine-scale gradients, This is the initial distance.
3. The method of claim 2, wherein, The step of selecting seed points from the weighted guided edge map to generate a support region, and then iteratively competing based on the support region to obtain two candidate point sets, specifically includes: Pixels representing the target quantity value are selected from the weighted guided edge map as the initial seed point set. ; for each seed point in the initial set of seed points calculating, for each pixel in the field of view, a direction consistency and a spatial affinity with the seed point to form an initial region ; Based on the initial region, regional competition and merging are performed, the principal direction and linearity of each region are calculated, and iterative merging is carried out to form two supporting regions. and ; Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point in the candidate point set includes a position, weight, and local gradient direction.
4. The image line intersection detection method according to claim 3, characterized in that, The construction of the dual-line-interface joint probability model based on the two candidate point sets specifically includes: Construct a dual-linear-disclosure joint probability model, in which, Based on the normal parametric representation of two lines, the intersection coordinates are... The equation of the straight line is as follows: ; ; in, , Two straight lines It is a straight line The direction angle, It is a straight line Direction angle; Let the model parameter set be denoted as ,in, These describe the points surrounding the line. and Noise parameters related to the degree of dispersion of the distribution; Introduce an attribution label latent variable Determine each point in the candidate point set. The straight line belongs to, where For point coordinate, For point Weight, For point Local gradient direction, the line belonging to includes straight lines Or a straight line .
5. The image line intersection detection method according to claim 4, characterized in that, The construction of the dual-line-interface joint probability model based on the two candidate point sets further includes: Observation model parameter set and attribution tags Time The joint probability, wherein the joint probability includes the geometric distance probability and the orientation consistency probability; The distance calculation formula in the geometric distance probability is as follows: ; in, For point to its corresponding straight line vertical distance, For point to its corresponding straight line The direction angle, For point coordinate, Disclosure of coordinates; The formula for calculating the direction in the direction consistency probability is as follows: ; in, Due to differences in direction, For point Local gradient direction, For point to its corresponding straight line Direction angle; Weighted based on distance likelihood and direction likelihood Get points The complete weighted likelihood is calculated as follows: ; ; ; in, For a complete weighted likelihood, For distance likelihood, For directional likelihood, For the set of model parameters, For the attribution label, a hidden variable. This is a concentration parameter.
6. The image line intersection detection method according to claim 5, characterized in that, The detection results obtained by solving the dual-line-understanding joint probability model based on the expectation-maximization algorithm specifically include: Initialize the attribution probability and estimate it given parameters. In this case, calculate each point Belongs to a straight line or straight line Post-hoc responsibility The calculation formula is as follows: ; in, , It is a linear mixing coefficient. For the attribution label, a hidden variable. For the given model parameters; Based on the aforementioned posterior responsibility Update model parameter set The detection results are obtained based on the model parameters at the time of model convergence, and the detection results include the intersection coordinates, line parameters and confidence level.
7. An image line intersection detection system, characterized in that, The system includes a memory and a processor. The memory contains a program for detecting the intersection of lines in an image. When the processor executes the program for detecting the intersection of lines in an image, it performs the following steps: The original input image is acquired, and multi-scale gradient field calculations are performed to generate a weighted guided edge map. Seed points are selected from the weighted guided edge map to generate a support region, and two candidate point sets are obtained through iterative competition based on the support region. A dual-line-disclosure joint probability model is constructed based on the two candidate point sets, wherein the points in the candidate point sets are used as latent variables to be estimated, and the point set in the weighted guided edge map is used as observation data. The detection results are obtained by solving the dual-line-intersection joint probability model based on the expectation-maximization algorithm, wherein the detection results include at least the coordinates of the image intersection points.
8. The image line intersection detection system according to claim 7, characterized in that, The process of acquiring the input original image and performing multi-scale gradient field calculations to generate a weighted guided edge map specifically includes: Obtain the original input image The gradient is calculated by smoothing using two Gaussian kernels of different scales, where the calculated gradient includes a fine-scale gradient and a coarse-scale gradient. Calculate the local orientation consistency metric for each pixel and synthesize weights based on the constructed weight function, wherein the weight function is related to the coarse-scale gradient; The weighted guided edge map is generated based on the synthesized weights, the calculated gradient, and the initial distance. The weighted guided edge map includes a triplet data field, and is calculated as follows: ; in, For triplet data fields, For the composite weights, For fine-scale gradients, This is the initial distance.
9. The image line intersection detection system according to claim 8, characterized in that, The step of selecting seed points from the weighted guided edge map to generate a support region, and then iteratively competing based on the support region to obtain two candidate point sets, specifically includes: Pixels representing the target quantity value are selected from the weighted guided edge map as the initial seed point set. ; With each seed point in the initial seed point set Centered on the seed point, the orientational consistency and spatial affinity of pixels within the calculation area are used to form the initial region. ; Based on the initial region, regional competition and merging are performed, the principal direction and linearity of each region are calculated, and iterative merging is carried out to form two supporting regions. and ; Two candidate point sets are obtained based on the pixels contained in the two support regions, wherein each point in the candidate point set includes a position, weight, and local gradient direction.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a method program for detecting the intersection of lines in an image. When the method program is executed by a processor, it implements the steps of the method for detecting the intersection of lines in an image as described in any one of claims 1 to 6.