Image frame line extraction method, device and system of borehole histogram
By preprocessing the borehole histogram image and LSD straight line detection, combined with topological constraint rules, the noise and straight line cluster problems in frame line detection are solved, the completeness and accuracy of the detection results are improved, and the efficiency of the frame line is achieved Extraction and correction.
Patent Information
- Application Number
- CN202411124145.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-08-16
AI Technical Summary
The existing technology is susceptible to unclear image printing, inaccurate straight line detection algorithms and noise in the detection of drilled histogram frame lines, resulting in missing or inaccurate frame line detection, and the same straight line detection result is multiple straight line clusters, which cannot Meet expectations for completeness and accuracy.
By preprocessing the input image, including grayscale, adaptive threshold binarization, erosion and expansion, combined with OpenCV's LSD straight line detection algorithm, horizontal and vertical frame lines are detected based on topological adjacent or connected relationships. Clustering and refinement, establishing topological constraint rules for the organization of table frame lines, correcting the detection results, and outputting vector files.
It improves the completeness and accuracy of frame line detection results, eliminates the impact of high-density text and noise on detection, and eliminates the need to manually set thresholds. It is highly efficient and versatile, and can effectively correct incomplete or inaccurate frame line detection.
Smart Images

Figure CN118657803A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of drilling column graph frame line extraction and optimization, in particular to a drilling column graph image frame line extraction method, and also to a drilling column graph image frame line extraction system. Background Art
[0002] At present, most of the drilling histograms are still archived in the form of images, including scanned images of paper documents and graphic export images. Due to the differences in the representation and information organization of drilling histograms from different sources, the automatic extraction of drilling histogram information is currently carried out by combining image understanding and digital image processing technology. The core key step is to accurately and completely extract the table frame lines.
[0003] However, in actual operations, due to unclear image printing or scanning, inaccurate detection of straight line detection algorithms, and image noise, it is easy to have missing or inaccurate frame line detection. At the same time, due to the wide frame line pixels and the existence of line aliasing in the image, the same straight line is often detected as multiple straight line clusters in the detection results, which cannot meet expectations. Therefore, it is necessary to optimize the frame line extraction method to improve the completeness and accuracy of the frame line detection results. Summary of the invention
[0004] In view of this, the present invention provides a method, device and system for extracting frame lines of a drilling histogram image, so as to improve the integrity and accuracy of the frame line detection results.
[0005] In order to achieve the above object, the basic scheme of the present invention provides an image frame line extraction method of a drilling histogram, comprising the following steps: Step 100, input image format drilling histogram; Step 200, input image preprocessing; Step 300, frame line detection and line cluster merging and refinement; Step 400, merging and refining the result straight lines for post-processing; Step 500, outputting the vector file of the horizontal and vertical frame lines in the table frame lines in the image drilling histogram, and ending.
[0006] In one possible design, step 200 specifically includes: Step 201, read the drilling histogram image matrix Image, and obtain the height H and width W of the matrix Image; Step 202, using OpenCV to perform grayscale and adaptive threshold binarization operations on the input image Image, and output a binary image Binary_img; Step 203, according to the height H and width W, set the adaptive size rectangular convolution kernels respectively, the height rectangle Kernel1, the size is height H / 20, width 1; the width rectangle Kernel2, the size is height 1, width W / 20; respectively use Kernel1 and Kernel2 to corrode Binary_img using OpenCV first and then expand to obtain the horizontal frame line image Horizontal_img and the vertical frame line image Vertical_img; Step 204 , vertically project the vertical frame line image Vertical_img to obtain a pixel line width set Line_width={w1,w2,w3,…,wn}, and calculate the set arithmetic mean w_mean; the input image preprocessing is completed, and the process proceeds to step 300 .
[0007] In a possible design, step 300 is specifically that the straight line detection and straight line cluster merging and thinning process is divided into two parts: horizontal frame lines and vertical frame lines, and the horizontal frame lines are extracted and processed.
[0008] In one possible design, step 300 includes, Step 301, read the horizontal frame line image Horizontal_img, use Opencv's LSD line detection algorithm to detect the frame lines in Horizontal_img, and obtain preliminary detection results, horizontal frame line cluster Horline_set, each straight line in the cluster is expressed and stored in the form of the coordinates of the two end points, Step 302, traverse all horizontal lines in Horline_set, and arrange the lines in the set in ascending order according to height y; proceed to step 303 to cluster the line clusters at the same height of Horline_set based on topological adjacency or connection relationship; Step 303, if there are still unclassified lines in Horline_set, go to step 3031; otherwise go to step 304; Among them, step 3031, traverse the sorted Horline_set, initialize all_hor_class to store all heights of line clusters and single height line cluster hor_class, add hor_class to all_hor_class, add the first line line1=[(x1,y1),(x2,y1)] to hor_class, and mark y, y=y1, then delete line1 from Horline_set; then enter step 3032; Step 3032: Continue to traverse the straight lines in the set, read the next straight line line2 = [(x3, y2), (x4, y2)]. If the difference between the height y2 of line2 and the marked y, |y - y2| ≤ 1, then add line2 to hor_class, delete line2 from Horline_set, update the marked y = y2, and enter Step 303; otherwise, enter Step 3031. Step 304: Traverse all the straight line cluster sets all_hor_class after clustering. If there are still straight line clusters that have not been traversed, enter Step 3041 until all horizontal straight line clusters are processed, and then enter Step 305. Step 3041: Read the straight line cluster hor_class, initialize the x - coordinate range set xrange_set, the y - coordinate set y_set, and the merged straight line x - coordinate set xrange_merge_set; enter Step 3042. Step 3042: Traverse all the straight lines in hor_class. Denote the straight line linei = [(xi1, yi), (xi2, yi)], where i is the index of the line in the set, i = 1, 2, 3, …, n. Add yi to y_set, add [xi1, xi2] to xrange_set, delete the traversed hor_class, and enter Step 3043. Step 3043: Read y_set, calculate the arithmetic mean of all elements in y_set, denoted as y_mean, and enter Step 3044. Step 3044: Traverse x_range_set, initialize the straight line x - coordinate range x_range = [x11, x12], and add it to xrange_merge_set; enter Step 3045. Step 3045: Continue to traverse to get the x - coordinate range x_range = [x21, x22]. If x21 ∈ [x11, x12] and x22 > x12, then update x12 = x22; if x22 < x12, then do not update. Delete the line that has completed traversal. If there are still x - coordinate ranges that have not been traversed, enter Step 3044; otherwise, enter Step 3046. Step 3046: Traverse the merged x - coordinate range xrange_merge_set, with the internal element xrange_mergei = [xi1, xi2]. Output the straight line [(xi1, y_mean), (xi2, y_mean)], and add it to the set mergeline_set; enter Step 304. Step 305, processing the vertical frame line detection result, reading the vertical frame line image Vertical_img, using Opencv's LSD line detection algorithm to detect the frame lines in Vertical_img, and obtaining a preliminary detection result, a vertical frame line cluster Vertical_set, in which each straight line in the cluster is expressed and stored in the form of the coordinates of both end points; then entering step 306; Step 306, traverse all horizontal lines in Verline_set, and arrange the lines in the set in ascending order according to the horizontal position x; proceed to step 307, cluster the line clusters at the same height of Verline_set based on the topological adjacent or connected relationship; Step 307, if there are still unclassified lines in Verline_set, go to step 3071; otherwise go to step 308; Among them, step 3071, traverse the sorted Verline_set, initialize all line cluster classes all_ver_class, line cluster class ver_class, and add ver_class to all_ver_class, and add the first line line1=[(x1,y1),(x1,y2)] to ver_class, and mark x, x=x1, and then delete line1 from Verline_set; then enter step 3032; Step 3072, continue to traverse the lines in the set, read the next line line2 = [(x2, y3), (x2, y4)], if the difference between the height y2 of line2 and the mark y, |x-x2|≤1, then add line2 to ver_class, delete line2 from Verline_set, update the mark x = x2, and go to step 308, otherwise go to step 3071; Step 308, traverse the clustering to complete all the line cluster sets all_ver_class, if there are still line clusters that have not been traversed, then go to step 3081, until all the line clusters are processed, then go to step 400; Among them, step 3081 reads the line cluster class ver_class, initializes the y coordinate range set yrange_set, the x coordinate set x_set, and the merged line y coordinate set yrange_merge_set; then proceeds to step 3082; Step 3082, traverse all lines in ver_class, record linei=[(xi,yi1),(xi,yi2)], i is the index of the line in the set, i=1, 2, 3, ..., n, add xi to x_set, add [yi1, yi2] to yrange_set, delete the traversed ver_class, and go to step 3043; Step 3083: Read x_set, calculate the arithmetic mean of all elements in x_set, denoted as x_mean, and proceed to Step 3084; Step 3084: Traverse y_range_set, initialize the y - coordinate range of the line y_range = [y11, y12], and add it to yrange_merge_set, then proceed to Step 3085; Step 3085: Continue traversing to obtain the y - coordinate range y_range = [y21, y22]. If y21 ∈ [y11, y12] and y22 > y12, then update y12 = y22; if y22 < y12, do not update. Delete the lines that have completed traversal. If there are still y - coordinate ranges that have not been traversed, proceed to Step 3084; otherwise, proceed to Step 3086; Step 3086: Traverse the merged y - coordinate range yrange_merge_set, where the internal element yrange_mergei = [yi1, yi2], output the line [(x_mean, yi1), (x_mean, yi2)], and add it to the set mergeline_set; then proceed to Step 308.
[0009] In a possible design, the said Step 400 includes Step 401: Read the horizontal and vertical frame line sets Hor_set and Ver_set obtained after merging and refinement, and proceed to Step 402; Step 402: Initialize the vertical - coordinate set of horizontal frame lines Hory_set and the horizontal - coordinate set of vertical frame lines Verx_set. Traverse the vertical coordinates y of the lines in Hor_set and add them to Hory_set, and traverse the horizontal coordinates x of the lines in Ver_set and add them to Verx_set. Both are sorted in ascending order to obtain Hory_set = {y1, y2,..., yn} and Verx_set = {x1, x2,..., xn}; then proceed to Step 403; Step 403: Traverse all horizontal frame lines in Hor_set, read the line hor_linei = [(xi1, yi), (xi2, yi)], where i = 1, 2, 3,..., n, to obtain the horizontal coordinates xi1 and xi2 of the two endpoints of the line. If xi1 ∈ Verx_set, no adjustment is made, and the same applies to xi2; otherwise, proceed to Step 404; Step 404, respectively calculate the absolute value of the difference between xi1 and all x coordinates in Verx_set, and obtain the absolute minimum value D_min and its corresponding x coordinate xmin, and determine the size relationship between xmin and the set threshold t=3*w_mean. If D_min≤t, modify xi1=xmin, otherwise modify xi1=xmin+1; after traversing and adjusting the horizontal frame line in Hor_set, enter step 405; Step 405, traverse all vertical frame lines in Ver_set, read the straight line ver_linei=[(xi,yi1),(xi,yi2)], and obtain the vertical range of the straight line [yi1,yi2]. If yi1∈Hory_set, no adjustment is made, and the same is true for yi2. Otherwise, go to step 406; Step 406, respectively calculate the absolute value of the difference between yi1 and all x coordinates in Hory_set, and obtain the absolute minimum value D_min and its corresponding y coordinate ymin, and determine the size relationship between ymin and the set threshold t=3*w_mean. If D_min≤t, modify yi1=ymin, otherwise modify yi1=ymin+1; until the vertical frame lines in Ver_set are traversed and adjusted, enter step 407; Step 407, obtain the adjusted horizontal frame line Hor_set and vertical frame line Ver_set, arrange them in ascending order according to the height y coordinate and the horizontal position x coordinate, and proceed to step 408; Step 408, traverse all the lines in Ver_set and classify them according to the x-coordinates of the vertical lines to obtain Ver_x_class, where the x-coordinates of the lines in each class are the same, and then proceed to step 409; Step 409, traverse all classes Ver_class in Ver_x_class, if the class length is equal to 1, no operation is performed, otherwise go to step 410; Step 410, traverse all the lines in the class, record the x coordinate x0 of the current class line, and the y coordinates of the upper and lower endpoints of all the lines, obtain the y coordinate set y_class_set={y1,y2,y3,…,yn}, and go to step 411; Step 411, take the maximum value y_max and the minimum value y_min in y_class_set, and obtain the straight line line=[(x0,y_min),(x0,y_max)], delete all the straight lines in Ver_class in Ver_set, and add line until all classes are traversed.
[0010] In a possible design, the image format in step 100 includes jpg, png or tif.
[0011] In a possible design, in step 500, the output is a vector file of the horizontal and vertical frame lines in the table frame line in the image drilling histogram, which is stored in the coordinates of the nodes at both ends of the line in the Esri Shapefile file coordinate system, and the storage format is as follows: .
[0012] The present invention also provides an image frame line extraction device for a drilling bar graph, comprising a memory, a control processor, and a computer program stored in the memory and executable on the control processor. The control processor executes the program to implement the image frame line extraction method for the drilling bar graph as described above.
[0013] The present invention also provides a control system, comprising the image frame line extraction device of the drilling column chart as described above.
[0014] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the image frame line extraction method of the drilling column chart as described above.
[0015] Aiming at the demand for frame line extraction of drill bar chart tables, the present invention pre-processes the input image to remove other noise elements outside the frame line to enhance the detection accuracy, and sets topological constraints in combination with the frame line organization rules of the drill bar chart table. From the perspective of post-processing, the multiple straight line clusters in the detection results are accurately merged and refined, and corrected to improve the accuracy and completeness of the frame line detection results.
[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) The present invention can eliminate the influence of high-density text and noise on the LSD algorithm in the process of straight line detection of the image drilling histogram.
[0017] (2) In the process of merging and thinning the detected straight line clusters, the present invention does not need to manually set and adjust the threshold. Instead, the straight line clusters belonging to the same line are merged and thinned based on the topological adjacent or connected relationship between the straight lines. This method has high efficiency and strong versatility.
[0018] (3) The present invention designs topological constraint rules based on the organizational rules of table frame lines, corrects and supplements incomplete and inaccurate frame lines, and improves the completeness and accuracy of the results. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A logical block diagram of a method, device and system for extracting frame lines from a drilling histogram according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] To further illustrate each embodiment, the present invention provides drawings, which are part of the disclosure of the present invention and are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in the field should be able to understand other possible implementations and advantages of the present invention. The components in the figures are not drawn to scale, and similar component symbols are generally used to represent similar components.
[0022] The existing technologies mainly include the following methods: (1) Currently, the commonly used line detection algorithms include those based on transform domain, such as Hough Transformation, RANSAC, etc., and those based on image domain, such as Line Segments Detection (LSD), Canny Lines, etc.
[0023] (2) For the merging and thinning of line clusters detected by the line detection algorithm, the commonly used method is the distance-based method, that is, merging and thinning the lines within the distance threshold tolerance.
[0024] Among them, the disadvantages of the above-mentioned prior art are as follows: (1) Due to the line detection algorithm itself, the unclear straight lines in the original image, and the multi-pixel line width and line aliasing of the frame lines in the image, the detection results are prone to missing line information and inaccurate results. At the same time, the single-line frame lines in the actual image appear as multiple straight line clusters in the detection results, which will cause inaccurate frame line detection or affect the subsequent table structure recognition.
[0025] (2) The line detection algorithm based on the image domain is suitable for complex images, but it is easily affected by image noise and high-density text in tables. The algorithm based on the transform domain has strong noise resistance, but it is prone to reduced accuracy and integrity when faced with complex image extraction tasks.
[0026] (3) To merge line clusters based on distance, on the one hand, it is necessary to adjust the distance threshold multiple times according to different images for merging. On the other hand, due to the existence of line aliasing, the deviation between the two ends of the same frame line is large, and the merging result may be too far away from the actual deviation, resulting in inaccuracy.
[0027] At present, the extraction of frame lines of image drilling column charts is easily affected by image quality, detection algorithms facing complex detection tasks and noise, resulting in inaccurate and incomplete detection in the final result; for the merging and refinement of the detected straight line clusters, the commonly used distance-based merging method relies on the adjustment of the threshold and has low efficiency. The present invention is aimed at the detection of frame lines of drilling column charts. On the basis of completing image preprocessing (tilt correction, grayscale and binarization), the image is first corroded and then expanded to eliminate the influence of noise and high-density text in the image on frame line detection; based on the topological adjacent and connected relationship of the detected straight line clusters, the straight line clusters belonging to the same frame line are clustered, and the merging and refinement results are output; finally, through the organizational law of the drilling column chart frame line, the topological constraint rules are established, the frame line is corrected, and the final result is obtained.
[0028] In the face of the detection task of complex table frame lines in the image drilling column chart, the present invention optimizes the detection of complex table frame lines through preprocessing and postprocessing based on the image domain LSD detection algorithm. By corroding and dilating the input image, noise and text are removed to weaken the influence of noise; based on the topological adjacent and connected relationships, the straight line clusters are clustered, merged and refined to achieve accurate extraction of straight lines; finally, combined with the organizational rules of the table frame lines in the drilling column chart, the inaccurate and missing frame lines in the detection results are corrected.
[0029] Faced with the extraction of complex tables in the drilling column chart, the LSD algorithm based on the image domain of the present invention has more complete and accurate detection results than the algorithm based on the transform domain, but the LSD algorithm has weak noise resistance. Therefore, the present invention first pre-processes the input image, sets an adaptive threshold by the image size to first corrode and then expand, removes noise, text, patterns, etc. in the image, and avoids the influence of noise on the detection of frame lines. Then, the processed frame line image is detected by the LSD algorithm to obtain the detection results, and then the detection results are merged, refined and corrected. The straight line clusters of frame lines belonging to the same height or horizontal position are clustered according to the topological adjacent or connected relationship within the cluster, and then merged and refined. Finally, topological constraints are established in combination with the organizational rules of the table frame lines, and some frame lines that are not fully detected are corrected and supplemented.
[0030] like Figure 1 As shown, an embodiment of the present invention discloses a method for extracting image frame lines of a drilling histogram, comprising the following steps: Step 100, input the drilling histogram in image format, wherein the image format includes jpg, png or tif; Step 200, input image preprocessing; Step 300, frame line detection and line cluster merging and refinement; Step 400, merging and refining the result straight lines for post-processing; Step 500, output is a vector file of the horizontal and vertical frame lines in the table frame line in the image drilling histogram, which is stored in the coordinates of the nodes at both ends of the line in the Esri Shapefile file coordinate system, and the storage format is as follows: ,Finish.
[0031] Wherein, step 200 specifically includes: Step 201, read the drilling histogram image matrix Image, and obtain the height H and width W of the matrix Image; Step 202, using OpenCV to perform grayscale and adaptive threshold binarization operations on the input image Image, and output a binary image Binary_img; Step 203, according to the height H and width W, respectively set the adaptive size rectangular convolution kernel, the height rectangle Kernel1, the size is height H / 20, width 1, where 1 represents 1 pixel; the width rectangle Kernel2, the size is height 1, where 1 represents 1 pixel, width W / 20; respectively use Kernel1 and Kernel2 to corrode Binary_img using OpenCV first and then dilate to obtain the horizontal frame line image Horizontal_img and the vertical frame line image Vertical_img; Step 204 , vertically project the vertical frame line image Vertical_img to obtain a pixel line width set Line_width={w1,w2,w3,…,wn}, and calculate the set arithmetic mean w_mean; the input image preprocessing is completed, and the process proceeds to step 300 .
[0032] Specifically, step 300 includes performing the straight line detection and straight line cluster merging and thinning process in two parts: horizontal frame lines and vertical frame lines, and extracting and processing the horizontal frame lines.
[0033] Wherein, step 300 includes, Step 301, read the horizontal frame line image Horizontal_img, use Opencv's LSD line detection algorithm to detect the frame lines in Horizontal_img, and obtain preliminary detection results, horizontal frame line cluster Horline_set, each straight line in the cluster is expressed and stored in the form of the coordinates of the two end points, Step 302, traverse all horizontal lines in Horline_set, and arrange the lines in the set in ascending order according to height y; proceed to step 303 to cluster the line clusters at the same height of Horline_set based on topological adjacency or connection relationship; Step 303, if there are still unclassified lines in Horline_set, go to step 3031; otherwise go to step 304; Among them, step 3031, traverse the sorted Horline_set, initialize all_hor_class to store all heights of line clusters and single height line cluster hor_class, add hor_class to all_hor_class, add the first line line1=[(x1,y1),(x2,y1)] to hor_class, and mark y, y=y1, then delete line1 from Horline_set; then enter step 3032; Step 3032, continue to traverse the lines in the set, read the next line line2 = [(x3, y2), (x4, y2)], if the difference between the height y2 of line2 and the mark y, |y-y2|≤1, then add line2 to hor_class, delete line2 from Horline_set, update the mark y = y2, and go to step 303, otherwise go to step 3031; Step 304, traverse and cluster all the straight line cluster sets all_hor_class, if there are still straight line clusters that have not been traversed, go to step 3041, until all horizontal straight line clusters are processed, and then go to step 305; Step 3041, read the line cluster class hor_class, initialize the x coordinate range set xrange_set, the y coordinate set y_set, and the merged line x coordinate set xrange_merge_set; proceed to step 3042; Step 3042, traverse all the lines in hor_class, record the line linei=[(xi1,yi),(xi2,yi)], i is the index of the line in the set, i=1, 2, 3, ..., n, add yi to y_set, add [xi1, xi2] to xrange_set, delete the traversed hor_class, and go to step 3043; Step 3043, read y_set, calculate the arithmetic mean of all elements in y_set, record it as y_mean, and go to step 3044; Step 3044, traverse x_range_set, initialize the x coordinate range of the straight line x_range = [x11, x12], and add xrange_merge_set, and enter step 3045; Step 3045, continue traversal to obtain the x - coordinate range x_range = [x21, x22]. If x21 ∈ [x11, x12] and x22 > x12, then update x12 = x22; if x22 < x12, do not update. Delete the lines that have completed traversal. If there are still x - coordinate ranges that have not been traversed, enter Step 3044; otherwise, enter Step 3046; Step 3046, traverse the merged x - coordinate range xrange_merge_set, with internal element xrange_mergei = [xi1, xi2]. Output the straight line [(xi1, y_mean), (xi2, y_mean)] and add it to the set mergeline_set; enter Step 304; Step 305, process the vertical bounding - box line detection result. Read the vertical bounding - box image Vertical_img, and use the LSD straight - line detection algorithm in Opencv to detect the bounding - box lines in Vertical_img to obtain the preliminary detection result, the vertical - line cluster Vertical_set. Each straight line in the cluster is expressed and stored in the form of the coordinates of its two end - points; then enter Step 306; Step 306, traverse all horizontal lines in Verline_set, and sort the lines in the set in ascending order according to the horizontal position x; enter Step 307, and cluster the straight - line clusters at the same height in Verline_set based on the topological adjacency or connection relationship; Step 307, if there are still unclassified lines in Verline_set, enter Step 3071; otherwise, enter Step 308; Among them, in Step 3071, traverse the sorted Verline_set, initialize all straight - line cluster classes all_ver_class, the straight - line cluster class ver_class, add ver_class to all_ver_class, add the first straight line line1 = [(x1, y1), (x1, y2)] to ver_class, and mark x, x = x1, then delete line1 from Verline_set; then enter Step 3032; Step 3072, continue to traverse the lines in the set, read the next straight line line2 = [(x2, y3), (x2, y4)]. If the difference between the height y2 of line2 and the marked y, |x - x2| ≤ 1, then add line2 to ver_class, delete line2 from Verline_set, update the marked x = x2, and enter Step 308; otherwise, enter Step 3071; Step 308: Traverse all the line cluster classes in the all_ver_class set after clustering. If there are still line cluster classes that have not been traversed completely, go to Step 3081 until all line cluster classes are processed, and then go to Step 400; Among them, in Step 3081, read the line cluster class ver_class, initialize the y - coordinate range set yrange_set, the x - coordinate set x_set, and the merged line y - coordinate set yrange_merge_set; then go to Step 3082; Step 3082: Traverse all the lines in ver_class. Denote the line linei = [(xi, yi1), (xi, yi2)], where i is the index of the line in the set, and i = 1, 2, 3, …, n. Add xi to x_set, add [yi1, yi2] to yrange_set, delete the traversed ver_class, and then go to Step 3043; Step 3083: Read x_set, calculate the arithmetic mean of all elements in x_set, denoted as x_mean, and then go to Step 3084; Step 3084: Traverse y_range_set, initialize the line y - coordinate range y_range = [y11, y12], and add it to yrange_merge_set, then go to Step 3085; Step 3085: Continue to traverse to get the y - coordinate range y_range = [y21, y22]. If y21 ∈ [y11, y12] and y22 > y12, then update y12 = y22; if y22 < y12, do not update. Delete the lines that have been traversed. If there are still y - coordinate ranges that have not been traversed, go to Step 3084; otherwise, go to Step 3086; Step 3086: Traverse the merged y - coordinate range yrange_merge_set, where the internal element yrange_mergei = [yi1, yi2]. Output the line [(x_mean, yi1), (x_mean, yi2)], and add it to the mergeline_set; then go to Step 308.
[0034] Among them, Step 400 includes: Step 401: Read the horizontal and vertical frame line sets Hor_set and Ver_set obtained after merging and refinement, and then go to Step 402; Step 402, initialize the horizontal frame line ordinate set Hory_set, the vertical frame line abscissa set Verx_set, traverse the ordinate y of the straight line in Hor_set and add it to Hory_set, traverse the abscissa x of the straight line in Ver_set and add it to Verx_set, and arrange them in ascending order to obtain Hory_set = {y1, y2, ..., yn} and Verx_set = {x1, x2, ..., xn}; proceed to step 403; Step 403, traverse all horizontal frame lines in Hor_set, read the straight line hor_linei = [(xi1, yi), (xi2, yi)], where i = 1, 2, 3, ..., n, and get the horizontal coordinates xi1 and xi2 of the two end points of the straight line. If xi1∈Verx_set, no adjustment is made, and the same is true for xi2, otherwise, proceed to step 404; Step 404, respectively calculate the absolute value of the difference between xi1 and all x coordinates in Verx_set, and obtain the absolute minimum value D_min and its corresponding x coordinate xmin, and determine the size relationship between xmin and the set threshold t=3*w_mean. If D_min≤t, modify xi1=xmin, otherwise modify xi1=xmin+1; after traversing and adjusting the horizontal frame line in Hor_set, enter step 405; Step 405, traverse all vertical frame lines in Ver_set, read the straight line ver_linei=[(xi,yi1),(xi,yi2)], and obtain the vertical range of the straight line [yi1,yi2]. If yi1∈Hory_set, no adjustment is made, and the same is true for yi2. Otherwise, go to step 406; Step 406, respectively calculate the absolute value of the difference between yi1 and all x coordinates in Hory_set, and obtain the absolute minimum value D_min and its corresponding y coordinate ymin, and determine the size relationship between ymin and the set threshold t=3*w_mean. If D_min≤t, modify yi1=ymin, otherwise modify yi1=ymin+1; until the vertical frame lines in Ver_set are traversed and adjusted, enter step 407; Step 407, obtain the adjusted horizontal frame line Hor_set and vertical frame line Ver_set, arrange them in ascending order according to the height y coordinate and the horizontal position x coordinate, and proceed to step 408; Step 408, traverse all the lines in Ver_set and classify them according to the x-coordinates of the vertical lines to obtain Ver_x_class, where the x-coordinates of the lines in each class are the same, and then proceed to step 409; Step 409, traverse all classes Ver_class in Ver_x_class, if the class length is equal to 1, no operation is performed, otherwise go to step 410; Step 410, traverse all the lines in the class, record the x coordinate x0 of the current class line, and the y coordinates of the upper and lower endpoints of all the lines, obtain the y coordinate set y_class_set={y1,y2,y3,…,yn}, and go to step 411; Step 411, take the maximum value y_max and the minimum value y_min in y_class_set, and obtain the straight line line=[(x0,y_min),(x0,y_max)], delete all the straight lines in Ver_class in Ver_set, and add line until all classes are traversed.
[0035] The present invention also provides an image frame line extraction device for a drilling bar graph, comprising a memory, a control processor, and a computer program stored in the memory and executable on the control processor. The control processor executes the program to implement the image frame line extraction method for the drilling bar graph as described above.
[0036] The present invention also provides a control system, comprising the image frame line extraction device of the drilling column chart as described above.
[0037] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the image frame line extraction method of the drilling column chart as described above.
[0038] Although the above methods are illustrated and described as a series of actions for simplicity of explanation, it should be understood and appreciated that these methods are not limited by the order of the actions, because according to one or more embodiments, some actions may occur in different orders and / or concurrently with other actions from the illustrations and descriptions herein or not illustrated and described herein but understandable to those skilled in the art. It will be further appreciated by those skilled in the art that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or a combination of the two. To clearly explain this interchangeability of hardware and software, various illustrative components, frames, modules, circuits, and steps are generally described in the form of their functionality above. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. The technical staff can implement the described functionality in different ways for each specific application, but such implementation decisions should not be interpreted as resulting in a departure from the scope of the present invention. The various illustrative logic blocks, modules, and circuits described in conjunction with the embodiments disclosed herein may be implemented or executed with a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor may be a microprocessor, but in an alternative, the processor may be any conventional processor, a battery compartment control board, a micro-battery compartment control board, or a state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors in cooperation with a DSP core, or any other such configuration. The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read and write information from / to the storage medium. In an alternative, the storage medium may be integrated into the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and the storage medium may reside in a user terminal as discrete components. In one or more exemplary embodiments, the functions described may be implemented in hardware, software, firmware, or any combination thereof. If implemented as a computer program product in software, each function may be stored on a computer-readable medium or transmitted therefrom as one or more instructions or codes.Computer-readable media include both computer storage media and communication media, including any media that facilitates a computer program to be transferred from one place to another. Storage media can be any available media that can be accessed by a computer. As an example and not limitation, such computer-readable media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other media that can be used to carry or store the agreed program code in the form of instructions or data structures and can be accessed by a computer. Any connection is also properly referred to as computer-readable media. For example, if software is transmitted from a web site, a central control computer, or other remote sources using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwaves, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwaves are included in the definition of medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, wherein disk often reproduces data magnetically, while disc reproduces data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0039] Although the above methods are illustrated and described as a series of actions for simplicity of explanation, it should be understood and appreciated that these methods are not limited by the order of the actions, because according to one or more embodiments, some actions may occur in a different order and / or concurrently with other actions from those illustrated and described herein or not illustrated and described herein but understandable to those skilled in the art.
[0040] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technical personnel in this field can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any brief modifications, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. A method for extracting image frame lines of a drilling histogram, characterized in that: The following steps are involved: Step 100, input image format drilling histogram; Step 200, input image preprocessing; Step 300, frame line detection and line cluster merging and refinement; Step 400, merging and refining the result straight lines for post-processing; Step 500, outputting the vector file of the horizontal and vertical frame lines in the table frame lines in the image drilling histogram, and ending.
2. The method for extracting image frame lines of a drilling histogram according to claim 1, characterized in that: Step 200 specifically includes: Step 201, read the drilling histogram image matrix Image, and obtain the height H and width W of the matrix Image; Step 202, using OpenCV to perform grayscale and adaptive threshold binarization operations on the input image Image, and output a binary image Binary_img; Step 203, according to the height H and width W, set the adaptive size rectangular convolution kernels respectively, the height rectangle Kernel1, the size is height H / 20, width 1; the width rectangle Kernel2, the size is height 1, width W / 20; respectively use Kernel1 and Kernel2 to corrode Binary_img using OpenCV first and then expand to obtain the horizontal frame line image Horizontal_img and the vertical frame line image Vertical_img; Step 204 , vertically project the vertical frame line image Vertical_img to obtain a pixel line width set Line_width={w1,w2,w3,…,wn}, and calculate the set arithmetic mean w_mean; the input image preprocessing is completed, and the process proceeds to step 300 .
3. The method for extracting image frame lines of a drilling histogram according to claim 1 or 2, characterized in that: Specifically, step 300 includes performing the straight line detection and straight line cluster merging and thinning process in two parts: horizontal frame lines and vertical frame lines, and extracting and processing the horizontal frame lines.
4. The method for extracting image frame lines of a drilling histogram according to claim 3, characterized in that: Step 300 includes, Step 301, read the horizontal frame line image Horizontal_img, use Opencv's LSD line detection algorithm to detect the frame lines in Horizontal_img, and obtain preliminary detection results, horizontal frame line cluster Horline_set, each straight line in the cluster is expressed and stored in the form of the coordinates of both end points; Step 302, traverse all horizontal lines in Horline_set, and arrange the lines in the set in ascending order according to height y; proceed to step 303 to cluster the line clusters at the same height of Horline_set based on topological adjacency or connection relationship; Step 303, if there are still unclassified lines in Horline_set, go to step 3031; otherwise go to step 304; Among them, step 3031, traverse the sorted Horline_set, initialize all_hor_class to store all heights of line clusters and single height line cluster hor_class, add hor_class to all_hor_class, add the first line line1=[(x1,y1),(x2,y1)] to hor_class, and mark y, y=y1, then delete line1 from Horline_set; then enter step 3032; Step 3032, continue to traverse the lines in the set, read the next line line2 = [(x3, y2), (x4, y2)]. If the difference between the height y2 of line2 and the marked y, |y - y2| ≤ 1, then add line2 to hor_class, delete line2 from Horline_set, update the marked y = y2, and enter Step 303. Otherwise, enter Step 3031; Step 304, traverse all the line clusters all_hor_class after clustering. If there are still line clusters that have not been traversed, enter Step 3041 until all horizontal line clusters are processed, and then enter Step 305; Step 3041, read the line cluster hor_class, initialize the x - coordinate range set xrange_set, the y - coordinate set y_set, and the merged line x - coordinate set xrange_merge_set; enter Step 3042; Step 3042, traverse all the lines in hor_class. Denote the line linei = [(xi1, yi), (xi2, yi)], where i is the index of the line in the set, i = 1, 2, 3, …, n. Add yi to y_set, add [xi1, xi2] to xrange_set, delete the traversed hor_class, and enter Step 3043; Step 3043, read y_set, calculate the arithmetic mean of all elements in y_set, denoted as y_mean, and enter Step 3044; Step 3044, traverse x_range_set, initialize the line x - coordinate range x_range = [x11, x12], and add it to xrange_merge_set, then enter Step 3045; Step 3045, continue to traverse, and get the x - coordinate range x_range = [x21, x22]. If x21 ∈ [x11, x12] and x22 > x12, then update x12 = x22. If x22 < x12, then do not update. Delete the lines that have completed traversal. If there are still x - coordinate ranges that have not been traversed, enter Step 3044. Otherwise, enter Step 3046; Step 3046, traverse the merged x - coordinate range xrange_merge_set, with internal element xrange_mergei = [xi1, xi2], output the line [(xi1, y_mean), (xi2, y_mean)], and add it to the set mergeline_set; enter Step 304; Step 305, process the vertical frame line detection result. Read the vertical frame line image Vertical_img, use the LSD line detection algorithm in Opencv to detect the frame lines in Vertical_img, and obtain the preliminary detection result, the vertical line cluster Vertical_set. Each line in the cluster is expressed and stored in the form of the coordinates of both ends; then enter Step 306; Step 306, traverse all horizontal lines in Verline_set, and arrange the lines in the set in ascending order according to the horizontal position x; proceed to step 307, cluster the line clusters at the same height of Verline_set based on the topological adjacent or connected relationship; Step 307, if there are still unclassified lines in Verline_set, go to step 3071; otherwise go to step 308; Among them, step 3071, traverse the sorted Verline_set, initialize all line cluster classes all_ver_class, line cluster class ver_class, and add ver_class to all_ver_class, and add the first line line1=[(x1,y1),(x1,y2)] to ver_class, and mark x, x=x1, and then delete line1 from Verline_set; then enter step 3032; Step 3072, continue to traverse the lines in the set, read the next line line2 = [(x2, y3), (x2, y4)], if the difference between the height y2 of line2 and the mark y, |x-x2|≤1, then add line2 to ver_class, delete line2 from Verline_set, update the mark x = x2, and go to step 308, otherwise go to step 3071; Step 308, traverse the clustering to complete all the line cluster sets all_ver_class, if there are still line clusters that have not been traversed, then go to step 3081, until all the line clusters are processed, then go to step 400; Among them, step 3081 reads the line cluster class ver_class, initializes the y coordinate range set yrange_set, the x coordinate set x_set, and the merged line y coordinate set yrange_merge_set; then proceeds to step 3082; Step 3082, traverse all lines in ver_class, record linei=[(xi,yi1),(xi,yi2)], i is the index of the line in the set, i=1, 2, 3, ..., n, add xi to x_set, add [yi1, yi2] to yrange_set, delete the traversed ver_class, and go to step 3043; Step 3083, read x_set, calculate the arithmetic mean of all elements in x_set, record it as x_mean, and go to step 3084; Step 3084, traverse y_range_set, initialize the straight line y coordinate range y_range = [y11, y12], and add yrange_merge_set, and enter step 3085; Step 3085: Continue traversal to obtain the y - coordinate range y_range = [y21, y22]. If y21 ∈ [y11, y12] and y22 > y12, then update y12 = y22; if y22 < y12, then do not update. Delete the lines that have completed traversal. If there are still y - coordinate ranges that have not completed traversal, go to Step 3084; otherwise, go to Step 3086. Step 3086: Traverse the merged y - coordinate range yrange_merge_set, where the internal element yrange_mergei = [yi1, yi2]. Output the line [(x_mean, yi1), (x_mean, yi2)] and add it to the set mergeline_set. Enter Step 308.
5. The method for extracting image frame lines of a drilling histogram according to claim 4, characterized in that: The said Step 400 includes: Step 401: Read the horizontal and vertical box - line sets Hor_set and Ver_set obtained after merging and refinement, and enter Step 402. Step 402: Initialize the set Hory_set of the vertical coordinates of the horizontal box - lines and the set Verx_set of the horizontal coordinates of the vertical box - lines. Traverse the vertical coordinates y of the lines in Hor_set and add them to Hory_set, and traverse the horizontal coordinates x of the lines in Ver_set and add them to Verx_set. Both are sorted in ascending order to obtain Hory_set = {y1, y2,..., yn} and Verx_set = {x1, x2,..., xn}. Enter Step 403. Step 403: Traverse all the horizontal box - lines in Hor_set, and read the line hor_linei = [(xi1, yi), (xi2, yi)], where i = 1, 2, 3,..., n, to obtain the horizontal coordinates xi1 and xi2 of the two endpoints of the line. If xi1 ∈ Verx_set, then no adjustment is made, and the same applies to xi2; otherwise, enter Step 404. Step 404: Calculate the absolute values of the differences between xi1 and all the x - coordinates in Verx_set respectively, and obtain the minimum absolute value D_min and its corresponding x - coordinate xmin. Judge the size relationship between xmin and the set threshold t = 3 * w_mean. If D_min ≤ t, then modify xi1 = xmin; otherwise, modify xi1 = xmin + 1. After traversing and adjusting the horizontal box - lines in Hor_set, enter Step 405. Step 405: Traverse all the vertical box - lines in Ver_set, and read the line ver_linei = [(xi, yi1), (xi, yi2)] to obtain the vertical range [yi1, yi2] of the line. If yi1 ∈ Hory_set, then no adjustment is made, and the same applies to yi2; otherwise, enter Step 406. Step 406, respectively calculate the absolute value of the difference between yi1 and all x coordinates in Hory_set, and obtain the absolute minimum value D_min and its corresponding y coordinate ymin, and determine the size relationship between ymin and the set threshold t=3*w_mean. If D_min≤t, modify yi1=ymin, otherwise modify yi1=ymin+1; until the vertical frame lines in Ver_set are traversed and adjusted, enter step 407; Step 407, obtain the adjusted horizontal frame line Hor_set and vertical frame line Ver_set, arrange them in ascending order according to the height y coordinate and the horizontal position x coordinate, and proceed to step 408; Step 408, traverse all the lines in Ver_set and classify them according to the x-coordinates of the vertical lines to obtain Ver_x_class, where the x-coordinates of the lines in each class are the same, and then proceed to step 409; Step 409, traverse all classes Ver_class in Ver_x_class, if the class length is equal to 1, no operation is performed, otherwise go to step 410; Step 410, traverse all the lines in the class, record the x coordinate x0 of the current class line, and the y coordinates of the upper and lower endpoints of all the lines, obtain the y coordinate set y_class_set={y1,y2,y3,…,yn}, and go to step 411; Step 411, take the maximum value y_max and the minimum value y_min in y_class_set, and obtain the straight line line=[(x0,y_min),(x0,y_max)], delete all the straight lines in Ver_class in Ver_set, and add line until all classes are traversed.
6. A method for extracting image frame lines of a drilling histogram according to any one of claims 1, 2, 4 or 5, characterized in that: The image format in step 100 includes jpg, png or tif.
7. A method for extracting image frame lines of a drilling histogram according to any one of claims 1, 2, 4 or 5, characterized in that: In step 500, the output is a vector file of the horizontal and vertical frame lines in the table frame line in the image drilling histogram, which is stored in the coordinates of the nodes at both ends of the line in the Esri Shapefile file coordinate system, and the storage format is as follows: 。 8. A device for extracting image frame lines of a drilling histogram, characterized in that: The invention comprises a memory, a control processor and a computer program stored in the memory and executable on the control processor, wherein the control processor executes the program to implement the image frame line extraction method of the drilling column chart as described in any one of claims 1 to 7.
9. A control system, characterized in that: The invention comprises the image frame line extraction device of the drilling column chart as described in claim 8.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to implement the image frame line extraction method of the drilling column chart according to any one of claims 1-7.
Citation Information
Patent Citations
Detection and identification method oriented to image tablet shot by mobile terminal
CN106156761A
Building contour identification method based on space topology relation constraint and end point
CN107292238A
Efficient drilling histogram information automatic extraction method
CN110826393A
Image table structure identification method and system, terminal and storage medium
CN112036232A
Hard-tipped pen calligraphy matts slice image extraction method, system and device
CN113901936A
