CN115564714A - Method and device for determining line segments in image, storage medium and electronic device - Google Patents
Method and device for determining line segments in image, storage medium and electronic device Download PDFInfo
- Publication number
- CN115564714A CN115564714A CN202211096766.5A CN202211096766A CN115564714A CN 115564714 A CN115564714 A CN 115564714A CN 202211096766 A CN202211096766 A CN 202211096766A CN 115564714 A CN115564714 A CN 115564714A
- Authority
- CN
- China
- Prior art keywords
- line segment
- line
- incomplete
- segments
- initial
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/60—Analysis of geometric attributes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/40—Extraction of image or video features
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20024—Filtering details
- G06T2207/20028—Bilateral filtering
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Quality & Reliability (AREA)
- Geometry (AREA)
- Multimedia (AREA)
- Image Analysis (AREA)
Abstract
The embodiment of the invention provides a method and a device for determining line segments in an image, a storage medium and an electronic device, wherein the method comprises the following steps: acquiring an initial line segment set, wherein the initial line segment set comprises a normal line segment and a incomplete line segment extracted from an 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, wherein the target line segment set comprises normal line segments and completion line segments obtained after completion processing is performed on the incomplete line segments; and determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set. The invention solves the problem of low line segment extraction efficiency in the related technology.
Description
Technical Field
The embodiment of the invention relates to the technical field of image processing, in particular to a method and a device for determining line segments in an image, a storage medium and an electronic device.
Background
In recent years, with the rapid development of information technology, feature extraction in images becomes the first and most important link for researching visual odometry, and how to efficiently extract feature information contained in images and use the feature information for subsequent positioning and navigation operations becomes a great research hotspot. At present, image features mainly used are point features, and researchers obtain information such as edges and angular points in the images according to the point features in the images. However, for some specific scenes, the scene is relatively spacious and the texture is relatively single, and the required number of feature points cannot be obtained, so extracting and using the line segment features becomes a method for solving the problem. The line features can still provide stable and certain amount of feature information in some scenes with sparse textures. In the prior art, a method for extracting features in an image searches in a whole image, extracts pixel points meeting conditions, generates line segment output, may cause discontinuity of some line segments due to angles, pixels and the like of the image in the extraction process to cause line segment loss, and has overlarge search range in the whole image, large calculation amount and limited line segment extraction speed. Therefore, the prior art has the problem of low line segment extraction efficiency.
Aiming at the problem of low line segment extraction efficiency in the related technology, no effective solution is provided at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for determining a line segment in an image, a storage medium and an electronic device, which are used for at least solving the problem of low line segment extraction efficiency in the related technology.
According to an embodiment of the present invention, there is provided a method for determining a line segment in an image, including: acquiring an initial line segment set, wherein the initial line segment set comprises a normal line segment and a incomplete line segment extracted from an 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, wherein the target line segment set comprises the normal line segments and a completion line segment obtained after completion processing is performed on the incomplete line segments; and determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set.
In an exemplary embodiment, the completing the incomplete line segment in the initial line segment set includes: acquiring at least two initial line segments which are positioned on the same straight line in the initial line segment set, wherein the initial line segments comprise the normal line segments and the incomplete line segments; determining the initial line segments with the distance between adjacent line segments smaller than or equal to a preset threshold value in the at least two initial line segments as a group of incomplete line segments; and performing the completion processing on the group of incomplete line segments to obtain the completion line segments.
In an exemplary embodiment, obtaining at least two initial line segments of the initial line segment set, which are located on the same straight line, includes: determining a target coordinate system according to the processed image; executing 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 when the following steps are executed: 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 in a vertical relation; determining the intersection line of the first plane and the second plane as a current intersection line; and determining at least two initial line segments of the initial line segment set, which are positioned on the current intersection line, as at least two initial line segments on the same straight line.
In an exemplary embodiment, the completing the incomplete line segment to obtain the completed line segment includes: acquiring at least two incomplete line segments which are positioned on the same straight line in the initial line segment set; and performing the completion processing on the at least two incomplete line segments to obtain the completion line segment.
In an exemplary embodiment, the completing the at least two incomplete line segments to obtain the completed line segment includes: performing the completion processing on a first segment and a second segment of the at least two segments by the following steps, wherein the first segment and the second segment are two adjacent segments: acquiring two adjacent coordinates between the first incomplete line segment and the second incomplete line segment; and connecting two adjacent coordinates between the first incomplete line segment and the second incomplete line segment, and determining the connected first incomplete line segment and the second incomplete line segment as the line segments subjected to completion processing.
In one exemplary embodiment, the method further comprises: under the condition that the at least two incomplete line segments further comprise a third incomplete line segment and the supplemented line segment are two adjacent line segments, two adjacent coordinates between the supplemented line segment and the third incomplete line segment are obtained; and connecting two adjacent coordinates between the supplemented line segment and the third incomplete line segment to obtain the supplemented line segment.
In an exemplary embodiment, determining a target line segment in the target line segment set according to the segment length of each line segment in the target line segment set includes: executing the following steps on each line segment in the target line segment set, wherein each line segment is a current line segment when the following steps are executed: acquiring the length of the current line segment; acquiring a current length threshold corresponding to the current line segment; and determining the current line segment as a target line segment when the length of the current line segment is greater than or equal to the current length threshold.
In an exemplary embodiment, obtaining the current length threshold corresponding to the current line segment includes: acquiring a first abscissa and a first ordinate of a first endpoint of the current line segment, a second abscissa and a second ordinate of a second endpoint, and the height and width of the image to be processed; acquiring a horizontal coordinate difference between the first horizontal coordinate and the second horizontal coordinate and an ordinate difference between the first ordinate and the second ordinate; and determining the length threshold value according to the height and the width of the image to be processed according to the horizontal coordinate difference and the vertical coordinate difference.
In an exemplary embodiment, the determining the length threshold according to the height and the width of the image to be processed according to the size of the abscissa difference and the ordinate difference includes: in the case where the abscissa difference is larger than the ordinate difference, the length threshold is obtained by the following formula:
in a case where the abscissa difference is less than or equal to the ordinate difference, the length threshold is obtained by the following formula:
zeta 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 abscissa, v1 is the first ordinate, u2 is the second abscissa, and v2 is the second ordinate.
In an exemplary embodiment, the obtaining the initial set of line segments includes: carrying out bilateral filtering optimization on the image to be processed to obtain an optimized image; determining a target region in the optimized image according to the gradient information in the optimized image, wherein the target region is a region with gradient quantity variation larger than or equal to a preset threshold value; and extracting the line segments in the target area to obtain the initial line segment set.
According to another embodiment of the present invention, there is also provided an apparatus for determining a line segment in an image, including: the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an initial line segment set, and the initial line segment set comprises a normal line segment and a incomplete line segment which are extracted from an image to be processed;
a completion module, configured to perform completion processing on the incomplete line segment in the initial line segment set to obtain a target line segment set, where the target line segment set includes the normal line segment and a completion line segment obtained after performing completion processing on the incomplete line segment;
and the determining module is used for determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set.
According to a further embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.
According to yet another embodiment of the present invention, there is also provided an electronic device, comprising a memory in which a computer program is stored and a processor configured to run the computer program to perform the steps of any of the method embodiments described above.
According to the method, an initial line segment set is obtained, wherein the initial line segment set comprises a normal line segment and a incomplete line segment extracted from an 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, wherein the target line segment set comprises normal line segments and completion line segments obtained after completion processing is performed on the incomplete line segments; and determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set. Therefore, the problem of low line segment extraction efficiency in the related technology is solved, and the effect of improving the line segment efficiency is achieved.
Drawings
Fig. 1 is a block diagram of a hardware structure of a mobile terminal of a method for determining a line segment in an image according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method for determining line segments in an image according to an embodiment of the invention;
FIG. 3 is an alternative line segment extraction diagram according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a set of target line segments resulting from optional line segment completion, according to an embodiment of the invention;
FIG. 5 is a first diagram illustrating alternative collinear initial line segments, in accordance with an embodiment of the present invention;
FIG. 6 is a diagram illustrating an alternative collinear initial line segment according to an embodiment of the present invention;
FIG. 7 is a third diagram of an alternative collinear initial line segment in accordance with an embodiment of the present invention;
FIG. 8 is a schematic illustration of a vertical plane and its intersection of an alternative Prock coordinate system in accordance with an embodiment of the present invention;
FIG. 9 is a first schematic diagram of an alternative completion of a stub segment in accordance with an embodiment of the present invention;
FIG. 10 is a second schematic diagram of an alternative completion of a remnant line segment in accordance with an embodiment of the present invention;
FIG. 11 is a flow diagram of an alternative method for determining line segments in an image, in accordance with embodiments of the present invention;
FIG. 12 is a schematic illustration of determining a target area according to an embodiment of the invention;
fig. 13 is a block diagram of a configuration of a determination apparatus of a line segment in an image according to an embodiment of the present invention.
Detailed Description
Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings in conjunction with the embodiments.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The method embodiments provided in the embodiments of the present application may be executed in a mobile terminal, a computer terminal, or a similar computing device. Taking the mobile terminal as an example, fig. 1 is a block diagram of a hardware structure of the mobile terminal of the method for determining a line segment in an image according to the embodiment of the present invention. As shown in fig. 1, the mobile terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), and a memory 104 for storing data, wherein the mobile terminal may further include a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration, and does not limit the structure of the mobile terminal. For example, the mobile terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program and a module of an application software, such as a computer program corresponding to the method for determining a line segment in an image in an embodiment of the present invention, and the processor 102 executes the computer program stored in the memory 104 to execute various functional applications and data processing, i.e., to implement the method described above. 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 examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a Network adapter (NIC), which can be connected to other Network devices through a base station so as to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In this embodiment, a method for determining a line segment in an image is provided, and fig. 2 is a flowchart of the method for determining a line segment in an image according to the embodiment of the present invention, as shown in fig. 2, the flowchart includes the following steps:
step S202, acquiring an initial line segment set, wherein the initial line segment set comprises a normal line segment and a incomplete line segment extracted from an image to be processed;
the method comprises the steps that an initial line segment is extracted from an image to be processed, in the process of extracting the line segment, the line segment is divided into at least two line segments which are the incomplete line segments extracted from the image to be processed and are discontinuous, and the extracted continuous line segment is the normal line segment extracted from the image to be processed.
Fig. 3 is a schematic diagram of optional line segment extraction according to an embodiment of the present invention, and as shown in fig. 3, the line segments under extraction include a line segment AB, a line segment CD and a line segment EF, where the line segment AB is a continuous line segment, that is, a normal line segment in the initial line segment set, and the line segments CD and EF are two line segments extracted after a break occurs in one continuous line segment, and correspond to a segment that is incomplete in the initial line segment set.
Step S204, performing completion processing on the incomplete line segments in the initial line segment set to obtain a target line segment set, wherein the target line segment set comprises the normal line segments and the completion line segments obtained after completion processing is performed on the incomplete line segments;
in this embodiment, at least two incomplete line segments extracted from one continuous line segment inevitably lose some features, so that an error may occur during feature analysis according to the extracted line segments subsequently, for example, when matching is performed on the same line segment in two images to be processed at two different viewing angles, since the line segment in one image to be processed is divided into a plurality of discontinuous incomplete line segments, the line segment may not be matched with a corresponding complete line segment in the image to be processed at another viewing angle, and the accuracy of line segment matching may be affected by the incomplete problem of the detected line segment. Therefore, in order to reduce the influence of the missing features, the incomplete line segments in the initial line segment set are supplemented, and some features are added through the supplementation of the incomplete line segments.
Figure 4 is a schematic diagram of a target set of line segments resulting from an optional line segment completion according to an embodiment of the present invention, as shown in figure 4 of the drawings, the stub segments in FIG. 3: the line segment CF in fig. 4 is obtained after the line segments CD and EF are completed, that is, the line segment CF is a completed line segment obtained after completion processing, the line segment AB is a normal line segment, and the completed line segment and the normal line segment obtained after completion processing are recorded in the target line segment set without performing completion processing. The target line segment set obtained after completion processing in fig. 4 includes a line segment AB and a line segment CF.
Step S206, determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set.
In this embodiment, some too short segments only contain little segment information, and these too short segments have little effect on subsequent segment feature analysis, but too short segments may exist in a large number in the target segment set, so that the computation amount of segment feature analysis is increased, but the influence on the analysis result is small, and therefore, segments meeting the segment length requirement are screened out according to the segment length of each segment in the target segment set, thereby reducing the computation amount of subsequent segment feature analysis, and improving the efficiency of segment feature analysis.
Through the steps, the incomplete line segments extracted from the image to be processed are subjected to completion processing to obtain a target line segment set, the target line segments are determined according to the length of each line segment in the target line segment set, missing parts on continuous line segments caused by the problem of shielding or shooting angles are incomplete, the extracted line segment features are richer, the extracted line segments are screened, short line segments do not participate in subsequent line feature analysis, the efficiency of line segment feature analysis is improved, and the problem of low line segment extraction efficiency in the related technology is solved.
In an optional embodiment, performing completion processing on the incomplete line segment in the initial line segment set includes: acquiring at least two initial line segments which are positioned on the same straight line in the initial line segment set, wherein the initial line segments comprise the normal line segments and the incomplete line segments; determining the initial line segment with the distance between adjacent line segments of the at least two initial line segments smaller than or equal to a preset threshold value as the incomplete line segment; and performing the completion processing on the incomplete line segment to obtain the completion line segment.
In this embodiment, in the process of completing the incomplete line segment, it is first determined which of the extracted initial line segments are incomplete line segments and which of the extracted initial line segments are normal line segments.
Firstly, the incomplete line segment is generated by a continuous line segment, therefore, the line segments needing to be completed are required to be positioned on the same straight line, therefore, in the completing process, all initial line segments positioned on the same straight line are obtained, including at least two initial line segments, it is required to be explained that under the condition that only one initial line segment is positioned on one straight line, the initial line segment is explained to be a normal line segment, the completing process is not required, and therefore, two or more initial line segments are only obtained on one straight line.
In at least two initial line segments on the same straight line, if the distance between two adjacent initial line segments is smaller than or equal to a threshold value, the two initial line segments are two incomplete line segments obtained by the interruption of one continuous line segment, and the completion of the incomplete parts in the incomplete line segments is to perform the completion processing on the incomplete line segments to obtain the completed line segments.
The initial line segments on the same straight line include multiple cases, and the following describes, by way of example, the initial line segments in which the distance between adjacent line segments in the at least two initial line segments is less than or equal to a preset threshold value are determined as a group of the incomplete line segments.
Fig. 5 is a first schematic diagram of optional initial line segments on the same straight line according to an embodiment of the present invention, as shown in fig. 5, in a case that the initial line segments on the same straight line only include two initial line segments (line segment AB and line segment CD), the line segment AB and the line segment CD are adjacent to each other, a distance between the line segment AB and the line segment CD is a distance between a point B and a point C, and in a case that the distance between the point B and the point C is less than or equal to a preset threshold, the line segment AB and the line segment CD are determined as a group of incomplete line segments to perform completion processing.
Fig. 6 is a schematic diagram of an optional initial line segment on the same straight line, where as shown in fig. 6, when the initial line segment on the same straight line includes three initial line segments (line segment AB, line segment CD, and line segment EF), the line segment AB is adjacent to the line segment CD, the line segment CD is adjacent to the line segment EF, a distance between the line segment AB and the line segment CD is a distance between a point B and a point C, and a distance between the line segment CD and the line segment EF is a distance between a point D and a point E.
Determining the line segment AB, the line segment CD and the line segment EF as a group of incomplete line segments under the condition that the distance between the line segment AB and the line segment CD and the distance between the line segment CD and the line segment EF are both smaller than or equal to a preset threshold value; and under the conditions that the distance between the line segment AB and the line segment CD is smaller than or equal to a preset threshold value and the distance between the line segment CD and the line segment EF is larger than the preset threshold value, determining the line segment AB and the line segment CD as a group of incomplete line segments and determining the line segment DF as a normal line segment.
Fig. 7 is a schematic diagram of an optional third initial line segment on the same straight line according to an embodiment of the present invention, as shown in fig. 7, the initial line segment on the same straight line includes four initial line segments (line segment AB, line segment CD, line segment EF, and line segment GH), the line segment AB is adjacent to the line segment CD, the line segment CD is adjacent to the line segment EF, the line segment EF is adjacent to the line segment GH, a distance between the line segment AB and the line segment CD is a distance between a point B and a point C, a distance between the line segment CD and the line segment EF is a distance between a point D and a point E, and a distance between the line segment EF and the line segment GH is a distance between a point F and a point G.
Assuming that the distance between the line segment AB and the line segment CD in fig. 7 is smaller than or equal to the preset threshold, the distance between the line segment CD and the line segment EF is greater than the preset threshold, and the distance between the line segment EF and the line segment GH is smaller than or equal to the preset threshold, the line segment AB and the line segment CD are determined as a set of incomplete line segments, and the line segment EF and the line segment GH are determined as another set of incomplete line segments.
In an optional embodiment, obtaining at least two initial line segments of the initial line segment set, which are located on the same straight line, includes: determining a target coordinate system according to the image to be processed; executing the following steps for each initial line segment in the initial line segment set, wherein each initial line segment is a current initial line segment when the following steps are executed: 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 in a vertical relation; determining the intersection line of the first plane and the second plane as a current intersection line; and determining at least two initial line segments of the initial line segment set, which are positioned on the current intersection line, as at least two initial line segments on the same straight line.
In this embodiment, when obtaining at least two initial line segments located on the same straight line, it is first determined which line segments are located on the same straight line in the initial line segment set, and it is determined for each initial line segment in the initial line segment set that a wireless segment is located on the same straight line as the initial line segment.
The target coordinate system may be a Procko coordinate system, as the target coordinate system may be defined by a line and a direction perpendicular to the line. Meanwhile, for any straight line, the two intersected planes can jointly determine, and the intersecting line of the two planes is the only straight line, so that the conclusion that if the two intersected planes are placed in the Prock coordinate system and kept perpendicular to each other, the intersecting line of the two intersected planes is the only straight line in the Prock coordinate system can be deduced.
The horizontal plane in the prock coordinate system is tiled in the image to be processed, that is, all original line segments in the image to be processed are located in the same plane (i.e., horizontal plane) in the prock coordinate system.
Two mutually perpendicular planes (a first plane and a second plane) corresponding to a current original line segment are determined in a Pluecker coordinate system, and the current original line segment is included in the first plane and the second plane.
Specifically, the first plane may be a horizontal plane in the purroc coordinate system, and the second plane may be a vertical plane perpendicular to the horizontal plane in the purroc coordinate system. The intersection line defined by the first plane and the second plane is unique, and all initial line segments on the intersection line are initial line segments on the same straight line.
Fig. 8 is a schematic diagram of a vertical plane and an intersection thereof under an alternative purck coordinate system according to an embodiment of the present invention, and as shown in fig. 8, a first plane and a second plane corresponding to a line segment AB are determined, the intersection of the first plane and the second plane is a straight line l, the first plane is a horizontal plane, the second plane is a vertical plane, a line segment CD and a line segment EF are located on the straight line l, a line segment GH is not located on the straight line l, and the line segment AB, the line segment CD and the line segment EF are at least two initial line segments located on the same straight line.
It should be noted that the advantage of using the purck coordinate system is that the common intersection (parallel, intersecting, collinear, etc.) problem can be handled with a few simple operations. Division operation is removed in actual programming, programming complexity is reduced, and efficiency is improved.
In an optional embodiment, performing the completion processing on the incomplete line segment to obtain the completion line segment includes: acquiring at least two incomplete line segments which are positioned on the same straight line in the initial line segment set; and performing the completion processing on the at least two incomplete line segments to obtain the completion line segment.
In this embodiment, when the incomplete line segment is subjected to the completion processing, at least two incomplete line segments located on the same straight line are acquired to be subjected to the completion processing, and the initial line segment identified as the normal line segment on the same straight line is not subjected to the completion processing.
In an optional embodiment, the completing the at least two incomplete line segments to obtain the completed line segment includes: performing the completion processing on a first segment and a second segment of the at least two segments by the following steps, wherein the first segment and the second segment are two adjacent segments: acquiring two adjacent coordinates between the first incomplete line segment and the second incomplete line segment; and connecting two adjacent coordinates between the first incomplete line segment and the second incomplete line segment, and determining the connected first incomplete line segment and the second incomplete line segment as the line segments subjected to the completion processing.
In this embodiment, a group of segment defects located on a straight line is obtained, and the segment defects between two adjacent segment defects are filled. When the incomplete filling between two adjacent incomplete line segments is completed, two adjacent coordinates between the two incomplete line segments are connected, and the two incomplete line segments are filled into a continuous line segment.
Fig. 9 is a schematic diagram of optional completion of the incomplete line segment according to the first embodiment of the present invention, and corresponding to fig. 5, the incomplete line segment AB and the incomplete line segment CD in fig. 5 are completed, that is, two adjacent coordinates between the incomplete line segment AB and the incomplete line segment CD, that is, a connection point B and a point C, are connected, and the incomplete line segment AB and the incomplete line segment CD are completed to obtain a continuous line segment AD, that is, the line segment AD after completion processing shown in fig. 9 is obtained.
In an optional embodiment, the method further comprises: under the condition that the at least two incomplete line segments further comprise a third incomplete line segment and the supplemented line segment are two adjacent line segments, two adjacent coordinates between the supplemented line segment and the third incomplete line segment are obtained; and connecting two adjacent coordinates between the supplemented line segment and the third incomplete line segment to obtain the supplemented line segment.
In this embodiment, when the number of the incomplete line segments on the same straight line is greater than two, two adjacent incomplete line segments are subjected to completion processing, and the line segment subjected to completion processing is subjected to completion processing with other incomplete line segments adjacent to the line segment subjected to completion processing.
Fig. 10 is a schematic diagram of optional incomplete line segment completion according to an embodiment of the present invention, where as shown in fig. 10, the at least two incomplete line segments on the same straight line include three incomplete line segments (an incomplete line segment AB, an incomplete line segment CD, and an incomplete line segment EF), the line segment AD is a completion-processed line segment (corresponding to the completion-processed line segment) obtained after completion of the incomplete line segment AB and the incomplete line segment CD, and further includes an incomplete line segment DF (corresponding to a third incomplete line segment), the line segment AD is adjacent to the incomplete line segment EF, and two coordinates (point D and point E) of the line segment AD adjacent to the incomplete line segment EF are connected to obtain a completion line segment AF.
Optionally, the following method may also be used in the process of completing the incomplete line segments, to obtain a group of incomplete line segments (at least two incomplete line segments) on the same straight line, to obtain coordinates of two end points farthest from each other in the group of incomplete line segments, and to connect the coordinates of the two end points to form a line segment after completing, for example, in fig. 10, the group of incomplete line segments includes three incomplete line segments (an incomplete line segment AB, an incomplete line segment CD, and an incomplete line segment EF), the coordinates of the two end points farthest from each other are a point a and a point F, and the connection point a and the point F are connected to form a line segment AF, which is the complete line segment.
In an optional embodiment, determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set includes: executing the following steps for each line segment in the target line segment set, wherein each line segment is a current line segment when the following steps are executed: acquiring the length of the current line segment; acquiring a current length threshold corresponding to the current line segment; and determining the current line segment as a target line segment when the length of the current line segment is greater than or equal to the current length threshold.
In this embodiment, in order to remove a line segment with an excessively short length in the initial line segment, the line segments in the target line segment set are screened according to the length of the line segment in combination with a length threshold, the line segment meeting a preset condition is determined as the target line segment, and the extracted features of the target line segment are used in subsequent feature analysis.
It should be noted that the length thresholds corresponding to the line segments in different directions are different.
In an optional embodiment, obtaining the current length threshold corresponding to the current line segment includes: acquiring a first abscissa and a first ordinate of a first endpoint of the current line segment, a second abscissa and a second ordinate of a second endpoint, and the height and width of the image to be processed; acquiring an abscissa difference between the first abscissa and the second abscissa, and an ordinate difference between the first ordinate and the second ordinate; and determining the length threshold value according to the height and the width of the image to be processed according to the horizontal coordinate difference and the vertical coordinate difference.
In this embodiment, since the length thresholds corresponding to the line segments in different directions are different, when the length of the current line segment is determined, the length threshold of the current line segment needs to be determined first.
In an optional embodiment, the determining the length threshold according to the horizontal coordinate difference and the vertical coordinate difference and the height and the width of the image to be processed includes: in a case where the abscissa difference is larger than the ordinate difference, the length threshold is obtained by the following equation:
in a case where the abscissa difference is less than or equal to the ordinate difference, the length threshold is obtained by the following formula:
zeta 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 abscissa, v1 is the first ordinate, u2 is the second abscissa, and v2 is the second ordinate.
In the present embodiment, | u when the line segment is horizontal or vertical 2 -u 1 |>>|v 2 -v 1 L or v 2 -v 1 |>>|u 2 -u 1 At this time |Or
When the line segment is a diagonal line,orTaking values of 0 to 1, in particular, when the line angle is 45 degrees, in this case
In order to obtain a monotonous function and facilitate the solution operation, the method comprisesAndtarget value when projected into the exponential spaceOrValue range [1, e ]]The function is monotonically increasing.
It should be noted that the preset parameter is a scaling factor of a line segment in any direction, and the scaling factor is obtained through experiments.
In the embodiment, the length thresholds of the line segments in all directions can be determined only by determining one proportionality coefficient through the method, and the length thresholds of the line segments in different directions can be different without determining one proportionality coefficient according to different directions of the line segments, so that the burden of obtaining a plurality of different proportionality coefficients through experiments in the process of advanced treatment is reduced, and the efficiency is improved.
In an optional embodiment, the obtaining the initial line segment set includes: carrying out bilateral filtering optimization on the image to be processed to obtain an optimized image; determining a target region in the optimized image according to the gradient information in the optimized image, wherein the target region is a region with gradient quantity variation larger than or equal to a preset threshold value; and extracting the line segments in the target area to obtain the initial line segment set.
In this embodiment, a bilateral filtering algorithm is used for a gray-scale image of an image to be processed, so that noise in the image is eliminated, edge information is more obvious, and an optimized image is obtained. And determining a gradient value in the optimized image according to the gray value of the pixel in the optimized image, wherein the gradient value can well describe the change of the gray value in the optimized image. If the image to be processed is a color image, the color image is converted into a gray scale image.
Determining a region with gradient variation larger than or equal to a preset threshold in the optimized image according to the gradient value, determining the region as a target region, and extracting line segments in the target region to obtain the initial line segment set.
It should be noted that, when extracting a target line segment in the target region, an LSD (line segment detector) algorithm is used to extract the target line segment in the target region.
Extracting the line segments in the target area, and obtaining the initial line segment set comprises:
pseudo-sorting is carried out on gradient values in a target area, searching in a threshold range is carried out from a point (seed point) with The maximum gradient, points (The gradient value is larger than or equal to The threshold) meeting conditions are added into a target pixel point set, an external rectangle is selected for each target pixel point set, the most suitable external rectangle (The rectangle is cut off or reserved) is obtained by judging The number of points contained in The rectangle and The target pixel point set, the NFA value (The number of false alarm times of The rectangle frame in The external rectangle frame) is calculated, the size of The rectangle is changed to enable The NFA value to be smaller than an output threshold value, the changed rectangle frame is added and output, the extracted line segment is contained in The rectangle frame, if The NFA value is larger than or equal to The output threshold value, cutting off and reserving of The external rectangle frame are carried out again, the NFA value is recalculated until The NFA value is smaller than The threshold value, and The changed rectangle frame is output.
It is to be understood that the above-described embodiments are only a few, but not all, embodiments of the present invention.
The present invention will be described in detail with reference to the following examples:
fig. 11 is a flowchart of an alternative method for determining line segments in an image according to an embodiment of the present invention, as shown in fig. 11, including the following steps:
step S1101, inputting a color image;
step S1102, converting the input color image into a grayscale;
step S1103, carrying out bilateral filtering algorithm optimization on the gray level image, eliminating noise points in the image, enabling the edge area to be more obvious, and enabling the current gradient value to well describe the change size of the gray level value in the gray level image;
step S1104, searching a target area, and determining the area with large gradient change in the image as the target area; compared with other areas lacking texture information, the areas have stronger gray gradient information and have the characteristics of continuity and clustering, and target areas with obvious gradient changes can be obtained by calculating and analyzing the gradient information in the gray map;
step S1105, judging whether there is enough target area, if there is enough target area, executing step S1106; if not, go to step S1110;
step S1106, carrying out LSD algorithm detection line segment in the target area;
step S1107, completing the detected line segment;
step S1108, screening line segments based on the length of the line segments;
step S1109, outputting a target line segment;
step S1110, carrying out LSD algorithm detection line segment in the target area;
step S1111, judging whether enough line segments are detected, if so, executing step S1112; if not, go to step S1114;
step S1112 of completing the detected line segment;
step S1113, screening line segments based on the length of the line segments, and executing step S1109;
in step S1114, a next image is requested, and step 1101 is executed.
Fig. 12 is a schematic diagram of determining a target area according to an embodiment of the present invention, as shown in fig. 12, in a scene using line features, there are cases where extraction of point features is difficult or extraction amount is small, because such a scene has a weak texture or scene information is single. For such texture-simple scenes, the line features that can be detected are typically clique occurrences. For example: in an open warehouse environment, four sides are simply walls lacking texture, and it is difficult to detect the available line characteristics on these walls. A truly useful line feature might be the intersection of a wall with the ground, as well as some object information present in the scene. Extracting the positional information from these pieces of information corresponds to extracting a target region in the image that has a large change due to a gradient. Compared with other areas lacking texture information, the areas have stronger gray gradient information and have the characteristics of continuity and clustering, and the target area with obvious gradient change can be easily obtained by calculating and analyzing the gradient information in the gray map.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention or portions thereof contributing to the prior art may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (which may be a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
There is also provided in this embodiment a device for determining a line segment in an image, and fig. 13 is a block diagram of a structure of the device for determining a line segment in an image according to an embodiment of the present invention, as shown in fig. 13, the device includes:
an obtaining module 1302, configured to obtain an initial line segment set, where the initial line segment set includes a normal line segment and a incomplete line segment extracted from an image to be processed;
a completion module 1304, configured to perform completion processing on the incomplete line segment in the initial line segment set to obtain a target line segment set, where the target line segment set includes the normal line segment and a completion line segment obtained after performing completion processing on the incomplete line segment;
the determining module 1306 is configured to determine a target line segment in the target line segment set according to a line segment length of each line segment in the target line segment set.
In an optional embodiment, the apparatus is further configured to acquire at least two initial line segments located on the same straight line in the initial line segment set, where the initial line segments include the normal line segment and the incomplete line segment; determining the initial line segments with the distance between adjacent line segments smaller than or equal to a preset threshold value in the at least two initial line segments as a group of incomplete line segments; and performing the completion processing on the group of incomplete line segments to obtain the completion line segments.
In an alternative embodiment, the apparatus is further configured to determine a target coordinate system from the processed image; executing 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 when the following steps are executed: 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 in a vertical relation; determining the intersection line of the first plane and the second plane as a current intersection line; and determining at least two initial line segments of the initial line segment set, which are positioned on the current intersection line, as at least two initial line segments on the same straight line.
In an optional embodiment, the apparatus is further configured to acquire at least two of the incomplete line segments located on the same straight line in the initial line segment set; and performing the completion processing on the at least two incomplete line segments to obtain the completion line segment.
In an optional embodiment, the apparatus is further configured to perform the completion processing on a first segment and a second segment of the at least two segment by: acquiring two adjacent coordinates between the first incomplete line segment and the second incomplete line segment; and connecting two adjacent coordinates between the first incomplete line segment and the second incomplete line segment, and determining the connected first incomplete line segment and the second incomplete line segment as the line segments subjected to the completion processing.
In an optional embodiment, the apparatus is further configured to, when the at least two incomplete line segments further include a third incomplete line segment, and the third incomplete line segment and the supplemented line segment are two adjacent line segments, obtain two adjacent coordinates between the supplemented line segment and the third incomplete line segment; and connecting two adjacent coordinates between the supplemented line segment and the third incomplete line segment to obtain the supplemented line segment.
In an optional embodiment, the apparatus is further configured to perform the following steps for each line segment in the target set of line segments, where the following steps are performed, the each line segment being a current line segment: acquiring the length of the current line segment; acquiring a current length threshold corresponding to the current line segment; and determining the current line segment as a target line segment when the length of the current line segment is greater than or equal to the current length threshold.
In an optional embodiment, the apparatus is further configured to obtain a first abscissa and a first ordinate of a first endpoint of the current line segment, a second abscissa and a second ordinate of a second endpoint, and a height and a width of the image to be processed; acquiring a horizontal coordinate difference between the first horizontal coordinate and the second horizontal coordinate and an ordinate difference between the first ordinate and the second ordinate; and determining the length threshold value according to the height and the width of the image to be processed according to the horizontal coordinate difference and the vertical coordinate difference.
In an optional embodiment, the apparatus is further configured to obtain the length threshold value by the following formula if the abscissa difference is larger than the ordinate difference:
in a case where the abscissa difference is less than or equal to the ordinate difference, the length threshold is obtained by the following formula:
where ζ is a preset parameter, h is a height of the image to be processed, w is a width of the image to be processed, u1 is the first abscissa, v1 is the first ordinate, u2 is the second abscissa, and v2 is the second ordinate.
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; determining a target region in the optimized image according to the gradient information in the optimized image, wherein the target region is a region with gradient quantity variation larger than or equal to a preset threshold value; and extracting the line segments in the target area to obtain the initial line segment set.
It should be noted that the above modules may be implemented by software or hardware, and for the latter, the following may be implemented, but not limited to: the modules are all positioned in the same processor; alternatively, the modules are respectively located in different processors in any combination.
Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above-mentioned method embodiments when executed.
In an exemplary embodiment, the computer readable storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Embodiments of the present invention further provide an electronic device, comprising a memory in which a computer program is stored and a processor configured to execute the computer program to perform the steps in any of the above method embodiments.
In an exemplary embodiment, the electronic apparatus 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.
For specific examples in this embodiment, reference may be made to the examples described in the foregoing embodiments and exemplary implementations, and details of this embodiment are not repeated herein.
It will be apparent to those skilled in the art that the various modules or steps of the invention described above may be implemented using a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and they may be implemented using program code executable by the computing devices, such that they may be stored in a memory device and executed by the computing device, and in some cases, the steps shown or described may be performed in an order different than that described herein, or they may be separately fabricated into various integrated circuit modules, or multiple ones of them may be fabricated into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the principle of the present invention should be included in the protection scope of the present invention.
Claims (13)
1. A method for determining line segments in an image is characterized by comprising the following steps:
acquiring an initial line segment set, wherein the initial line segment set comprises a normal line segment and a incomplete line segment extracted from an 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, wherein the target line segment set comprises the normal line segments and a completion line segment obtained after completion processing is performed on the incomplete line segments;
and determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set.
2. The method of claim 1, wherein completing the incomplete line segment in the initial line segment set comprises:
acquiring at least two initial line segments which are positioned on the same straight line in the initial line segment set, wherein the initial line segments comprise the normal line segments and the incomplete line segments;
determining the initial line segments with the distance between adjacent line segments smaller than or equal to a preset threshold value in the at least two initial line segments as a group of incomplete line segments;
and performing the completion processing on the incomplete line segments to obtain the completion line segments.
3. The method of claim 2, wherein obtaining at least two initial line segments of the set of initial line segments that are located on a same straight line comprises:
determining a target coordinate system according to the processed image;
executing the following steps for each initial line segment in the initial line segment set, wherein each initial line segment is a current initial line segment when the following steps are executed:
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 in a vertical relation;
determining the intersection line of the first plane and the second plane as a current intersection line;
and determining at least two initial line segments of the initial line segment set, which are positioned on the current intersection line, as at least two initial line segments on the same straight line.
4. The method of claim 2, wherein performing the completion processing on the incomplete line segment to obtain the completion line segment comprises:
acquiring at least two incomplete line segments which are positioned on the same straight line in the initial line segment set;
and performing the completion processing on the at least two incomplete line segments to obtain the completion line segment.
5. The method of claim 2, wherein performing the completion processing on the at least two incomplete line segments to obtain the completion line segment comprises:
performing the completion processing on a first segment and a second segment of the at least two segments by the following steps, wherein the first segment and the second segment are two adjacent segments:
acquiring two adjacent coordinates between the first incomplete line segment and the second incomplete line segment;
and connecting two adjacent coordinates between the first incomplete line segment and the second incomplete line segment, and determining the connected first incomplete line segment and the second incomplete line segment as the line segments subjected to the completion processing.
6. The method of claim 5, further comprising:
under the condition that the at least two incomplete line segments further comprise a third incomplete line segment and the supplemented line segment are two adjacent line segments, two adjacent coordinates between the supplemented line segment and the third incomplete line segment are obtained;
and connecting two adjacent coordinates between the supplemented line segment and the third incomplete line segment to obtain the supplemented line segment.
7. The method of claim 1, wherein determining a target segment in the target segment set based on a segment length of each segment in the target segment set comprises:
executing the following steps on each line segment in the target line segment set, wherein each line segment is a current line segment when the following steps are executed:
acquiring the length of the current line segment;
acquiring a current length threshold corresponding to the current line segment;
and determining the current line segment as a target line segment when the length of the current line segment is greater than or equal to the current length threshold.
8. The method of claim 7, wherein obtaining the current length threshold corresponding to the current line segment comprises:
acquiring a first abscissa and a first ordinate of a first end point of the current line segment, a second abscissa and a second ordinate of a second end point, and the height and width of the image to be processed;
acquiring a horizontal coordinate difference between the first horizontal coordinate and the second horizontal coordinate and an ordinate difference between the first ordinate and the second ordinate;
and determining the length threshold value according to the height and the width of the image to be processed according to the horizontal coordinate difference and the vertical coordinate difference.
9. The method of claim 8, wherein determining the length threshold based on the height and width of the image to be processed based on the magnitude of the abscissa difference and the ordinate difference comprises:
in the case where the abscissa difference is larger than the ordinate difference, the length threshold is obtained by the following formula:
in a case where the abscissa difference is less than or equal to the ordinate difference, the length threshold is obtained by the following formula:
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, u is 1 Is the first abscissa, v 1 Is said first ordinate, u 2 Is the second abscissa, v 2 Is the second ordinate。
10. The method of claim 1, wherein obtaining the initial set of line segments comprises:
carrying out bilateral filtering optimization on the image to be processed to obtain an optimized image;
determining a target region in the optimized image according to the gradient information in the optimized image, wherein the target region is a region with gradient quantity variation larger than or equal to a preset threshold value;
and extracting the line segments in the target area to obtain the initial line segment set.
11. An apparatus for determining line segments in an image, comprising:
the device comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring an initial line segment set, and the initial line segment set comprises a normal line segment and a incomplete line segment which are extracted from an image to be processed;
a completion module, configured to perform completion processing on the incomplete line segment in the initial line segment set to obtain a target line segment set, where the target line segment set includes the normal line segment and a completion line segment obtained after performing completion processing on the incomplete line segment;
and the determining module is used for determining a target line segment in the target line segment set according to the length of each line segment in the target line segment set.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, wherein the computer program, when being executed by a processor, carries out the steps of the method as claimed in any one of the claims 1 to 10.
13. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method as claimed in any of claims 1 to 10 are implemented when the computer program is executed by the processor.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211096766.5A CN115564714A (en) | 2022-09-08 | 2022-09-08 | Method and device for determining line segments in image, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211096766.5A CN115564714A (en) | 2022-09-08 | 2022-09-08 | Method and device for determining line segments in image, storage medium and electronic device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115564714A true CN115564714A (en) | 2023-01-03 |
Family
ID=84741712
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211096766.5A Pending CN115564714A (en) | 2022-09-08 | 2022-09-08 | Method and device for determining line segments in image, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115564714A (en) |
-
2022
- 2022-09-08 CN CN202211096766.5A patent/CN115564714A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108446698B (en) | Method, device, medium and electronic equipment for detecting text in image | |
US10521694B2 (en) | 3D building extraction apparatus, method and system | |
CN110781756A (en) | Urban road extraction method and device based on remote sensing image | |
CN110991560A (en) | Target detection method and system in combination with context information | |
CN112580561A (en) | Target detection method and device, electronic equipment and storage medium | |
CN112613107B (en) | Method, device, storage medium and equipment for determining construction progress of pole and tower engineering | |
CN111310710A (en) | Face detection method and system | |
CN114611635B (en) | Object identification method and device, storage medium and electronic device | |
CN112819889B (en) | Method and device for determining position information, storage medium and electronic device | |
CN117315406B (en) | Sample image processing method, device and equipment | |
CN111833341B (en) | Method and device for determining stripe noise in image | |
CN115564714A (en) | Method and device for determining line segments in image, storage medium and electronic device | |
CN110135422B (en) | Dense target detection method and device | |
CN111630569B (en) | Binocular matching method, visual imaging device and device with storage function | |
CN113469130B (en) | Method and device for detecting shielding target, storage medium and electronic device | |
CN110874814A (en) | Image processing method, image processing device and terminal equipment | |
CN113256484B (en) | Method and device for performing stylization processing on image | |
CN115830342A (en) | Method and device for determining detection frame, storage medium and electronic device | |
CN112288817B (en) | Three-dimensional reconstruction processing method and device based on image | |
CN112633198A (en) | Picture processing method and device, storage medium and electronic device | |
CN117541838A (en) | Threshold adjustment method and device for object detection and electronic equipment | |
CN113780286A (en) | Object recognition method and device, storage medium and electronic device | |
CN113362227A (en) | Image processing method, image processing device, electronic equipment and storage medium | |
CN117094994B (en) | Sliding window parameter determining method, image identifying method and device | |
CN112991451A (en) | Image recognition method, related device and computer program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |