Method, device, storage medium and electronic device for determining line segment in image

By completing and filtering line segments in the image, the problem of low line segment extraction efficiency is solved, and more efficient line segment feature analysis is achieved.

CN115564714BActive Publication Date: 2026-06-19ZHEJIANG HUARAY TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG HUARAY TECH CO LTD
Filing Date
2022-09-08
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies for extracting line segments from images are inefficient, resulting in discontinuous line segments and high computational costs, which affect the accuracy and efficiency of subsequent feature analysis.

Method used

By obtaining an initial set of line segments, identifying and completing incomplete line segments to form a target set of line segments, and then filtering out target line segments based on their length, eliminating excessively short line segments to improve efficiency.

Benefits of technology

It improves the efficiency and accuracy of line segment extraction, reduces the amount of computation, and enhances the effect of line segment feature analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115564714B_ABST
    Figure CN115564714B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, storage medium, and electronic device for determining line segments in an image. The method includes: acquiring an initial line segment set, which includes normal line segments and incomplete line segments extracted from the image to be processed; performing completion processing on the incomplete line segments in the initial line segment set to obtain a target line segment set, which includes normal line segments and completed line segments obtained after completing the incomplete line segments; and determining a target line segment in the target line segment set based on the length of each line segment in the target line segment set. This invention solves the problem of low efficiency in line segment extraction in related technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and more specifically, to a method, apparatus, storage medium, and electronic device for determining line segments in an image. Background Technology

[0002] In recent years, with the rapid development of information technology, feature extraction from images has become the primary and most important step in the research of visual odometry. How to efficiently extract the feature information contained in images and use it for subsequent positioning and navigation operations has become a major research hotspot. Currently, the mainstream image feature used is point feature, which researchers use to obtain information such as edges and corners in images. However, in some specific scenarios, the scene is relatively empty and the texture is relatively simple, making it impossible to obtain the required number of feature points. Therefore, extracting and using line segment features has become a way to solve this problem. Line features can still provide stable and a certain amount of feature information in some sparse textured scenes. Existing methods for extracting features from images search the entire image to extract pixels that meet the conditions and generate line segments. During the extraction process, some line segments may be discontinuous due to image angles and pixel differences, resulting in missing segments. Furthermore, the large search range across the entire image leads to high computational costs, limiting the speed of line segment extraction. Therefore, existing technologies suffer from low efficiency in extracting line segments.

[0003] There is currently no effective solution to the problem of low efficiency in extracting line segments in related technologies. Summary of the Invention

[0004] This invention provides a method, apparatus, storage medium, and electronic device for determining line segments in an image, to at least solve the problem of low efficiency in line segment extraction in related technologies.

[0005] According to an embodiment of the present invention, a method for determining line segments in an image is provided, comprising: obtaining an initial line segment set, wherein the initial line segment set includes normal line segments and incomplete line segments extracted from an image to be processed; performing a completion process on the incomplete line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set includes the normal line segments and completed line segments obtained after completing the incomplete line segments; and determining a target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set.

[0006] In an exemplary embodiment, the process of completing the missing line segments in the initial line segment set includes: obtaining at least two initial line segments located on the same straight line in the initial line segment set, wherein the initial line segments include the normal line segments and the missing line segments; determining the initial line segments among the at least two initial line segments whose distance between adjacent line segments is less than or equal to a preset threshold as a group of missing line segments; and performing the completion process on the group of missing line segments to obtain the completed line segments.

[0007] In an exemplary embodiment, obtaining at least two initial line segments located on the same straight line from the initial line segment set includes: determining a target coordinate system based on the processed image; performing the following steps on each initial line segment in the initial line segment set, wherein each initial line segment is a current initial line segment: determining a first plane and a second plane corresponding to the current initial line segment in the target coordinate system, wherein the first plane and the second plane are perpendicular; determining the intersection of the first plane and the second plane as the current intersection line; and determining at least two initial line segments located on the current intersection line in the initial line segment set as at least two initial line segments on the same straight line.

[0008] In an exemplary embodiment, performing the completion process on the missing line segment to obtain the completed line segment includes: obtaining at least two missing line segments located on the same straight line from the initial line segment set; and performing the completion process on the at least two missing line segments to obtain the completed line segment.

[0009] In an exemplary embodiment, performing the completion process on the at least two missing line segments to obtain the completed line segment includes: performing the completion process on a first missing line segment and a second missing line segment among the at least two missing line segments through the following steps, wherein the first missing line segment and the second missing line segment are two adjacent line segments: obtaining two adjacent coordinates between the first missing line segment and the second missing line segment; connecting the two adjacent coordinates between the first missing line segment and the second missing line segment, and determining the connected first missing line segment and the second missing line segment as the line segment after the completion process.

[0010] In an exemplary embodiment, the method further includes: if the at least two incomplete line segments include a third incomplete line segment, and the third incomplete line segment and the completed line segment are two adjacent line segments, obtaining two adjacent coordinates between the completed line segment and the third incomplete line segment; and connecting the two adjacent coordinates between the completed line segment and the third incomplete line segment to obtain the completed line segment.

[0011] In an exemplary embodiment, determining a target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set includes: performing the following steps on each line segment in the target line segment set, wherein each line segment is a current line segment when performing the following steps: obtaining the current line segment length of the current line segment; obtaining the current length threshold corresponding to the current line segment; and determining the current line segment as a target line segment if the current line segment length is greater than or equal to the current length threshold.

[0012] In an exemplary embodiment, obtaining the current length threshold corresponding to the current line segment includes: obtaining the first abscissa and first ordinate of the first endpoint of the current line segment, the second abscissa and second ordinate of the second endpoint, and the height and width of the image to be processed; obtaining the abscissa difference between the first abscissa and the second abscissa, and the ordinate difference between the first ordinate and the second ordinate; and determining the length threshold based on the magnitude of the abscissa difference and the ordinate difference, and the height and width of the image to be processed.

[0013] In an exemplary embodiment, determining the length threshold based on the magnitude of the difference between the horizontal coordinates and the difference between the vertical coordinates, and the height and width of the image to be processed, includes: when the difference between the horizontal coordinates is greater than the difference between the vertical coordinates, obtaining the length threshold using the following formula:

[0014]

[0015] When the difference in the horizontal coordinates is less than or equal to the difference in the vertical coordinates, the length threshold is obtained using the following formula:

[0016]

[0017] Where ζ is a preset parameter, h is the height of the image to be processed, w is the width of the image to be processed, u1 is the first horizontal coordinate, v1 is the first vertical coordinate, u2 is the second horizontal coordinate, and v2 is the second vertical coordinate.

[0018] In an exemplary embodiment, obtaining the initial line segment set includes: performing bilateral filtering optimization on the image to be processed to obtain an optimized image; determining a target region in the optimized image based on gradient information in the optimized image, wherein the target region is a region where the gradient change is greater than or equal to a preset threshold; and extracting line segments in the target region to obtain the initial line segment set.

[0019] According to another embodiment of the present invention, a device for determining line segments in an image is also provided, comprising: an acquisition module for acquiring an initial set of line segments, wherein the initial set of line segments includes normal line segments and incomplete line segments extracted from the image to be processed;

[0020] The completion module is used to complete the incomplete line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set includes the normal line segments and the completed line segments obtained after completing the incomplete line segments;

[0021] The determination module is used to determine the target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set.

[0022] According to yet another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, wherein the computer program is configured to perform the steps in any of the above method embodiments when it is run.

[0023] According to yet another embodiment of the present invention, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.

[0024] This invention obtains an initial set of line segments, including normal line segments and incomplete line segments extracted from the image to be processed; it then performs a completion process on the incomplete line segments in the initial set to obtain a target set of line segments, which includes normal line segments and completed line segments obtained after completing the incomplete line segments; finally, it identifies target line segments based on the length of each line segment in the target set. Therefore, this invention solves the problem of low efficiency in line segment extraction in related technologies, achieving an improved efficiency in line segment extraction. Attached Figure Description

[0025] Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of determining line segments in an image according to an embodiment of the present invention.

[0026] Figure 2 This is a flowchart of a method for determining line segments in an image according to an embodiment of the present invention;

[0027] Figure 3 This is an optional line segment extraction schematic diagram according to an embodiment of the present invention;

[0028] Figure 4 This is a schematic diagram of the target line segment set obtained by optional line segment completion according to an embodiment of the present invention;

[0029] Figure 5 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 1 ;

[0030] Figure 6 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 2 ;

[0031] Figure 7 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 3 ;

[0032] Figure 8 This is a schematic diagram of the vertical plane and its intersection line in an optional Plück coordinate system according to an embodiment of the present invention;

[0033] Figure 9 This is an illustration of optional incomplete line segment completion according to an embodiment of the present invention. Figure 1 ;

[0034] Figure 10 This is an illustration of optional incomplete line segment completion according to an embodiment of the present invention. Figure 2 ;

[0035] Figure 11 This is a flowchart of an optional method for determining line segments in an image according to an embodiment of the present invention;

[0036] Figure 12 This is a schematic diagram illustrating the determination of a target area according to an embodiment of the present invention;

[0037] Figure 13 This is a structural block diagram of a device for determining line segments in an image according to an embodiment of the present invention. Detailed Implementation

[0038] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples.

[0039] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0040] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a mobile terminal hardware structure block diagram of the method for determining line segments in an image according to an embodiment of the present invention. For example... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.

[0041] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the method for determining line segments in an image in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0042] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module, used for wireless communication with the Internet.

[0043] This embodiment provides a method for determining line segments in an image. Figure 2 This is a flowchart of a method for determining line segments in an image according to an embodiment of the present invention, as shown below. Figure 2 As shown, the process includes the following steps:

[0044] Step S202: Obtain an initial line segment set, wherein the initial line segment set includes normal line segments and incomplete line segments extracted from the image to be processed;

[0045] In the process of extracting initial line segments from the image to be processed, some line segments that should be continuous are often found to be discontinuous, divided into at least two segments. These discontinuous line segments are the incomplete line segments extracted from the image to be processed. The continuous line segments extracted without any discontinuity are the normal line segments extracted from the image to be processed.

[0046] Figure 3 This is an optional line segment extraction schematic diagram according to an embodiment of the present invention, such as... Figure 3 As shown, the extracted line segments include line segment AB, line segment CD, and line segment EF. Line segment AB is a continuous line segment, which corresponds to the normal line segment in the initial line segment set. Line segments CD and EF are two line segments extracted after a continuous line segment is interrupted, which correspond to the incomplete line segment in the initial line segment set.

[0047] Step S204: Complete the missing line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set includes the normal line segments and the completed line segments obtained after completing the missing line segments;

[0048] In this embodiment, at least two incomplete line segments are extracted from a continuous line segment. These incomplete segments inevitably lose some features, leading to errors in subsequent feature analysis based on the extracted line segments. For example, when matching the same line segment in two images from different perspectives, the line segment in one image may be divided into multiple discontinuous segments, potentially failing to match the corresponding complete line segment in the other image. This issue of incomplete line segments affects the accuracy of line segment matching. Therefore, to reduce the impact of missing features, incomplete line segments in the initial line segment set are supplemented, adding new features through this supplementation.

[0049] Figure 4 This is a schematic diagram of the target line segment set obtained by optional line segment completion according to an embodiment of the present invention, such as... Figure 4 As shown, Figure 3 The missing line segments: obtained after completing line segments CD and EF. Figure 4 In the target line segment set, line segment CF is the completed line segment obtained after completion processing, while line segment AB is a normal line segment that does not need to be completed. The completed line segment and the normal line segment obtained after completion processing are recorded in the target line segment set. Figure 4 The target line segment set obtained after the completion process includes line segment AB and line segment CF.

[0050] Step S206: Determine the target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set.

[0051] In this embodiment, some line segments that are too short contain very little line segment information. These short line segments have little effect on subsequent line segment feature analysis. However, a large number of short line segments may exist in the target line segment set, thus increasing the computational load of line segment feature analysis, but having little impact on the analysis results. Therefore, line segments that meet the line segment length requirements are selected based on the line segment length of each line segment in the target line segment set, thereby reducing the computational load of subsequent line segment feature analysis and improving the efficiency of line segment feature analysis.

[0052] Through the above steps, a set of target line segments is obtained by completing the incomplete line segments extracted from the image to be processed. The target line segments are determined according to the length of each line segment in the target line segment set. The missing parts of continuous line segments due to occlusion or shooting angle are incomplete, making the extracted line segment features richer. The extracted line segments are also filtered so that short line segments are not included in the subsequent line feature analysis, which improves the efficiency of line segment feature analysis and solves the problem of low efficiency in line segment extraction in related technologies.

[0053] In an optional embodiment, the process of completing the missing line segments in the initial line segment set includes: obtaining at least two initial line segments located on the same straight line in the initial line segment set, wherein the initial line segments include the normal line segments and the missing line segments; identifying the initial line segments among the at least two initial line segments whose distance between adjacent line segments is less than or equal to a preset threshold as the missing line segments; and performing the completion process on the missing line segments to obtain the completed line segments.

[0054] In this embodiment, during the process of completing the incomplete line segments, it is necessary to first determine which of the extracted initial line segments are incomplete and which are normal line segments.

[0055] First, the missing line segment is generated by the discontinuity of a continuous line segment. Therefore, the line segment to be completed should be located on the same straight line. Thus, during the completion process, all initial line segments located on the same straight line are obtained, including at least two initial line segments. It should be noted that if there is only one initial line segment on a straight line, it means that the initial line segment is a normal line segment and does not need to be completed. Therefore, it is only necessary to obtain two or more initial line segments on a straight line.

[0056] If the distance between two adjacent initial line segments on the same straight line is less than or equal to a threshold, it means that the two initial line segments are two incomplete line segments obtained by interruption from a continuous line segment. Filling in the missing parts of the incomplete line segments is the process of completing the incomplete line segments to obtain the completed line segments.

[0057] The initial line segments on the same straight line include various cases. The following example illustrates that the initial line segments in which the distance between adjacent line segments of the at least two initial line segments is less than or equal to a preset threshold are determined as a group of the incomplete line segments.

[0058] Figure 5 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 1 ,like Figure 5 As shown, when the initial line segments on the same straight line contain only two initial line segments (line segment AB and line segment CD), line segments AB and CD are adjacent, and the distance between line segments AB and CD is the distance between point B and point C. If the distance between point B and point C is less than or equal to a preset threshold, line segments AB and CD are determined as a set of incomplete line segments and are then filled in.

[0059] Figure 6 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 2 ,like Figure 6 As shown, when the initial line segments on the same straight line include three initial line segments (line segment AB, line segment CD, and line segment EF), line segment AB and line segment CD are adjacent, line segment CD and line segment EF are adjacent, the distance between line segment AB and line segment CD is the distance between point B and point C, and the distance between line segment CD and line segment EF is the distance between point D and point E.

[0060] If the distance between line segments AB and CD, and the distance between line segments CD and EF are both less than or equal to a preset threshold, then line segments AB, CD, and EF are identified as a group of incomplete line segments. If the distance between line segments AB and CD is less than or equal to a preset threshold, and the distance between line segments CD and EF is greater than a preset threshold, then line segments AB and CD are identified as a group of incomplete line segments, and line segment DF is identified as a normal line segment.

[0061] Figure 7 This is a schematic diagram of an optional initial line segment on the same straight line according to an embodiment of the present invention. Figure 3 ,like Figure 7 As shown, the initial line segments on the same straight line include four initial line segments (line segment AB, line segment CD, line segment EF, and line segment GH). Line segments AB and CD are adjacent, line segments CD and EF are adjacent, and line segments EF and GH are adjacent. The distance between line segments AB and CD is the distance between points B and C, the distance between line segments CD and EF is the distance between points D and E, and the distance between line segments EF and GH is the distance between points F and G.

[0062] Assumption Figure 7If the distance between line segment AB and line segment CD is less than or equal to a preset threshold, the distance between line segment CD and line segment EF is greater than a preset threshold, and the distance between line segment EF and line segment GH is less than or equal to a preset threshold, then line segment AB and line segment CD are identified as one set of incomplete line segments, and line segment EF and line segment GH are identified as another set of incomplete line segments.

[0063] In an optional embodiment, obtaining at least two initial line segments located on the same straight line from the initial line segment set includes: determining a target coordinate system based on the image to be processed; performing the following steps on each initial line segment in the initial line segment set, wherein each initial line segment is a current initial line segment: determining a first plane and a second plane corresponding to the current initial line segment in the target coordinate system, wherein the first plane and the second plane are perpendicular; determining the intersection of the first plane and the second plane as the current intersection line; and determining at least two initial line segments located on the current intersection line in the initial line segment set as at least two initial line segments on the same straight line.

[0064] In this embodiment, when obtaining at least two initial line segments located on the same straight line, it is first necessary to determine which line segments in the initial line segment set are on the same straight line, and then determine whether there are any other line segments on the same straight line as each initial line segment in the initial line segment set.

[0065] The aforementioned target coordinate system can be the Plücker coordinate system, since a straight line can be determined by both its direction and the direction perpendicular to it. Furthermore, any straight line can be determined by two intersecting planes, and the line of intersection of these two planes is a unique straight line. Therefore, if two intersecting planes are placed in the Plücker coordinate system, keeping them perpendicular, their line of intersection will be a unique straight line in the Plücker coordinate system.

[0066] The horizontal plane in the Plück coordinate system is tiled in the image to be processed, meaning that all initial line segments in the image to be processed are located in the same plane (i.e., the horizontal plane) in the Plück coordinate system.

[0067] In the Plücker coordinate system, determine two mutually perpendicular planes (the first plane and the second plane) corresponding to the current initial line segment, and the first plane and the second plane include the current initial line segment.

[0068] Specifically, the first plane can be the horizontal plane in the Plücker coordinate system, and the second plane can be a vertical plane in the Plücker coordinate system that is perpendicular to the horizontal plane. The line of intersection determined by the first and second planes is unique, and all initial line segments on this line of intersection are initial line segments lying on the same straight line.

[0069] Figure 8This is a schematic diagram of a vertical plane and its intersection line in an optional Plücker coordinate system according to an embodiment of the present invention, as shown below. Figure 8 As shown, determine the first plane and the second plane corresponding to line segment AB. The intersection of the first plane and the second plane is the straight line l. The first plane is a horizontal plane and the second plane is a vertical plane. Line segments CD and EF are located on the straight line l, while line segment GH is not located on the straight line l. Therefore, line segments AB, CD, and EF are at least two initial line segments located on the same straight line.

[0070] It's worth noting that the advantage of using the Plück coordinate system is that common intersection problems (parallelism, intersection, lying on the same line, etc.) can be handled with just a few simple operations. In actual programming, division operations are eliminated, reducing programming complexity and improving efficiency.

[0071] In an optional embodiment, performing the completion process on the missing line segment to obtain the completed line segment includes: obtaining at least two missing line segments located on the same straight line from the initial line segment set; and performing the completion process on the at least two missing line segments to obtain the completed line segment.

[0072] In this embodiment, when performing the completion process on the missing line segments, at least two missing line segments located on the same straight line are obtained for completion processing. Initial line segments that are identified as normal line segments on the same straight line are not completed.

[0073] In an optional embodiment, the completion process is performed on the at least two missing line segments to obtain the completed line segment, including: performing the completion process on a first missing line segment and a second missing line segment among the at least two missing line segments through the following steps, wherein the first missing line segment and the second missing line segment are two adjacent line segments: obtaining two adjacent coordinates between the first missing line segment and the second missing line segment; connecting the two adjacent coordinates between the first missing line segment and the second missing line segment, and determining the connected first missing line segment and the second missing line segment as the line segment after the completion process.

[0074] In this embodiment, a set of incomplete line segments located on a straight line are obtained, and the missing parts between two adjacent incomplete line segments are filled in. When filling in the missing parts between two adjacent incomplete line segments, the two adjacent coordinates between the two incomplete line segments are connected, thus filling the two incomplete line segments into a continuous line segment.

[0075] Figure 9 This is an illustration of optional incomplete line segment completion according to an embodiment of the present invention. Figure 1 , corresponding to Figure 5 ,Will Figure 5To complete the missing line segments AB and CD, we need to connect the two adjacent coordinates between them, i.e., connect points B and C. Completing AB and CD results in a continuous line segment AD. Figure 9 The line segment AD shown is the completed version.

[0076] In an optional embodiment, the method further includes: if the at least two missing line segments include a third missing line segment, and the third missing line segment and the completed line segment are two adjacent line segments, obtaining two adjacent coordinates between the completed line segment and the third missing line segment; and connecting the two adjacent coordinates between the completed line segment and the third missing line segment to obtain the completed line segment.

[0077] In this embodiment, when there are more than two missing line segments on the same straight line, the two adjacent missing line segments are completed, and the completed line segments are then completed with other missing line segments adjacent to the completed line segments.

[0078] Figure 10 This is an illustration of optional incomplete line segment completion according to an embodiment of the present invention. Figure 2 ,like Figure 10 As shown, at least two incomplete line segments on the same straight line include three incomplete line segments (incomplete line segment AB, incomplete line segment CD, and incomplete line segment EF). Line segment AD is the completed line segment obtained after completing incomplete line segments AB and CD (corresponding to the completed line segment). It also includes incomplete line segment DF (corresponding to the third incomplete line segment). Line segment AD and incomplete line segment EF are adjacent. Connecting the two adjacent coordinates (point D and point E) of line segment AD and incomplete line segment EF, we obtain the completed line segment AF.

[0079] Optionally, during the process of completing incomplete line segments, the following method can also be used: obtain a set of incomplete line segments (at least two incomplete line segments) on the same straight line; obtain the coordinates of the two farthest endpoints in the set of incomplete line segments; and connect the coordinates of the two endpoints to obtain the completed line segment. For example... Figure 10 A set of incomplete line segments includes three incomplete line segments (incomplete line segment AB, incomplete line segment CD, and incomplete line segment EF). The coordinates of the two endpoints that are furthest apart are point A and point F. Connecting point A and point F results in line segment AF, which is the complete line segment.

[0080] In an optional embodiment, determining a target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set includes: performing the following steps on each line segment in the target line segment set, wherein each line segment is the current line segment during the following steps: obtaining the current line segment length of the current line segment; obtaining the current length threshold corresponding to the current line segment; and determining the current line segment as the target line segment if the current line segment length is greater than or equal to the current length threshold.

[0081] In this embodiment, in order to remove line segments that are too short in the initial line segments, the line segments in the target line segment set are filtered according to the length of the line segments and the length threshold. The line segments that meet the preset conditions are determined as target line segments, and the features of the extracted target line segments are used in subsequent feature analysis.

[0082] It should be noted that the length thresholds for line segments in different directions are different.

[0083] In an optional embodiment, obtaining the current length threshold corresponding to the current line segment includes: obtaining the first abscissa and first ordinate of the first endpoint of the current line segment, the second abscissa and second ordinate of the second endpoint, and the height and width of the image to be processed; obtaining the abscissa difference between the first abscissa and the second abscissa, and the ordinate difference between the first ordinate and the second ordinate; and determining the length threshold based on the magnitude of the abscissa difference and the ordinate difference, and the height and width of the image to be processed.

[0084] In this embodiment, since the length thresholds corresponding to line segments in different directions are different, the length threshold of the current line segment must be determined first when judging the length of the current line segment.

[0085] In an optional embodiment, determining the length threshold based on the magnitude of the difference between the horizontal and vertical coordinates, and the height and width of the image to be processed, includes: when the difference between the horizontal and vertical coordinates is greater than the difference between the vertical coordinates, obtaining the length threshold using the following formula:

[0086]

[0087] When the difference in the horizontal coordinates is less than or equal to the difference in the vertical coordinates, the length threshold is obtained using the following formula:

[0088]

[0089] Where ζ is a preset parameter, h is the height of the image to be processed, w is the width of the image to be processed, u1 is the first horizontal coordinate, v1 is the first vertical coordinate, u2 is the second horizontal coordinate, and v2 is the second vertical coordinate.

[0090] In this embodiment, when the line segment is horizontal or vertical, |u2-u1| >> |v2-v1| or |v2-v1| >> |u2-u1|. or

[0091] When the line segment is a diagonal line or It takes a value between 0 and 1, specifically when the line segment angle is 45 degrees.

[0092] In order to obtain a monotonic function for easier solution calculation, we... and When projected onto the exponential space, the target value or The range of values ​​is [1, e], and the function is monotonically increasing.

[0093] It should be noted that the preset parameter is the scaling factor of line segments in any direction, which was obtained experimentally.

[0094] In this embodiment, the length threshold of all line segments in all directions can be determined by determining only one scaling factor for the entire image using the above method. This eliminates the need to determine a scaling factor based on the different directions of the line segments, thus making the length thresholds of line segments in different directions different. This reduces the burden of obtaining multiple different scaling factors through experiments during the preprocessing stage and improves efficiency.

[0095] In an optional embodiment, obtaining the initial line segment set includes: performing bilateral filtering optimization on the image to be processed to obtain an optimized image; determining a target region in the optimized image based on gradient information in the optimized image, wherein the target region is a region where the gradient change is greater than or equal to a preset threshold; and extracting line segments in the target region to obtain the initial line segment set.

[0096] In this embodiment, for a grayscale image of the image to be processed, a bilateral filtering algorithm is used to eliminate noise in the image, making edge information more obvious, thus obtaining an optimized image. The gradient values ​​in the optimized image are determined based on the grayscale values ​​of the pixels; the gradient values ​​can effectively describe the magnitude of grayscale value changes in the optimized image. If the image to be processed is a color image, it is first converted to a grayscale image.

[0097] Based on the gradient value, the regions in the optimized image whose gradient change is greater than or equal to a preset threshold are identified as target regions. Line segments in the target regions are then extracted to obtain the initial set of line segments.

[0098] It should be noted that the LSD (line segment detector) algorithm is used to extract the target line segment in the target area.

[0099] Extracting line segments from the target region to obtain the initial set of line segments includes:

[0100] The gradient values ​​within the target region are pseudo-sorted. Starting from the point with the largest gradient (seed point), a search is performed within a threshold range. Points that meet the condition (gradient value greater than or equal to the threshold) are added to the target pixel set. For each target pixel set, a bounding rectangle is selected. By comparing the number of points contained in the rectangle with the number of points contained in the target pixel set, the most suitable bounding rectangle is obtained (the rectangle is truncated or retained). The NFA value (the number of false alarms) within the bounding rectangle is calculated. The size of the rectangle is changed so that the NFA value is less than the output threshold. The changed rectangle is added to the output, and the extracted line segments are contained within the rectangle. If the NFA value is greater than or equal to the output threshold, the bounding rectangle is truncated and retained again, and the NFA value is recalculated until the NFA value is less than the threshold. The changed rectangle is then output.

[0101] Obviously, the embodiments described above are only some embodiments of the present invention, and not all embodiments.

[0102] The present invention will be specifically described below with reference to embodiments:

[0103] Figure 11 This is a flowchart of an optional method for determining line segments in an image according to an embodiment of the present invention, such as... Figure 11 As shown, it includes the following steps:

[0104] Step S1101: Input a color image;

[0105] Step S1102: Convert the input color image to a grayscale image;

[0106] Step S1103: Optimize the grayscale image using a bilateral filtering algorithm to eliminate noise in the image and make the edge regions more obvious, so that the current gradient value can well describe the magnitude of the grayscale value change in the grayscale image.

[0107] Step S1104: Find the target region. The target region is determined based on the region with large gradient changes in the image. Compared with other regions lacking texture information, these regions have stronger gray-level gradient information and have the characteristics of continuity and clustering. By calculating and analyzing the gradient information in the gray-level image, the target region with obvious gradient changes can be obtained.

[0108] Step S1105: Determine if there are enough target areas. If so, proceed to step S1106; otherwise, proceed to step S1110.

[0109] Step S1106: Perform LSD algorithm detection on line segments in the target area;

[0110] Step S1107: Complete the detected line segments;

[0111] Step S1108: Filter line segments based on their length;

[0112] Step S1109: Output the target line segment;

[0113] Step S1110: Perform LSD algorithm detection on line segments in the target area;

[0114] Step S1111: Determine whether enough line segments have been detected. If so, proceed to step S1112; otherwise, proceed to step S1114.

[0115] Step S1112: Complete the detected line segments;

[0116] Step S1113: Filter line segments based on line segment length, and proceed to step S1109;

[0117] Step S1114: Request the next image and execute step 1101.

[0118] Figure 12 This is a schematic diagram illustrating the determination of a target area according to an embodiment of the present invention, such as... Figure 12 As shown, in scenarios employing line features, point feature extraction is often difficult or yields limited results because these scenarios have weak textures or relatively simple scene information. For such simple textured scenes, the detectable line features typically appear in clusters. For example, in an empty warehouse environment with walls lacking texture on all four sides, it's difficult to detect usable line features on these walls. Truly useful line features might be the boundaries between walls and the ground, and information about objects within the scene. Extracting the location information from this information is equivalent to extracting target regions in the image based on significant gradient changes. Compared to other regions lacking texture information, these regions have stronger grayscale gradient information and exhibit continuous, clustered characteristics. By calculating and analyzing the gradient information in the grayscale image, target regions with significant gradient changes can be easily obtained.

[0119] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0120] This embodiment also provides a device for determining line segments in an image. Figure 13 This is a structural block diagram of a device for determining line segments in an image according to an embodiment of the present invention, such as... Figure 13 As shown, the device includes:

[0121] The acquisition module 1302 is used to acquire an initial line segment set, wherein the initial line segment set includes normal line segments and incomplete line segments extracted from the image to be processed;

[0122] The completion module 1304 is used to complete the incomplete line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set includes the normal line segments and the completed line segments obtained after completing the incomplete line segments;

[0123] The determining module 1306 is used to determine the target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set.

[0124] In an optional embodiment, the device is further configured to acquire at least two initial line segments located on the same straight line from the initial line segment set, wherein the initial line segments include the normal line segments and the incomplete line segments; determine the initial line segments among the at least two initial line segments whose distance between adjacent line segments is less than or equal to a preset threshold as a group of incomplete line segments; and perform the completion processing on the group of incomplete line segments to obtain the completed line segments.

[0125] In an optional embodiment, the apparatus is further configured to determine a target coordinate system based on the processed image; and to perform the following steps on each initial line segment in the initial line segment set, wherein each initial line segment is a current initial line segment: determining a first plane and a second plane corresponding to the current initial line segment in the target coordinate system, wherein the first plane and the second plane are perpendicular; determining the intersection of the first plane and the second plane as the current intersection line; and determining at least two initial line segments in the initial line segment set located on the current intersection line as at least two initial line segments on the same straight line.

[0126] In an optional embodiment, the device is further configured to obtain at least two of the missing line segments located on the same straight line in the initial line segment set; and to perform the completion process on the at least two missing line segments to obtain the completed line segment.

[0127] In an optional embodiment, the device is further configured to perform the completion processing on a first and a second incomplete line segment of the at least two incomplete line segments through the following steps: obtaining two adjacent coordinates between the first and second incomplete line segments; connecting the two adjacent coordinates between the first and second incomplete line segments; and determining the connected first and second incomplete line segments as the line segments after the completion processing.

[0128] In an optional embodiment, the device is further configured to, when the at least two incomplete line segments include a third incomplete line segment, and the third incomplete line segment and the completed line segment are two adjacent line segments, obtain two adjacent coordinates between the completed line segment and the third incomplete line segment; and connect the two adjacent coordinates between the completed line segment and the third incomplete line segment to obtain the completed line segment.

[0129] In an optional embodiment, the device is further configured to perform the following steps on each line segment in the target line segment set, wherein each line segment is the current line segment when performing the following steps: obtaining the current line segment length of the current line segment; obtaining the current length threshold corresponding to the current line segment; and determining the current line segment as the target line segment if the current line segment length is greater than or equal to the current length threshold.

[0130] In an optional embodiment, the device is further configured to obtain the first abscissa and first ordinate of the first endpoint of the current line segment, the second abscissa and second ordinate of the second endpoint, and the height and width of the image to be processed; obtain the abscissa difference between the first abscissa and the second abscissa, and the ordinate difference between the first ordinate and the second ordinate; and determine the length threshold based on the magnitude of the abscissa difference and the ordinate difference, and the height and width of the image to be processed.

[0131] In an optional embodiment, the device is further configured to obtain the length threshold using the following formula when the difference in the horizontal coordinates is greater than the difference in the vertical coordinates:

[0132]

[0133] When the difference in the horizontal coordinates is less than or equal to the difference in the vertical coordinates, the length threshold is obtained using the following formula:

[0134]

[0135] Where ζ is a preset parameter, h is the height of the image to be processed, w is the width of the image to be processed, u1 is the first horizontal coordinate, v1 is the first vertical coordinate, u2 is the second horizontal coordinate, and v2 is the second vertical coordinate.

[0136] In an optional embodiment, the apparatus is further configured to perform bilateral filtering optimization on the image to be processed to obtain an optimized image; determine a target region in the optimized image based on gradient information in the optimized image, wherein the target region is a region where the gradient change is greater than or equal to a preset threshold; and extract line segments in the target region to obtain the initial set of line segments.

[0137] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0138] Embodiments of the present invention also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments when executed.

[0139] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0140] Embodiments of the present invention also provide an electronic device including a memory and a processor, the memory storing a computer program and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.

[0141] In one exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.

[0142] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0143] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.

[0144] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for determining line segments in an image, characterized in that, include: Obtain an initial set of line segments, wherein the initial set of line segments includes normal line segments and incomplete line segments extracted from the image to be processed; The incomplete line segments in the initial line segment set are completed to obtain a target line segment set, wherein the target line segment set includes the normal line segments and the completed line segments obtained after completing the incomplete line segments; Based on the length of each line segment in the target line segment set, the target line segments are determined from the target line segment set, including: For each line segment in the target line segment set, perform the following steps, where each line segment is the current line segment during the execution of the following steps: Get the current line segment length; Obtain the first x-coordinate and first y-coordinate of the first endpoint of the current line segment, the second x-coordinate and second y-coordinate of the second endpoint, and the height and width of the image to be processed; Obtain the difference between the first x-coordinate and the second x-coordinate, and the difference between the first y-coordinate and the second y-coordinate; When the difference in the horizontal coordinates is greater than the difference in the vertical coordinates, the length threshold of the current line segment is obtained using the following formula: min(h,w); When the difference in the horizontal coordinates is less than or equal to the difference in the vertical coordinates, the length threshold of the current line segment is obtained using the following formula: min(h,w); Where ζ is a preset parameter, h is the height of the image to be processed, w is the width of the image to be processed, u1 is the first horizontal coordinate, v1 is the first vertical coordinate, u2 is the second horizontal coordinate, and v2 is the second vertical coordinate. If the current line segment length is greater than or equal to the current length threshold, the current line segment is determined as the target line segment.

2. The method according to claim 1, characterized in that, The process of completing the incomplete line segments in the initial line segment set includes: Obtain at least two initial line segments located on the same straight line from the initial line segment set, wherein the initial line segments include the normal line segments and the incomplete line segments; The initial line segments in the at least two initial line segments whose distance between adjacent line segments is less than or equal to a preset threshold are determined as a group of the incomplete line segments; The missing line segments are filled by performing the filling process to obtain the filled line segments.

3. The method according to claim 2, characterized in that, Obtaining at least two initial line segments lying on the same straight line from the initial line segment set includes: Determine the target coordinate system based on the processed image; For each initial line segment in the set of initial line segments, the following steps are performed, wherein each initial line segment is the current initial line segment during the execution of the following steps: In the target coordinate system, determine the first plane and the second plane corresponding to the current initial line segment, wherein the first plane and the second plane are perpendicular to each other; The intersection line of the first plane and the second plane is determined as the current intersection line; At least two initial line segments in the initial line segment set that are located on the current intersection line are identified as at least two initial line segments on the same straight line.

4. The method according to claim 2, characterized in that, The incomplete line segment is filled by performing the filling process to obtain the filled line segment, including: Obtain at least two of the missing line segments that are on the same straight line from the initial set of line segments; The completion process is performed on the at least two missing line segments to obtain the completed line segments.

5. The method according to claim 2, characterized in that, The completion process is performed on the at least two missing line segments to obtain the completed line segment, including: The completion process is performed on the first and second missing line segments of the at least two missing line segments through the following steps, wherein the first and second missing line segments are two adjacent line segments: Obtain the coordinates of two adjacent segments between the first incomplete line segment and the second incomplete line segment; Connect the two adjacent coordinates between the first and second incomplete line segments, and determine the first and second incomplete line segments after the connection as the line segments after the completion process.

6. The method according to claim 5, characterized in that, The method further includes: If the at least two missing line segments include a third missing line segment, and the third missing line segment and the completed line segment are two adjacent line segments, then obtain two adjacent coordinates between the completed line segment and the third missing line segment. The two adjacent coordinates between the completed line segment and the third incomplete line segment are connected to obtain the completed line segment.

7. The method according to claim 1, characterized in that, The process of obtaining the initial set of line segments includes: The image to be processed is optimized by bilateral filtering to obtain an optimized image; The target region in the optimized image is determined based on the gradient information in the optimized image, wherein the target region is a region where the gradient change is greater than or equal to a preset threshold. Extract the line segments from the target region to obtain the initial set of line segments.

8. A device for determining line segments in an image, characterized in that, include: An acquisition module is used to acquire an initial set of line segments, wherein the initial set of line segments includes normal line segments and incomplete line segments extracted from the image to be processed; The completion module is used to complete the incomplete line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set includes the normal line segments and the completed line segments obtained after completing the incomplete line segments; The determining module is used to determine the target line segment in the target line segment set based on the line segment length of each line segment in the target line segment set; The device is further configured to perform the following steps on each line segment in the target line segment set, wherein each line segment is the current line segment when performing the following steps: Get the current line segment length; Obtain the first x-coordinate and first y-coordinate of the first endpoint of the current line segment, the second x-coordinate and second y-coordinate of the second endpoint, and the height and width of the image to be processed; Obtain the difference between the first x-coordinate and the second x-coordinate, and the difference between the first y-coordinate and the second y-coordinate; When the difference in the horizontal coordinates is greater than the difference in the vertical coordinates, the length threshold of the current line segment is obtained using the following formula: min(h,w); When the difference in the horizontal coordinates is less than or equal to the difference in the vertical coordinates, the length threshold of the current line segment is obtained using the following formula: min(h,w); Where ζ is a preset parameter, h is the height of the image to be processed, w is the width of the image to be processed, u1 is the first horizontal coordinate, v1 is the first vertical coordinate, u2 is the second horizontal coordinate, and v2 is the second vertical coordinate. If the current line segment length is greater than or equal to the current length threshold, the current line segment is determined as the target line segment.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 7.