CN114998428B - A polyline/curve data extraction system and method based on image processing - Google Patents
A polyline/curve data extraction system and method based on image processing Download PDFInfo
- Publication number
- CN114998428B CN114998428B CN202210390591.2A CN202210390591A CN114998428B CN 114998428 B CN114998428 B CN 114998428B CN 202210390591 A CN202210390591 A CN 202210390591A CN 114998428 B CN114998428 B CN 114998428B
- Authority
- CN
- China
- Prior art keywords
- value
- list
- result
- image
- curve
- 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.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/70—Determining position or orientation of objects or cameras
- G06T7/73—Determining position or orientation of objects or cameras using feature-based methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V30/00—Character recognition; Recognising digital ink; Document-oriented image-based pattern recognition
- G06V30/40—Document-oriented image-based pattern recognition
- G06V30/41—Analysis of document content
- G06V30/413—Classification of content, e.g. text, photographs or tables
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; 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/20004—Adaptive image processing
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Artificial Intelligence (AREA)
- Multimedia (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a broken line/curve data extraction system and method based on image processing. The method comprises the steps of 1 searching frames of a curve/line graph, 2 preprocessing curve/line graph, 3 searching coordinate axis digital contours, 4 identifying x and y coordinate axis numbers, 5 calculating the ratio of the x to y coordinate axes, and 6 searching and obtaining y values. The invention can cope with more special situations. The invention can reconstruct and sample complex curves/line graphs with various background colors, grids and large curve slopes, and acquire the coordinate information of the pictures, thereby multiplexing the data in the pictures. The invention does not need to input parameters such as coordinates of an origin, only needs to input pictures, reduces manual operation, and can cope with more special situations compared with the traditional method.
Description
Technical Field
The invention relates to the field of digital image information extraction (Image Information Acquisition), in particular to curve/polyline picture information extraction, which recycles trend and numerical values of chart information and reconstructs the chart information. A polyline/curve data extraction system and method based on image processing are provided.
Background
With the development of basic science+, the process information involved in various scientific research activities and production and living activities tends to be complex. In the internet, medical, biological, chemical, traffic, etc. industries, a single item often covers data volumes of over ten thousand levels. To present data to the audience in a clearer manner, visualization methods have become an integral part. The curve and line graph stands out from a data graph by virtue of the expression capability of data trend and simple and easy-to-understand expression mode. Nowadays, the curve and the line graph are widely used in scenes such as stocks, electrocardiograms, simulation software, academic articles and the like.
Meanwhile, the exponentially growing data volume brings great difficulty to fine data analysis operations such as process reproduction, data mining and the like. For some studies, where the volume of data is large or where time is relatively long, it is clearly impractical to obtain detailed study data. If a data chart can be used as a data carrier, the data can be accurately recorded, and the difficulty of data storage and acquisition is certainly reduced. At the same time, a complete set of graph data extraction algorithms is needed as support.
At present, a lot of common curve graph data point extraction tools exist. There are ginput in Matlab, push_back in opencv, etc. for example, functions, webPlotDigitizer and Graphixy, etc. for example, software. They all have a good effect in graph data extraction work. However, the aforementioned tools have some problematic issues such as the need to manually input the starting point of the image and the maximum values of the x and y axes.
Because the formats of the obtained pictures are complex and various, and the situation of the coordinate axes on the pictures is not definite, the following difficulties are caused in obtaining the data information from the curve/line graph:
(1) Lacking batch processing means, the existing methods all require manual input of the position of the origin of the graph in the picture and the maximum of the x, y axes, so that if the above method is used, the obtaining of the abscissa of the point from the broken line/graph requires a lot of manpower and has mechanical repeatability.
(2) The method has the advantages of low accuracy and weak universality, pictures obtained by people in daily life are often different in variety, and the problems of different background colors, thickness of curves, boundaries of frames and the like are solved, and the existing method has poor picture processing effect.
Based on the above problems, the present invention provides a method for extracting polyline/curve data based on image processing and digital recognition, so as to solve the above-mentioned difficulties.
1. The method for automatically identifying the frame and the maximum value of the coordinates of the graph is provided;
2. the preprocessing method for the image is provided, so that interference of the background of the curve on recognition can be eliminated;
3. A method for reducing large slope curve errors based on graph trend is provided.
Disclosure of Invention
The invention aims at overcoming the defects of the prior art and provides a broken line/curve data extraction system and method based on image processing.
The invention solves the technical problems as follows:
a broken line/curve data extraction system based on image processing comprises a searching module of a curve/broken line frame, an image preprocessing module, a coordinate axis digital contour searching module, a coordinate axis digital identification module, a coordinate axis proportion calculating module and a y value searching module;
And the searching module of the curve/line graph frame is used for searching the edge contour of the original image, and selecting a required curve/line graph frame from a result returned by searching the edge contour.
The image preprocessing module is used for preprocessing a given curve/broken line image img, firstly carrying out gray level conversion on the image, then carrying out self-adaptive thresholding on the gray level image, and improving the precision of the subsequent digital contour searching
Finding out the range of the coordinate axis number on the broken line picture img, inputting the preprocessed picture, finding out all the outlines on the picture by using the outline finding function, screening out the outline really containing the number, and recording the corresponding coordinates of the digital area into a list to be the input of the next step
And the coordinate axis number identification module is used for obtaining the left and right boundaries and the upper and lower boundaries of the curve area in the curve/line diagram border searching module, separately identifying the numbers on the X and Y axes, taking the number position list in the coordinate axis number outline searching module as input, carrying out number identification on the designated area, and taking the identified number as a fifth dimension element of the list, which is also the input of the coordinate axis proportion calculation module.
The coordinate axis proportion calculation module is used for obtaining the corresponding proportion of the horizontal direction and the vertical direction according to the digital position and the identification result obtained by the coordinate axis digital contour searching module and the coordinate axis digital identification module;
And the y value searching module is used for searching the coordinates of the pixel points on the corresponding curve according to the x value to be searched, and converting the coordinate axis proportion obtained by the coordinate axis proportion calculating module into the true value of y.
Further, the searching module of the curve/line graph frame is realized by performing canny edge detection on an input image to obtain a two-dimensional pixel vector v1 containing a clear curve outline of the input image and an edge shape h x w of the input image, transposing the two-dimensional pixel vector v1 to obtain a transposed vector v2, and respectively performing row searching and column searching on the two-dimensional pixel vector v1 and the transposed vector v2, wherein the binarized image generates a mutation of a pixel point accumulation sum at the left and right sides of a starting point and an ending point of the line graph, and based on the mutation, accurate frame positioning is realized on the line graph/curve graph to obtain x_boundary_min, x_boundary_max, y_boundary_min and y_boundary_max;
the image preprocessing module is used for carrying out gray processing on an input image;
The coordinate axis digital contour searching module is used for carrying out contour searching on the preprocessed image, finding all contours and storing the contours into a list, traversing and returning the minimum positive rectangle information containing input information, namely, storing the left upper corner coordinates of a rectangular frame of the minimum positive rectangle and the width and height of the rectangle into the list;
Performing text recognition on the x list and the y list by pytesserac, performing rescreening treatment on the recognition result, storing the digital result obtained after screening into a fifth dimension of the x list and the y list respectively, and finally sorting the lists in ascending order by taking the fifth dimension as a keyword to obtain two new lists, namely result_x and result_y;
The coordinate axis proportion calculation module is used for respectively carrying out coordinate axis proportion calculation on the adjacency of the result_x and result_y lists;
And the y value searching module is used for inputting the x value to be searched and solving the true value of the x value in the pixel coordinate system.
A broken line/curve data extraction method based on image processing comprises the following steps:
Step (1), searching the frame of the curve/line diagram;
Step (2), preprocessing the image;
Step (3), searching the digital outline of the coordinate axis;
Step (4), identifying the coordinate axis number;
step (5), calculating the proportion of coordinate axes;
And (6) searching a true y value of the x value in a coordinate system through the input x value.
Further, the step (1) is specifically implemented as follows:
Applying canny edge detection to an input image to obtain a two-dimensional pixel vector v1 containing a clear curve outline of the input image and an edge shape h x w of the input image;
transpose the two-dimensional pixel vector v1 to obtain a transposed vector v2;
Performing row search and column search on the two-dimensional pixel vector v1 and the transposed vector v2 respectively;
Because the binarized image has the abrupt change of the pixel point accumulation sum at the left and right sides of the starting point and the ending point of the folding line, the accurate frame positioning is realized on the original image of the folding line/curve image based on the abrupt change, and the x_boundary_min, the x_boundary_max, the y_boundary_min and the y_boundary_max are obtained.
Further, the step (2) is specifically implemented as follows:
gray processing is carried out on the input image, wherein the values of three channels of the input image are all changed into the same value, and the value is divided by 3 by three channel pixel addition;
And carrying out self-adaptive binarization on the image after gray level processing, and setting 255 to the single-channel pixel value of the corresponding gray level image of the image with the value larger than the self-adaptive threshold value to obtain the preprocessed image.
Further, the step (3) is specifically implemented as follows:
and (3) carrying out contour searching on the preprocessed image obtained in the step (2), finding all contours, storing the contours into a list, traversing and returning the minimum positive rectangle information containing input information, namely storing the left upper corner coordinates of a rectangular frame of the minimum positive rectangle and the width and height of the rectangle into the list, screening all the minimum positive rectangles in the list, and storing the screening result into a new list a.
Further, the new list a may have two digits, and the new list a needs to be further judged because the division distance is further divided into two digits, if the distance between the two rectangular frames is smaller than the set threshold value, the two rectangular frames are combined to obtain the final required list x and list y, and the specific combination formula is as follows:
a[i]=[a[x1][0],a[x1][1],a[x2][0]-a[x1][0],max(a[x1][3],a[x2][3])] (1)
Wherein a [ x1] [0] represents the upper left corner x, a [ x1] [1] represents the upper left corner y, a [ x2] [0] -a [ x1] [0] represents the length of the rectangle, and max (a [ x1] [3], a [ x2] [3 ]) represents the width of the rectangle;
Specifically, according to the x_boundary_min and y_boundary_max obtained in the step (1), a rectangular box a [ i ] [0] < x_boundary_min in the list a is stored in a list Y which is the number on the Y axis, and a [ i ] [1] > y_boundary_max in the list a is stored in a list Y which is the number found on the X axis.
Further, the step (4) is specifically implemented as follows:
performing text recognition on the two lists x and y subjected to the merging treatment by using pytesserac respectively;
Screening the identification result, and storing the digital result obtained after screening into a fifth dimension of a list x and a list y respectively, wherein the list is in the following format:
list=[x1,y1,x2,y2,num] (2)
And finally, sorting the lists in ascending order by taking the fifth dimension as a keyword to obtain two new lists, namely result_x and result_y.
Further, the filtering process is as follows, since the character recognition may recognize space and line feed error characters, it is necessary to filter each digital rectangular frame, filter the numbers in the rectangular frame, combine the numbers, convert the data in the form of characters into integer type data, and store the integer type data in the fifth dimension of the list result_x and the list result_y respectively.
Further, the specific implementation process of the step (5) is as follows:
And respectively carrying out coordinate axis proportion calculation on adjacent elements in the list result_x and the list result_y, wherein the coordinate axis proportion calculation of the result_x list is to sequentially subtract the fifth dimension elements of the adjacent two elements in the result_x list and traverse the elements in the result_x list:
d=result_x[i+1][4]-result_x[i][4] (3)
the method comprises the steps of (1) setting a value d of a dictionary as a keyword, setting a value s of the dictionary as a list, recording the number of the rectangle frames, i in the example, and performing the same operation on a result_y list to finally obtain a dictionary my_direct_x and my_direct_y, searching the number of elements in the list according to the keyword, namely the d value, in the two dictionaries, accumulating the d value of the corresponding element in the my_direct_x [ Delta_x ] to obtain the Delta_sum_x, wherein i is greater than or equal to 0, and the value d of the corresponding element in the my_direct_x [ Delta_x ] is calculated by the same operation, and the proportion formula of the last coordinate axis is as follows:
x_ratio=Delta_sum_x/len(my_dictx_x[Delta_x]) (4)
The method comprises the steps of storing a value of a dictionary, wherein Delta_x represents a keyword with the maximum list length corresponding to the value of the value in the dictionary my_direct_x, x_ratio represents how many pixels the real length is in a pixel picture on a coordinate axis, and Delta_sum_x represents a value for accumulating differences between left boundaries of corresponding adjacent rectangular frames with the value of the keyword of the dictionary Delta_x.
Further, the specific implementation process of the step (6) is as follows:
Inputting the X value to be searched, drawing a reference point on the X axis, taking a subscript m from my_subject_x [ Delta_x ] and taking the coordinate and the truly recognized number from result_x [ m ], wherein the abscissa X symbol = (result_x [ m ] [0] +result_x [ m ] [2 ])/2 on the pixel point, and the true value standard_num_x=result [ m ] [4] of the reference point, wherein the abscissa of the input X value in the pixel coordinate system is:
x′=xsymbol+(x-standard_num_x)*x_ratio (5)
by traversing the pixels in the image, the background color in the image is removed, and the gray image pixel value is set to 255, namely white;
For the abscissa x ', x_int=int (x'), x_float=x '-x_int, for finding the corresponding Y value of the corresponding abscissa x', color finding is needed to be carried out through a color finding function to obtain the main color of the curve, namely line_color, then a method of traversing the row of pixels of x_int is adopted, when traversing from top to bottom to the first pixel point, the value of the line_color is the upper boundary of the Y to be found, and similarly traversing from bottom to top to the first pixel point, the value of the line_color is the lower boundary of the Y to be found, namely the median value of the Y to be found is the Y value corresponding to the x_int to be found; for the x_float part, searching the slope, finding the adjacent slope of x_int, multiplying the slope by x_float to form the ordinate of the corresponding pixel point on the final Y-axis, and for the Y-axis, a reference point is needed, which needs to be correctly identified, a subscript m is needed to be taken out from my_direct_y [ Delta_y ], the coordinate and the truly identified number are taken out from result_y [ m ], and the ordinate on the pixel point is needed
Reference point true value:
standard_num_y=result_y[m][4](7)
So for the input x value its true value in the pixel coordinate system is:
xresult=standard_num_y+(ysymbol-(kx*x_float))/y_ratio (8)
x result is the true value of the y-axis that needs to be found.
The invention has the following beneficial effects:
The invention provides a broken line/curve picture data extraction method based on image processing and digital identification. Although the existing open source software can realize the extraction of coordinate values, parameters such as coordinates of an origin are required to be manually input, and batch processing cannot be performed, so that the invention solves the defects that a great deal of manpower is required for extracting ordinary coordinate information of a daily map and the system has mechanical repeatability by matching with modules such as image processing and digital identification and the like and by matching with an image batch processing function. Meanwhile, the traditional software has higher requirements on pictures and has no universality, and for pictures containing grids and background colors and having large curve slopes, better result extraction cannot be realized, even corresponding coordinate information cannot be extracted, so that the invention carries out gray level conversion on input pictures, then carries out self-adaptive thresholding on gray level pictures, eliminates interference of factors such as the backgrounds, the grids and the like, and realizes coordinate extraction of complex fold lines/curves with various background colors, containing the grids, large curve slopes and the like by matching with a coordinate axis digital contour searching module and a final module for optimizing results according to the trend gradient of the graph. The method has the advantages that the method can realize batch processing, does not need manpower, and can cope with the complex curves/broken lines of multiple types, and compared with the traditional method and software, the method has the advantages of greatly improving the simplicity, convenience, accuracy and universality.
Drawings
FIG. 1 is a diagram of the result of finding the image frame;
FIG. 2 is a graph showing the result after image preprocessing;
FIG. 3 is a complete flow chart of the present invention;
Detailed Description
The detailed parameters of the present invention are further described in detail below with reference to the drawings and examples.
A complete flow chart of the present invention is shown in fig. 3. The invention provides a broken line/curve data extraction method based on image processing and digital identification.
Step one, searching the frame of the curve/line graph
The method comprises the following steps of 1, image graying, 2, denoising, 3, solving gradient amplitude and direction by using a sobel operator, 4, non-maximum value suppression, and 5, detecting and connecting edges by using a double-threshold algorithm. By adjusting the range of the double threshold to a suitable value, a two-dimensional pixel vector v (binary result) containing a sharp curve contour and an edge shape is obtained.
1-2, Searching an image frame, namely obtaining a vector v of h x w through canny edge detection, transposing v to obtain v2, and respectively carrying out row search and column search on v1 and v2, wherein the binarized image has abrupt change of pixel point accumulation sum (255 value quantity) at left and right sides of an image starting point and an image ending point, and based on the thought, accurate frame positioning is realized on a fold line/curve image original image, and a result is shown in figure 1.
Step two, preprocessing a given curve/broken line picture img
2-1, Carrying out gray processing on the picture by using cvtColor functions of an opencv library, and changing the values of three channels of the picture into the same value, wherein the value is obtained by dividing three channel pixel addition by 3.
2-2, Performing ADAPTIVE binarization on the image by using adaptiveThreshold () function of opencv library, setting single-channel pixel value of gray image to 255 for the gray image larger than the ADAPTIVE threshold, wherein adaptiveMethod parameter is set to ADAPTIVE_THRESH_ GAUSSIAN _C, blockSize parameter is set to 15, C is set to 4, the last ADAPTIVE binarization effect is the best, and the final processing effect is shown in figure 2.
Step three, searching coordinate axis digital contour
3-1, Searching the contours of the preprocessed image generated in the second step by using findContours functions of a opnecv library, and storing all the contours into a contours array;
3-2, traversing by boundingRect functions of an opencv library to return the minimum positive rectangle containing input information, storing the left upper corner coordinates of a rectangular frame and the width and height of the rectangle into a listing_ boxex, wherein the format of the listing is [ x, y, w, h ], x, y are respectively the abscissa of the left upper corner of the frame, and w, h are divided into the width and the height of the rectangular frame.
3-3. Since the rectangle found is not necessarily what we want, we need to filter it, we need x > x_boundary_min, y < y_boundary_max, and the value of w, h cannot be greater than 20 pixels, nor less than 8 pixels of the rectangle box, and store [ x, y, w, h ] satisfying the condition in the new list a
3-4 For list a, since the possible two digits are separated into two digits, it needs to be determined that if the distance between two rectangular frames is smaller than the set threshold, the two rectangular frames are combined by a [ i ] = [ a [ x1] [0], a [ x1] [1], a [ x2] [0] -a [ x1] [0], max (a [ x1] [3], a [ x2] [3 ]) (formula 1)
Step four, coordinate axis number identification
4-1. In the list a obtained in the previous step, the numbers on the X, Y axes are stored in a list, here we store the rectangular frames of the X, Y axes separately according to x_boundary_min and y_boundary_max, store the elements of x < x_boundary_min in the list a in boxx1, store the elements of y > y_boundary_max in the list a in boxx2, and facilitate the later identification of the numbers on the X, Y axes respectively
Digital identification for pictures establishing specific digital positions and contours, the pytessellact image to string function is used for the coordinates on the X, Y axes, respectively.
4-3, Processing the recognition result, namely obtaining a list l containing the recognition result through the step 4-2, extracting each result in the l, storing the result in the list temp, traversing the temp, discarding when non-character variables such as space and tab are encountered, splicing adjacent character variables, and finally obtaining character strings which are numerical values of X, Y axes obtained by recognition, performing type conversion, storing the recognized numbers in fifth dimensions of boxx and boxx respectively, and storing the formats of boxx and boxx2 as follows:
boxx=[x1,y1,x2,y2,num]
Wherein x1, y1 and x2, y2 are the coordinate positions of the upper left corner and the lower right corner of the rectangular frame, respectively, and num is the number identified in this step;
4-4. The list obtained in step 4-3 is sorted in ascending order by taking the fifth dimension as the key word to obtain two new lists, namely result_x and result_y, so that the proportion calculation of the coordinate axes in step five is facilitated
Step five, coordinate axis proportion calculation
5-1, Subtracting (identifying) the fifth dimension elements of the two adjacent elements of result_x and result_y, taking result_x as an example, traversing the elements in the result_x,
D=result_x [ i+1] [4] result_x [ i ] [4] (equation 2)
Taking the difference d as a keyword of the dictionary, setting values of the dictionary as a list, and recording what rectangular frame is, i in the example, to obtain two dictionaries of my_direct_x and my_direct_y;
5-2. Find the number of elements in the list of the two dictionaries obtained in 5-1 according to the key words, that is, the possible d values, because the recognition is sometimes difficult to avoid error, the method can avoid the problem that a small number of the characters are not recognized, taking the x axis as an example, the difference value of the digits on the coordinates is the key value corresponding to the longest value of the value list in my_direct_x, and the key value is recorded as Delta_x
5-3, Taking the x axis as an example on the basis of 5-2, accumulating d values of corresponding elements in the my_subject_x [ Delta_x ] to obtain Delta_sum_x, wherein the proportion formula of the last coordinate axis is as follows:
x_ratio=delta_sum_x/len (my_ dictx _x [ delta_x ]) (equation 3)
Step six, searching y value
6-1. Inputting the x value to be found, it is assumed that there is a reference point on the x-axis, which needs to be correctly identified, so that a subscript m needs to be taken from my_subject_x [ delta_x ], its coordinates and the truly identified number need to be taken from result_x [ m ], its pixel's abscissa x symbol = (result_x [ m ] [0] +result_x [ m ] [2 ])/2, and the reference point's true value standard_num_x=result [ m ] [4], so that for the input x, its abscissa in the pixel coordinate system is
X' =x symbol + (x-standard_num_x) ×ratio (formula 4)
Since x' may be a floating point number, to improve accuracy, the integer and fractional parts need to be calculated separately
6-2. Background color in the picture is removed by traversing the pixels in the image and its gray scale image pixel value is set to 255, i.e. white. For x ', x_int=int (x'), x_float=x '-x_int, for finding the corresponding y value of the corresponding x', we use a method of traversing the row of pixels of x_int to find the interval with the longest pixel length not being 255, which is the curve interval that we need to find last, and the median value is the y value corresponding to the x_int that we need to find
6-3 For the x_float portion, we find the slope near x_int, then multiply x_float by the slope to make up, form the ordinate of the corresponding pixel on the last y-axis.
6-4 Also requires a reference point for the y-axis, which needs to be correctly identified with the number, a subscript m from my_direct_y [ Detla _y ], its coordinates from result_y [ m ], and the true identified number, the ordinate on the pixel point
Y_symbol= (result_ym [0] +result_ym [2 ])/2 (equation 5)
True value of reference point
Standard_num_y=result_y [ m ] [4] (equation 6)
So for the input y its true value in the pixel coordinate system is:
x result=standard_num_y+(ysymbol-(kx x_float))/y_ratio (equation 7)
X result is the final value we need to find the true value of the y-axis.
Example 1:
Step one, searching the frame of the curve/line graph
And (3) applying canny edge detection to the original image p, and setting parameters threshold1 and threshold2 to be 50 and 50 respectively to obtain a two-dimensional pixel vector v1 (binary result) containing a clear curve outline and an edge shape h x w. And v1 is transposed to obtain v2, and v1 and v2 are respectively subjected to row search and column search, and because the binarized image has the mutation of pixel point accumulation sum (255-valued quantity) at the left and right sides of the starting point and the ending point of the image, based on the thought, accurate frame positioning is realized on the original image of the folded line/curve image, and x_boundary_min, x_boundary_max, y_boundary_min and y_boundary_max are obtained.
Example 2:
Step two, preprocessing module of picture
For the input image p, gray processing is carried out on the picture by using cvtColor functions of an opencv library, and the values of three channels of the picture are changed into the same value, wherein the value is obtained by dividing three channel pixel addition by 3. For the image after gray processing, the image is adaptively binarized by using adaptiveThreshold () function of opencv library, and for the image with gray image single channel pixel value larger than the ADAPTIVE threshold value, the gray image single channel pixel value is set to 255, wherein adaptiveMethod parameter is set to ADAPTIVE_THRESH_ GAUSSIAN _C, blockSize parameter is set to 15, C is set to 4, so as to obtain the image after preprocessing.
Example 3:
step three, coordinate axis digital contour searching module
Searching the contours of the preprocessed image generated in the second step by using findContours functions of an opencv library, storing all the contours into contours arrays, traversing the contours by using boundingRect functions of the opencv library to return the minimum positive rectangle containing input information, storing the left upper corner coordinates of a rectangular frame and the width and height of the rectangle into a binding_ boxex list, screening the rectangle, storing the screening result into a new list a, and judging that two digits possibly exist in the list a because the number of the two digits is divided into two digits due to the longer dividing distance, and combining the two rectangular frames if the distance between the two rectangular frames is smaller than a set threshold value.
Example 4:
identification module of coordinate axis numbers
And 3, respectively storing x and y for the result obtained in the step three, and respectively using a pytessellact image_to_string function for the x and y coordinates, wherein a config parameter is set to be 'psm 6-oem-ctessedit _char_ whitelist =0123456789', and the parameter 6 of the psm is to assume that the image is a unified text block, so that the accuracy of identifying the number is greatly improved. And processing the recognition result, and storing the obtained digital result in the fifth dimension boxx, boxx respectively, and now boxx, boxx are as follows:
boxx=[x1,y1,x2,y2,num]
finally, boxx and boxx2 are sorted in ascending order by taking the fifth dimension as a key word, and two new lists are obtained, namely result_x and result_y.
Example 5:
and carrying out standardized Euclidean distance calculation on the y-axis coordinate value identified by the algorithm and the actual y-axis coordinate value. Let the real label of data be y i', because the vertical axis coordinate scope is indefinite, calculate after label and the calculation result scale scaling, coefficient is k, and it is the line data y axis value maximum value, namely:
table 1 shows the results obtained on the line/graph for the method described in the text
| Line graph | Graph chart | Line/graph | |
| D value | 0.0952 | 0.0944 | 0.0966 |
。
Claims (10)
1. The broken line/curve data extraction system based on image processing is characterized by comprising a searching module of a curve/broken line frame, an image preprocessing module, a coordinate axis digital contour searching module, a coordinate axis digital identification module, a coordinate axis proportion calculating module and a y value searching module;
The searching module of the curve/line graph frame is realized by applying canny edge detection to an input image to obtain a two-dimensional pixel vector v1 containing a clear curve outline of the input image and an edge shape h x w of the input image, transposing the two-dimensional pixel vector v1 to obtain a transposed vector v2, and respectively carrying out row searching and column searching on the two-dimensional pixel vector v1 and the transposed vector v2, wherein the binarized image generates pixel point accumulation mutation at the left and right sides of a starting point and an ending point of the line graph, and based on the pixel point accumulation mutation, accurate frame positioning is realized on the line graph/curve graph image original graph to obtain x_boundary_min, x_boundary_max, y_boundary_min and y_boundary_max;
the image preprocessing module is used for carrying out gray processing on an input image;
The coordinate axis digital contour searching module is used for carrying out contour searching on the preprocessed image, finding all contours and storing the contours into a list, traversing and returning the minimum positive rectangle information containing input information, namely, storing the left upper corner coordinates of a rectangular frame of the minimum positive rectangle and the width and height of the rectangle into the list;
Performing text recognition on the x list and the y list by pytesserac, performing rescreening treatment on the recognition result, storing the digital result obtained after screening into a fifth dimension of the x list and the y list respectively, and finally sorting the lists in ascending order by taking the fifth dimension as a keyword to obtain two new lists, namely result_x and result_y;
The coordinate axis proportion calculation module is used for respectively carrying out coordinate axis proportion calculation on the adjacency of the result_x and result_y lists;
And the y value searching module is used for inputting the x value to be searched and solving the true value of the x value in the pixel coordinate system.
2. A method for extracting broken line/curve data based on image processing, which is applied to a broken line/curve data extraction system based on image processing as claimed in claim 1, and is characterized by comprising the following steps:
Step (1), searching the frame of the curve/line diagram;
Step (2), preprocessing the image;
Step (3), searching the digital outline of the coordinate axis;
Step (4), identifying the coordinate axis number;
step (5), calculating the proportion of coordinate axes;
and (6) searching a true value of the x value in a coordinate system through the input x value.
3. The method for extracting polyline/curve data based on image processing of claim 2, wherein the step (1) is specifically implemented as follows:
Applying canny edge detection to an input image to obtain a two-dimensional pixel vector v1 containing a clear curve outline of the input image and an edge shape h x w of the input image;
transpose the two-dimensional pixel vector v1 to obtain a transposed vector v2;
Performing row search and column search on the two-dimensional pixel vector v1 and the transposed vector v2 respectively;
Because the binarized image has the abrupt change of the pixel point accumulation sum at the left and right sides of the starting point and the ending point of the folding line, the accurate frame positioning is realized on the original image of the folding line/curve image based on the abrupt change, and the x_boundary_min, the x_boundary_max, the y_boundary_min and the y_boundary_max are obtained.
4. The method for extracting polyline/curve data based on image processing of claim 3, wherein step (2) is specifically implemented as follows:
gray processing is carried out on the input image, wherein the values of three channels of the input image are all changed into the same value, and the value is divided by 3 by three channel pixel addition;
And carrying out self-adaptive binarization on the image after gray level processing, and setting 255 to the single-channel pixel value of the corresponding gray level image of the image with the value larger than the self-adaptive threshold value to obtain the preprocessed image.
5. The method for extracting polyline/curve data based on image processing of claim 4, wherein step (3) is specifically implemented as follows:
and (3) carrying out contour searching on the preprocessed image obtained in the step (2), finding all contours, storing the contours into a list, traversing and returning the minimum positive rectangle information containing input information, namely storing the left upper corner coordinates of a rectangular frame of the minimum positive rectangle and the width and height of the rectangle into the list, screening all the minimum positive rectangles in the list, and storing the screening result into a new list a.
6. The method for extracting the polyline/curve data based on image processing of claim 5, wherein the new list a is characterized in that digits with two digits possibly exist are further divided into two digits due to a longer dividing distance, so that the new list a needs to be further judged:
a[i]=[a[x1][0],a[x1][1],a[x2][0]-a[x1][0],max(a[x1][3],a[x2][3])] (1)
Wherein a [ x1] [0] represents the upper left corner x, a [ x1] [1] represents the upper left corner y, a [ x2] [0] -a [ x1] [0] represents the length of the rectangle, and max (a [ x1] [3], a [ x2] [3 ]) represents the width of the rectangle;
Specifically, according to the x_boundary_min and y_boundary_max obtained in the step (1), a rectangular box a [ i ] [0] < x_boundary_min in the list a is stored in a list Y which is the number on the Y axis, and a [ i ] [1] > y_boundary_max in the list a is stored in a list Y which is the number found on the X axis.
7. The method for extracting polyline/curve data based on image processing of claim 6, wherein step (4) is specifically implemented as follows:
performing text recognition on the two lists x and y subjected to the merging treatment by using pytesserac respectively;
Screening the identification result, and storing the digital result obtained after screening into a fifth dimension of a list x and a list y respectively, wherein the list is in the following format:
list=[x1,y1,x2,y2,num] (2)
And finally, sorting the lists in ascending order by taking the fifth dimension as a keyword to obtain two new lists, namely result_x and result_y.
8. The method for extracting broken line/curve data based on image processing as set forth in claim 7, wherein the filtering process is to filter out numbers in each rectangular frame of numbers and to merge them, and to convert the data in the form of characters into data of integer type, and store them in fifth dimensions of list result_x and list result_y, respectively, because character recognition may possibly recognize space and line feed error characters.
9. The method for extracting polyline/curve data based on image processing of claim 7 or 8, wherein the specific implementation process of step (5) is as follows:
And respectively carrying out coordinate axis proportion calculation on adjacent elements in the list result_x and the list result_y, wherein the coordinate axis proportion calculation of the result_x list is to sequentially subtract the fifth dimension elements of the adjacent two elements in the result_x list and traverse the elements in the result_x list:
d=result_x[i+1][4]-result_x[i][4] (3)
the method comprises the steps of (1) setting a value d of a dictionary as a keyword, setting a value s of the dictionary as a list, recording the number of the rectangle frames, i in the example, and performing the same operation on a result_y list to finally obtain a dictionary my_direct_x and my_direct_y, searching the number of elements in the list according to the keyword, namely the d value, in the two dictionaries, accumulating the d value of the corresponding element in the my_direct_x [ Delta_x ] to obtain the Delta_sum_x, wherein i is greater than or equal to 0, and the value d of the corresponding element in the my_direct_x [ Delta_x ] is calculated by the same operation, and the proportion formula of the last coordinate axis is as follows:
x_ratio=Delta_sum_x/len(my_dictx_x[Delta_x]) (4)
The method comprises the steps of storing a value of a dictionary, wherein Delta_x represents a keyword with the maximum list length corresponding to the value of the value in the dictionary my_direct_x, x_ratio represents how many pixels the real length is in a pixel picture on a coordinate axis, and Delta_sum_x represents a value for accumulating differences between left boundaries of corresponding adjacent rectangular frames with the value of the keyword of the dictionary Delta_x.
10. The method for extracting polyline/curve data based on image processing of claim 9, wherein the specific implementation process of step (6) is as follows:
Inputting the X value to be searched, drawing a reference point on the X axis, taking a subscript m from my_subject_x [ Delta_x ] and taking the coordinate and the truly recognized number from result_x [ m ], wherein the abscissa X symbol = (result_x [ m ] [0] +result_x [ m ] [2 ])/2 on the pixel point, and the true value standard_num_x=result [ m ] [4] of the reference point, wherein the abscissa of the input X value in the pixel coordinate system is:
x'=xsymbol+(x-standard_num_x)*x_ratio (5)
By traversing the pixels in the image, the background color in the image is removed, and the gray image pixel value is set to 255, namely white;
For the abscissa x ', x_int=int (x'), x_float=x '-x_int, for finding the corresponding Y value of the corresponding abscissa x', color finding is needed to be carried out through a color finding function to obtain the main color of the curve, namely line_color, then a method of traversing the row of pixels of x_int is adopted, when traversing from top to bottom to the first pixel point, the value of the line_color is the upper boundary of the Y to be found, and similarly traversing from bottom to top to the first pixel point, the value of the line_color is the lower boundary of the Y to be found, namely the median value of the Y to be found is the Y value corresponding to the x_int to be found; for the x_float part, searching the slope, finding the adjacent slope of x_int, multiplying the slope by x_float to form the ordinate of the corresponding pixel point on the final Y-axis, and for the Y-axis, a reference point is needed, which needs to be correctly identified, a subscript m is needed to be taken out from my_direct_y [ Delta_y ], the coordinate and the truly identified number are taken out from result_y [ m ], and the ordinate on the pixel point is needed
Reference point true value:
standard_num_y=result_y[m][4](7)
so for the input x value its true value in the coordinate system is:
xresult=standard_num_y+(ysymbol-(kx*x_float))/y_ratio(8)
x result is the true value of the y-axis that needs to be found.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210390591.2A CN114998428B (en) | 2022-04-14 | 2022-04-14 | A polyline/curve data extraction system and method based on image processing |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210390591.2A CN114998428B (en) | 2022-04-14 | 2022-04-14 | A polyline/curve data extraction system and method based on image processing |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN114998428A CN114998428A (en) | 2022-09-02 |
| CN114998428B true CN114998428B (en) | 2025-06-10 |
Family
ID=83023613
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210390591.2A Active CN114998428B (en) | 2022-04-14 | 2022-04-14 | A polyline/curve data extraction system and method based on image processing |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN114998428B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN115331013B (en) * | 2022-10-17 | 2023-02-24 | 杭州恒生聚源信息技术有限公司 | Data extraction method and processing equipment for line graph |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108470364A (en) * | 2018-01-29 | 2018-08-31 | 青岛真时科技有限公司 | A kind of curve-fitting method and device |
| CN114332866A (en) * | 2021-12-08 | 2022-04-12 | 上海大学 | Document curve separation and coordinate information extraction method based on image processing |
Family Cites Families (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110955949A (en) * | 2018-09-25 | 2020-04-03 | 北京国双科技有限公司 | Engine data processing method, device and equipment |
| CN110569774B (en) * | 2019-08-30 | 2022-07-05 | 武汉大学 | Automatic line graph image digitalization method based on image processing and pattern recognition |
| CN110909732B (en) * | 2019-10-14 | 2022-03-25 | 杭州电子科技大学上虞科学与工程研究院有限公司 | Automatic extraction method of data in graph |
| CN112651315B (en) * | 2020-12-17 | 2024-12-10 | 苏州超云生命智能产业研究院有限公司 | Information extraction method, device, computer equipment and storage medium for line graph |
-
2022
- 2022-04-14 CN CN202210390591.2A patent/CN114998428B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN108470364A (en) * | 2018-01-29 | 2018-08-31 | 青岛真时科技有限公司 | A kind of curve-fitting method and device |
| CN114332866A (en) * | 2021-12-08 | 2022-04-12 | 上海大学 | Document curve separation and coordinate information extraction method based on image processing |
Also Published As
| Publication number | Publication date |
|---|---|
| CN114998428A (en) | 2022-09-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Delon et al. | A nonparametric approach for histogram segmentation | |
| CN111814722A (en) | A form recognition method, device, electronic device and storage medium in an image | |
| CN113609984A (en) | Pointer instrument reading identification method and device and electronic equipment | |
| CN114332866B (en) | Literature curve separation and coordinate information extraction method based on image processing | |
| CN110738030A (en) | Table reconstruction method and device, electronic equipment and storage medium | |
| CN112784932B (en) | Font identification method, device and storage medium | |
| CN108109157A (en) | A kind of rock mass analysis and assessment method based on digital panorama borehole image | |
| CN116704516B (en) | Visual inspection method for water-soluble fertilizer package | |
| CN116868226A (en) | Detection of annotated regions of interest in images | |
| CN112883795A (en) | Rapid and automatic table extraction method based on deep neural network | |
| CN113033558A (en) | Text detection method and device for natural scene and storage medium | |
| CN117576699A (en) | A method and system for intelligent identification of locomotive work order information based on deep learning | |
| CN109948440B (en) | Table image analysis method, device, computer equipment and storage medium | |
| CN100433045C (en) | Table extracting method and apparatus | |
| CN114998428B (en) | A polyline/curve data extraction system and method based on image processing | |
| CN115082944A (en) | Intelligent identification and segmentation method, system and terminal for table | |
| CN114038000A (en) | A structured method, system and electronic device for an image table | |
| CN110059572B (en) | Document image Chinese keyword detection method and system based on single character matching | |
| CN115830607A (en) | Text recognition method and device based on artificial intelligence, computer equipment and medium | |
| CN105160300B (en) | A kind of text abstracting method based on level-set segmentation | |
| Mehdi et al. | Optimized word segmentation for the word based cursive handwriting recognition | |
| CN113255657B (en) | Method and device for detecting scratch on bill surface, electronic equipment and machine-readable medium | |
| CN110084117A (en) | Document table line detecting method, system based on binary map segmented projection | |
| CN111046874A (en) | Single number identification method based on template matching | |
| CN116597222B (en) | A core column analysis method and system combined with attention mechanism |
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 | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |