Method and system for automatically detecting target line in manually designated area
By automatically detecting target lines in artificially designated areas, using improved ED lines and Edge Drawing algorithms to screen and fit lines, the problem of inaccurate line detection in the existing technology is solved, the detection efficiency and accuracy are improved, and the detection efficiency and accuracy are simplified. Image editing process.
Patent Information
- Application Number
- CN202411133109.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-29
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, line detection methods detect the entire image, lack efficient and accurate detection of target lines in designated areas, resulting in inaccurate and incomplete line extraction, and no effective solution has been found.
The method of automatically detecting target lines in artificially specified areas is adopted. By obtaining the starting point and end point of the smear trace, calculating the straight line distance, extending the detection area vertically, using the improved ED lines detection algorithm and Edge Drawing algorithm for detection, filtering and fitting similar to obtain the target detection line.
It improves the detection efficiency and recognition accuracy of target lines in designated areas, simplifies the screening process, and enhances the processing ability of target lines in designated areas, making it easier to follow-up image editing and processing.
Smart Images

Figure CN119048540A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of Internet image editing, and in particular to a method and a system for automatically detecting target lines in a manually designated area. Background Art
[0002] With the development of Internet technology, people's requirements for information exchange are becoming higher and higher. Images are an important channel for people to exchange information, and people will also process images according to their own needs in life. Line detection is a very important link for image-based editing content. By extracting the lines in the image, the image can be further processed. The line detection method has very important application value. The line detection method in the prior art detects all the lines of the entire image, and there are few methods for detecting target lines in a specified area. The disadvantage of this line detection is that when processing the target line technology in the specified area, there is a problem of inaccurate and incomplete line extraction. For this problem, no effective solution has been proposed yet. Therefore, how to improve the accuracy and efficiency of line detection is a technical problem that needs to be solved at this stage. Summary of the invention
[0003] The purpose of the present invention is to solve the above problems and to design a method and system for automatically detecting target lines in a manually designated area.
[0004] To achieve the above object, the technical solution of the present invention is that, further, in the above method for automatically detecting target lines in a manually designated area, the method for automatically detecting target lines in a manually designated area comprises the following steps:
[0005] Obtaining the starting point and the end point of the smear mark, connecting the starting point and the end point to obtain a connecting line, and obtaining the straight-line distance of the connecting line;
[0006] Based on the straight-line distance, vertically extend 20 pixels above and below the connecting line to obtain a line detection area;
[0007] Detecting the line detection area by using an improved ED lines detection algorithm to obtain initial detection lines;
[0008] Calculating the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines;
[0009] Among the similar detection lines, lines with similar distances and slopes are selected for line segment fitting, and a detection line with the best fitting is obtained in the line detection area to obtain the target detection line.
[0010] Furthermore, in the above-mentioned method for automatically detecting target lines in a manually designated area, the step of obtaining the starting point and the end point of the smear trace, connecting the starting point and the end point to obtain a connecting line, and obtaining the straight-line distance of the connecting line includes:
[0011] Acquire the smear traces in the system, and use sub-pixel precision positioning technology to acquire the starting point and the end point of the smear traces;
[0012] Using the Euclidean distance between two points, calculate and draw the line from the starting point to the end point to obtain the connecting line and straight-line distance.
[0013] Furthermore, in the above-mentioned method for automatically detecting target lines in a manually designated area, the line detection area is detected by using an improved ED lines detection algorithm to obtain initial detection lines, including:
[0014] Use the Edge Drawing algorithm to generate pixel chains, connect the generated pixel chains, and combine them to form the edge of the image.
[0015] Furthermore, in the above-mentioned method for automatically detecting target lines in a manually specified area, the use of the EdgeDrawing algorithm to generate pixel chains, connecting the generated pixel chains to form the edge of the image together, includes:
[0016] Graying the line detection area, and performing denoising and smoothing processing on the line detection area using Gaussian filtering to obtain a smooth line detection area;
[0017] The gradient operator in the Edge Drawing algorithm is used to calculate the amplitude and direction of each pixel in the smooth line detection area to obtain an amplitude line detection area;
[0018] Calculate the anchor points in the amplitude line detection area, the gradient operator generates the maximum value, and obtain the gradient peak area image;
[0019] The anchor points in the gradient peak region image are connected to obtain edge lines, thereby obtaining a line region detection image, and adjacent pixel chains in the line region detection image are refined to obtain an edge detection region.
[0020] Further, in the above-mentioned method for automatically detecting target lines in a manually designated area, the calculating of the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines, comprises:
[0021] Performing line detection on the edge detection area to obtain detection lines in the edge detection area;
[0022] Calculating the slope and distance of the connecting line, and determining the slope and distance between the detection line and the connecting line;
[0023] If the difference in slope angle between the detection line and the connection line is within 10°, and the difference in distance between the detection line and the connection line is 8 pixels, then the detection line is determined to be a similar detection line.
[0024] Furthermore, in the above-mentioned method for automatically detecting target lines in a manually specified area, the lines with similar distances and slopes are selected from the similar detection lines for line segment fitting, and a detection line with the best fitting is obtained in the line detection area to obtain the target detection line, including:
[0025] Acquire similar detected lines, expand a certain line A of the similar detected lines, and when encountering a line B that can be fitted with the line A, draw a line from the starting point of the line A to the end point of the fitable line B to obtain a continuous line C;
[0026] If the line A does not encounter a fitable line when it reaches the end of the line detection area, the line A is retained;
[0027] If the line A has been fitted with another line segment D when it reaches the end of the line detection area, the other line segment D is used to replace the line A;
[0028] A detection line with the best fit is obtained in the line detection area to obtain a target detection line.
[0029] Further, in a system for automatically detecting target lines in a manually specified area, the system for automatically detecting target lines in a manually specified area includes the following modules:
[0030] An endpoint acquisition module is used to acquire the starting point and the end point of the smear trace, connect the starting point and the end point to obtain a connecting line, and acquire the straight-line distance of the connecting line;
[0031] A detection area generation module, used to vertically extend 20 pixels above and below the connecting line based on the straight line distance to obtain a line detection area;
[0032] A line detection module, used to detect the line detection area by using an improved ED lines line detection algorithm to obtain initial detection lines;
[0033] A line screening module, used to calculate the slope and distance of the connecting lines, screen the initial detection lines, and screen the initial detection lines with similar slopes and distances to the connecting lines to obtain similar detection lines;
[0034] The line fitting module is used to select lines with similar distances and slopes from the similar detection lines for line segment fitting, obtain a detection line with the best fitting in the line detection area, and obtain a target detection line.
[0035] Furthermore, in a system for automatically detecting target lines in a manually specified area, the line detection module includes the following submodules:
[0036] A smoothing processing submodule, used to grayscale the line detection area, and perform denoising and smoothing processing on the line detection area using Gaussian filtering to obtain a smoothed line detection area;
[0037] an amplitude calculation submodule, for calculating the amplitude and direction of each pixel in the smooth line detection area by using a gradient operator to obtain an amplitude line detection area;
[0038] A gradient peak submodule is used to calculate the anchor point in the amplitude line detection area, and the gradient operator generates a maximum value to obtain a gradient peak area image;
[0039] The anchor point connection submodule is used to connect the anchor points in the gradient peak area image to obtain edge lines, obtain a line area detection image, and refine adjacent pixel chains in the line area detection image to obtain an edge detection area.
[0040] The beneficial effect is that, by obtaining the starting point and the end point of the smear mark, the starting point and the end point are connected to obtain a connecting line, and the straight-line distance of the connecting line is obtained; based on the straight-line distance, 20 pixels are vertically extended above and below the connecting line to obtain a line detection area; the line detection area is detected by an improved ED lines line detection algorithm to obtain an initial detection line; the slope and distance of the connecting line are calculated, the initial detection line is screened, and the initial detection lines with similar slopes and distances to the connecting line are screened to obtain similar detection lines; among the similar detection lines, lines with similar distances and slopes are selected for line segment fitting, and a detection line with the best fitting is obtained in the line detection area to obtain a target detection line. (1) The detection efficiency of the target line in the specified area is improved. The original method is to detect all the lines of the image, and it takes more effort to screen the required lines. The present invention helps to speed up the speed of screening the target lines. (2) The recognition accuracy of the target lines in the specified area is improved. When editing an image, the target lines in the specified area can be processed more accurately. (3) Provide convenience for subsequent image processing work. Improving the speed and accuracy of the target lines in the specified area can facilitate subsequent image processing work, such as erasing the target lines. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the following detailed description of the preferred embodiment.The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting the invention.
[0042] Figure 1 A schematic diagram of a first embodiment of a method for automatically detecting target lines in a manually specified area according to an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a second embodiment of a method for automatically detecting target lines in a manually designated area according to an embodiment of the present invention;
[0044] Figure 3 Schematic diagram of a first embodiment of a system for automatically detecting target lines in a manually designated area according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0046] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0047] The present invention will be described in detail below in conjunction with the accompanying drawings. Figure 1 As shown, a method for automatically detecting target lines in a manually specified area, the method for automatically detecting target lines in a manually specified area comprises the following steps:
[0048] Step 101, obtaining the starting point and the end point of the smear mark, connecting the starting point and the end point to obtain a connecting line, and obtaining the straight-line distance of the connecting line;
[0049] Specifically, in this embodiment, the smear traces in the system are obtained, and the starting point and the end point of the smear traces are obtained using sub-pixel precision positioning technology; the Euclidean distance between the two points is used to calculate and draw a line from the starting point to the end point to obtain the connecting line and the straight line distance.
[0050] Step 102, based on the straight line distance, vertically extend 20 pixels above and below the connecting line to obtain a line detection area;
[0051] Step 103: Detect the line detection area using the improved ED lines detection algorithm to obtain initial detection lines;
[0052] Specifically, in this embodiment, an Edge Drawing algorithm is used to generate pixel chains, and the generated pixel chains are connected to form the edge of the image.
[0053] The line detection area is grayed out, and the line detection area is denoised and smoothed using Gaussian filtering to obtain a smooth line detection area; the gradient operator in the Edge Drawing algorithm is used to calculate the amplitude and direction of each pixel in the smooth line detection area to obtain an amplitude line detection area; the anchor points in the amplitude line detection area are calculated, and the gradient operator produces the maximum value to obtain a gradient peak area image; the anchor points in the gradient peak area image are connected to obtain edge lines, obtain a line area detection image, and refine the adjacent pixel chains in the line area detection image to obtain an edge detection area.
[0054] Specifically, in this embodiment, "Edge Drawing" generally refers to an edge detection algorithm, which is a technique used in image processing and computer vision to identify the boundaries of objects in an image. The main purpose of an edge detection algorithm is to highlight significant changes in an image, thereby extracting structural information of the image.
[0055] This method utilizes Canny edge detection, which is a multi-stage edge detection method that aims to find the true edges in a given image.
[0056] Canny edge detection steps: Smoothing: Use a Gaussian filter to smooth the image to reduce noise. Calculate gradients: Use a Sobel-like method to calculate the gradient strength and direction. Non-maximum suppression: For each pixel, if its gradient value is not the local maximum along the gradient direction, it is set to 0. Double threshold and edge tracking: Apply two thresholds, the low threshold is used to detect potential weak edges, and the high threshold is used to determine strong edges. Then the edge detection is completed by connecting these weak edges.
[0057] Step 104, calculating the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines;
[0058] Specifically, in this embodiment, line detection is performed on the edge detection area to obtain detection lines in the edge detection area; the slope and distance of the connecting lines are calculated, and the slope and distance between the detection lines and the connecting lines are determined; if the slope angle difference between the detection line and the connecting line is within 10°, and the distance difference between the detection line and the connecting line is 8 pixels, then they are determined to be similar detection lines.
[0059] Step 105: among the similar detection lines, select lines with similar distance and slope for line segment fitting, obtain a detection line with the best fitting in the line detection area, and obtain the target detection line.
[0060] Specifically, in this embodiment, similar detection lines are obtained, and a certain line A of the similar detection lines is expanded. When a line B that can be fitted with line A is encountered, a line is drawn from the starting point of line A to the end point of the fitted line B to obtain a continuous line C; if line A has not encountered a fitable line when it reaches the end of the line detection area, line A is retained; if line A has been fitted with other line segments D when it reaches the end of the line detection area, other line segments D are used to replace line A; an optimally fitted detection line is obtained in the line detection area to obtain a target detection line.
[0061] The beneficial effect is that, by obtaining the starting point and the end point of the smear mark, the starting point and the end point are connected to obtain the connecting line, and the straight-line distance of the connecting line is obtained; based on the straight-line distance, 20 pixels are vertically extended above and below the connecting line to obtain the line detection area; the line detection area is detected by the improved ED lines line detection algorithm to obtain the initial detection line; the slope and distance of the connecting line are calculated, the initial detection line is screened, and the initial detection lines with similar slopes and distances to the connecting line are screened to obtain similar detection lines; among the similar detection lines, the lines with similar distances and slopes are selected for line segment fitting, and a detection line with the best fitting is obtained in the line detection area to obtain the target detection line. (1) The detection efficiency of the target line in the specified area is improved. The original method is to detect all the lines of the image, and it takes more effort to screen the required lines. The present invention helps to speed up the speed of screening the target lines. (2) The recognition accuracy of the target lines in the specified area is improved. When editing the image, the target lines in the specified area can be processed more accurately. (3) Convenience is provided for subsequent image processing work. After improving the speed and accuracy of the target lines in the specified area, subsequent image processing work, such as erasing the target lines, can be facilitated.
[0062] See also Figure 2In a method for automatically detecting target lines in a manually specified area, an edge drawing algorithm is used to generate pixel chains, and connecting the generated pixel chains to form the edge of an image includes the following steps:
[0063] Step 201, graying the line detection area, and performing denoising and smoothing processing on the line detection area using Gaussian filtering to obtain a smooth line detection area;
[0064] Step 202: Calculate the amplitude and direction of each pixel in the smooth line detection area using the gradient operator in the Edge Drawing algorithm to obtain an amplitude line detection area;
[0065] Step 203, calculating the anchor points in the amplitude line detection area, the gradient operator generates the maximum value, and obtaining the gradient peak area image;
[0066] Step 204: connect the anchor points in the gradient peak region image to obtain edge lines, obtain a line region detection image, and refine adjacent pixel chains in the line region detection image to obtain an edge detection region.
[0067] The above is an introduction to an embodiment of a method for automatically detecting target lines in a manually specified area of the present invention. Figure 3 In a system for automatically detecting target lines in a manually specified area, the system for automatically detecting target lines in a manually specified area includes the following modules:
[0068] The endpoint acquisition module is used to obtain the starting point and the end point of the smear trace, connect the starting point and the end point to obtain a connecting line, and obtain the straight-line distance of the connecting line;
[0069] A detection area generation module is used to obtain a line detection area by vertically extending 20 pixels above and below the connecting line based on the straight line distance;
[0070] The line detection module is used to detect the line detection area through the improved ED lines line detection algorithm to obtain the initial detection line;
[0071] A line screening module is used to calculate the slope and distance of the connecting lines, screen the initial detection lines, and screen the initial detection lines with similar slopes and distances to the connecting lines to obtain similar detection lines;
[0072] The line fitting module is used to select lines with similar distances and slopes from similar detection lines for line segment fitting, obtain a detection line with the best fit in the line detection area, and obtain the target detection line.
[0073] The beneficial effect is that the detection efficiency of the target lines in the designated area can be improved, which helps to speed up the speed of screening the target lines. The recognition accuracy of the target lines in the designated area can be improved. When editing the image, the target lines in the designated area can be processed more accurately. It provides convenience for subsequent image processing work. After improving the speed and accuracy of the target lines in the designated area, subsequent image processing work can be facilitated, such as erasing the target lines.
[0074] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only preferred examples of the present invention and are not intended to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A method for automatically detecting target lines in a manually specified area, characterized in that: The method comprises the following steps: Obtaining the starting point and the end point of the smear mark, connecting the starting point and the end point to obtain a connecting line, and obtaining the straight-line distance of the connecting line; Based on the straight-line distance, vertically extend 20 pixels above and below the connecting line to obtain a line detection area; Detecting the line detection area using an improved ED lines line detection algorithm to obtain initial detection lines; Calculating the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines; Among the similar detection lines, lines with similar distances and slopes are selected for line segment fitting, and a detection line with the best fitting is obtained in the line detection area to obtain the target detection line.
2. A method for automatically detecting target lines in a manually specified area according to claim 1, characterized in that: The step of obtaining the starting point and the end point of the smear trace, connecting the starting point and the end point to obtain a connecting line, and obtaining the straight-line distance of the connecting line includes: Acquire the smear traces in the system, and use sub-pixel precision positioning technology to acquire the starting point and the end point of the smear traces; Using the Euclidean distance between two points, calculate and draw the line from the starting point to the end point to obtain the connecting line and straight-line distance.
3. The method for automatically detecting target lines in a manually designated area according to claim 1, characterized in that: The step of detecting the line detection area by using an improved ED lines line detection algorithm to obtain initial detection lines includes: Use the Edge Drawing algorithm to generate pixel chains, connect the generated pixel chains, and combine them to form the edge of the image.
4. The method for automatically detecting target lines in a manually designated area according to claim 3, characterized in that: The edge drawing algorithm is used to generate pixel chains, and the generated pixel chains are connected to form the edge of the image, including: Graying the line detection area, and performing denoising and smoothing processing on the line detection area using Gaussian filtering to obtain a smooth line detection area; The gradient operator in the Edge Drawing algorithm is used to calculate the amplitude and direction of each pixel in the smooth line detection area to obtain an amplitude line detection area; Calculate the anchor points in the amplitude line detection area, the gradient operator generates the maximum value, and obtain the gradient peak area image; The anchor points in the gradient peak region image are connected to obtain edge lines, thereby obtaining a line region detection image, and adjacent pixel chains in the line region detection image are refined to obtain an edge detection region.
5. The method for automatically detecting target lines in a manually designated area according to claim 1, characterized in that: The calculating the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines, includes: Performing line detection on the edge detection area to obtain detection lines in the edge detection area; Calculating the slope and distance of the connecting line, and determining the slope and distance between the detection line and the connecting line; If the difference in slope angle between the detection line and the connection line is within 10°, and the difference in distance between the detection line and the connection line is 8 pixels, then the detection line is determined to be a similar detection line.
6. The method for automatically detecting target lines in a manually designated area according to claim 1, characterized in that: The method of selecting lines with similar distance and slope from the similar detection lines for line segment fitting, obtaining a detection line with the best fitting in the line detection area, and obtaining a target detection line includes: Acquire similar detected lines, expand a certain line A of the similar detected lines, and when encountering a line B that can be fitted with the line A, draw a line from the starting point of the line A to the end point of the fitable line B to obtain a continuous line C; If the line A does not encounter a fitable line when it reaches the end of the line detection area, the line A is retained; If the line A has been fitted with another line segment D when it reaches the end of the line detection area, the other line segment D is used to replace the line A; A detection line with the best fit is obtained in the line detection area to obtain a target detection line.
7. A system for automatically detecting target lines in a manually specified area, characterized in that: The system includes the following modules: An endpoint acquisition module is used to acquire the starting point and the end point of the smear trace, connect the starting point and the end point to obtain a connecting line, and acquire the straight-line distance of the connecting line; A detection area generation module, used to vertically extend 20 pixels above and below the connecting line based on the straight line distance to obtain a line detection area; A line detection module, used to detect the line detection area by using an improved ED lines line detection algorithm to obtain initial detection lines; A line screening module, used for calculating the slope and distance of the connecting lines, screening the initial detection lines, screening the initial detection lines with similar slopes and distances to the connecting lines, and obtaining similar detection lines; The line fitting module is used to select lines with similar distances and slopes from the similar detection lines for line segment fitting, obtain a detection line with the best fitting in the line detection area, and obtain a target detection line.
8. The system for automatically detecting target lines in a manually designated area according to claim 7, characterized in that: The line detection module includes the following submodules: A smoothing processing submodule, used to grayscale the line detection area, and perform denoising and smoothing processing on the line detection area using Gaussian filtering to obtain a smoothed line detection area; an amplitude calculation submodule, for calculating the amplitude and direction of each pixel in the smooth line detection area by using a gradient operator to obtain an amplitude line detection area; A gradient peak submodule is used to calculate the anchor point in the amplitude line detection area, and the gradient operator generates a maximum value to obtain a gradient peak area image; The anchor point connection submodule is used to connect the anchor points in the gradient peak area image to obtain edge lines, obtain a line area detection image, and refine adjacent pixel chains in the line area detection image to obtain an edge detection area.
