Recorder line drawing image processing method and processing system
By processing the line image of the recorder, including removing interference and extracting contours, the problem of manual transcription and poor image quality in traditional recorder data is solved, achieving higher data accuracy and real-time.
Patent Information
- Application Number
- CN202411976442.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-05-06
AI Technical Summary
The data generated by traditional paper tape line recorders require manual transcription, which cannot achieve immediate feedback, and the image quality caused by light and other reasons leads to large data errors.
A recorder line drawing image processing method is provided, including using a camera to capture the image of the recorder, calibrate the image processing box, intercepting the image and removing the scale line and digital interference, performing outline extraction and bone extraction of the pointer line drawing, and finally determining the fluctuation data of the pointer line drawing.
By improving image quality, clearly depicting the overall outline of the trajectory line, and accurately extracting real data, the real-timeness of the recorder and the accuracy of the data are improved, and the problems of data error and immediate feedback are solved.
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image recognition, and in particular provides a method and a system for processing a line drawing image of a recorder. Background Art
[0002] The recorder that draws lines on paper tape (hereinafter referred to as: paper tape line recorder) has a wide range of application backgrounds in scientific research and engineering applications. It can be used to record changes in various physical quantities, such as electrocardiograms, seismic waveforms, meteorological data, etc. In the medical field, paper tape line recorders are often used in medical diagnosis, such as recording physiological signals such as electrocardiograms and electroencephalograms to help doctors analyze the condition; in seismology and meteorology, paper tape line recorders are used to record seismic waveforms, meteorological data, etc. to study the earth's natural phenomena and climate change. However, the data generated by traditional paper tape line recorders usually need to be transcribed manually, and it is necessary to wait until the paper tape is recorded before the data can be read and analyzed. It is not suitable for application scenarios that require instant feedback. Therefore, data analysis can be performed by real-time image acquisition. Then, the acquired image may be of poor quality due to light and other reasons.
[0003] Therefore, it becomes an urgent problem to propose a method for processing line drawing images of recorders to improve image quality and accuracy. Summary of the invention
[0004] In view of this, the object of the present invention is to provide a method and system for processing a line drawing image of a recorder, so as to solve the problems in the prior art such as difficulty in identifying the line drawn by the pointer and large data errors.
[0005] The present invention provides a method for processing a line drawing image of a recorder, comprising:
[0006] S1: using a camera to vertically capture an image of a recording paper of a recorder, wherein the image includes a pointer line drawn by the recorder;
[0007] S2: Use the pointer to draw a straight line with zero data to mark the image processing frame in the image;
[0008] S3: intercepting the image corresponding to the image processing frame and removing the scale lines and digital interference of the recording paper on the image;
[0009] S4: extracting the outline of the pointer line in the image obtained in S3;
[0010] S5: Extract the skeleton of the pointer line contour on the image obtained in S4.
[0011] Preferably, in S1, the camera is fixedly mounted above the recorder and illuminated by an external light source.
[0012] Further preferably, in S3, the scale lines of the recording paper are removed by illuminating the corresponding color of the light when the image is collected in the early stage.
[0013] Further preferably, in S3, the digital scale on the recording paper is identified and removed according to the grayscale and length-area characteristics.
[0014] Further preferably, the step of S4 is as follows:
[0015] S41: Divide the image obtained in S3 into small rectangular grids with fixed width and height;
[0016] S42: Calculate the grayscale of each small rectangular grid, wherein the grayscale of the small rectangular grid refers to the average grayscale of all pixels in the grid;
[0017] S43: Assume that the moving direction of the track without information is the Y axis, and the direction with information is the X axis. Then, search for the track points of each row in turn along the Y axis to obtain the outline of the pointer drawing.
[0018] Further preferably, the method for finding the trajectory point of the hth row on the Y axis is as follows:
[0019] S431: Select the initial track point of the hth row on the Y axis, where if the hth row is the bottom row on the Y axis, the grid with the lowest gray value in the hth row on the Y axis is used as the initial track point of the row; otherwise, the initial track point of the row is selected from the grids above all the track points in the h+1th row on the Y axis;
[0020] S432: Calculate the grayscale value of the neighborhood grid within the row of the initial trajectory point and compare it with the grayscale value of the initial trajectory point. If the difference between the grayscale value of the neighborhood grid and the grayscale value of the trajectory point is less than the maximum neighborhood grayscale difference, then include the neighborhood grid in the row of trajectory points and continue to compare the grayscale value of the trajectory point with that of its domain grid until no new trajectory points are generated. Otherwise, directly end the search for the row of trajectory points. The maximum neighborhood grayscale difference is dynamically set. The larger the grayscale value of the trajectory point, the smaller the maximum neighborhood grayscale difference corresponding to the trajectory point.
[0021] Further preferably, the maximum neighborhood grayscale difference=(255-track point grayscale value)*coefficient, and the coefficient is 0.1-0.3.
[0022] More preferably, the image is first binarized before skeleton extraction, so that the pointer line is white and the background is black, and then a row of 255 pixels is added at the top and bottom of the pointer line outline.
[0023] Further preferably, the recorder line drawing image processing method further includes: S6: using the skeleton line of the pointer line drawn by S5 to determine the fluctuation data corresponding to the pointer line drawing.
[0024] The present invention also provides a recorder line drawing image processing system, which is used to execute the recorder line drawing image processing method.
[0025] The recorder line drawing image processing method and processing system provided by the present invention can solve the problem of data loss that may be caused by unclear shooting. It can not only clearly depict the overall outline of the trajectory line, but also accurately extract the real data, greatly improving the real-time performance of the recorder and the accuracy of the data. DETAILED DESCRIPTION
[0026] The present invention will be further explained below in conjunction with specific implementation schemes, but the present invention is not limited thereto.
[0027] The present invention provides a method for processing a line drawing image of a recorder, comprising the following steps:
[0028] S1: using a camera to vertically capture an image of a recording paper of a recorder, wherein the image includes a pointer line drawn by the recorder;
[0029] The camera can be fixedly installed above the recorder, and an external light source can be added for lighting. If the recorder is relatively small, a shell can be added to the outer end of the recorder, which is also conducive to protecting the lighting from external interference.
[0030] S2: Use the pointer to draw a straight line with zero data to mark the image processing frame in the image;
[0031] When processing images, especially before contour extraction, the image processing frame needs to be accurately calibrated. This is because in practical applications, the 0 data line is used as a reference and only the two sides of the line bounded by the 0 data line in the image are processed. To achieve this goal, it is necessary to ensure that the image processing frame can be accurately aligned with the 0 data line.
[0032] Before calibration, it is necessary to ensure that the recorder runs for a period of time without input signal, so that enough data can be accumulated so that the signal line can run through the entire range of the image processing frame. This step ensures that during the calibration process, the image processing frame can cover all possible signal line positions, thereby ensuring the accuracy of subsequent processing.
[0033] Next, move the image processing frame so that the line in it coincides with the 0 data line. This is a key step in the calibration process because only when the image processing frame is accurately aligned with the 0 data line can the subsequent processed line data be based on the 0 data line. This operation can be achieved by manually adjusting the position of the image processing frame or by using an automated positioning system.
[0034] After completing the above steps, you can start image processing and contour extraction. At this point, since the image processing box has been accurately calibrated, you can safely process the two sides of the line based on the 0 data line. This process not only improves the accuracy of the processing, but also reduces the error caused by inaccurate calibration.
[0035] S3: intercepting the image corresponding to the image processing frame and removing the scale lines and digital interference of the recording paper on the image;
[0036] Usually, recording paper is scaled, and the scale color is usually not black, but mostly red, such as electrocardiogram paper. The scale lines of this kind of recording paper can be removed by shining light of the corresponding color on it during the early image acquisition. The lines drawn by the recorder are generally black, and the scale can be filtered by shining light of the same color as the scale lines;
[0037] Usually, the recording paper will also have digital scales, which are darker and thicker than the lines drawn by the recorder. Therefore, the digital scales can be identified and removed based on characteristics such as grayscale, length and area.
[0038] S4: extracting the outline of the pointer line in the image obtained in S3;
[0039] Sometimes, due to reasons such as shooting, lighting, and instrument instability, the trajectory line drawn by the pointer is blurred in some places, resulting in incomplete or broken contour extraction, or due to printing problems of the paper tape itself, the lighting cannot completely filter out the scale, causing interference, affecting the final data extraction. To solve the above problems, the present invention proposes an adaptive grayscale neighborhood pathfinding method based on the trajectory characteristic law of the recorder, and the steps are as follows:
[0040] S41: Divide the image obtained in S3 into small rectangular grids with fixed width and height;
[0041] The width and height of the rectangular grid can be set according to actual needs. The minimum setting is 1 pixel. The smaller the setting, the more accurate the precision, but the greater the calculation amount. Let the width of the rectangular grid be Wgrid and the height be Hgrid.
[0042] S42: Calculate the grayscale of each small rectangular grid, wherein the grayscale of the small rectangular grid refers to the average grayscale of all pixels in the grid;
[0043] S43: Assume that the moving direction of the track when there is no information is the Y axis, and the direction with information is the X axis. Then, search for each row of track points in turn along the Y axis to obtain the outline of the pointer drawing line; wherein the drawing line track moves in one direction at a uniform speed when there is no information, and records valid information in another perpendicular direction, and each row of track points is composed of a plurality of small rectangular grids;
[0044] Among them, the method for finding the trajectory point of the hth row of the Y axis is as follows:
[0045] S431: Select the initial track point of the hth row on the Y axis, where if the hth row is the bottom row on the Y axis, the grid with the lowest gray value in the hth row on the Y axis is used as the initial track point of the row; otherwise, the initial track point of the row is selected from the grids above all the track points in the h+1th row on the Y axis;
[0046] S432: Calculate the grayscale value of the neighborhood grid in the row of the initial trajectory point and compare it with the grayscale value of the initial trajectory point. If the difference between the grayscale value of the neighborhood grid and the grayscale value of the trajectory point is less than the maximum neighborhood grayscale difference, then the neighborhood grid is included in the row of trajectory points and the grayscale value of the trajectory point and its domain grid is compared continuously until no new trajectory points are generated. Otherwise, the search for the row of trajectory points is terminated directly. The maximum neighborhood grayscale difference is dynamically set. The larger the grayscale value of the trajectory point, the smaller the maximum neighborhood grayscale difference corresponding to the trajectory point, that is, the stricter the boundary distinction.
[0047] Preferably, the maximum neighborhood grayscale difference = (255-track point grayscale value) * coefficient, where the coefficient can be adjusted according to the image quality, preferably 0.1-0.3, the closer the track point grayscale is to black, the greater the neighborhood compatibility is, and the closer it is to white, the smaller the compatibility is;
[0048] The trajectory points in each row together form the outline of the trajectory line, i.e., the outline of the pointer drawing line;
[0049] S5: extract the skeleton of the pointer line contour of the image obtained in S4;
[0050] The pointer drawing contour line is a thick line contour line, and the skeleton extraction uses a morphological skeletonization algorithm, such as the Zhang-Suen algorithm, to extract the skeleton inside the contour.
[0051] However, the algorithm has errors in edge bone extraction and will default to increasing the edge bones, leaving hidden dangers for subsequent work. Therefore, the present invention first binarizes the image before bone extraction, with the pointer line drawn in white and the background in black. Afterwards, a row of 255 pixels is added at the top and bottom of the pointer line outline; subsequently, the Zhang-Suen algorithm can be used to extract its skeleton inside the outline.
[0052] Among them, the Zhang-Suen algorithm is an iterative algorithm. When iterating the left and right points, the pixels that meet the following conditions are marked as 0:
[0053] 2<=Neighbor(Pa)<=6;
[0054] S(Pa)=1;
[0055] (Pb&&Pd&&Pf)||(Pd&&Pf&&Ph)=0;
[0056] Among them, the eight pixels adjacent to the pixel point Pa are Pb, Pc, Pd, Pe, Pf, Pg, Ph and Pi respectively. Pb, Pc, Pd, Pe, Pf, Pg, Ph and Pi are arranged clockwise around Pa in sequence, and Pb is located directly above Pa. Neighbor(Pa) represents the number of 255 pixels among the eight pixels adjacent to the pixel point Pa, and S(Pa) represents the number of times 0->255 appears from Pb->Pi pixels;
[0057] In this application, when Pa is the first row of the image, Pi, Pb, and Pc are set to 255, and when Pa is the last row of pixels, Pe, Pf, and Pg are set to 255.
[0058] The improved extraction data significantly improves the first and last row skeleton extraction.
[0059] S6: Determine the fluctuation data corresponding to the pointer drawing line using the skeleton line of the pointer drawing line obtained in S5.
[0060] The fluctuation amplitude of the skeleton line along the direction with data record can be calculated by the distance between the skeleton line and the 0 data line drawn by the pointer.
[0061] The present invention also provides a recorder line drawing image processing system, which is used to execute the recorder line drawing image processing method.
[0062] The recorder line drawing image processing method and processing system can solve the problem of data loss that may be caused by unclear shooting. It can not only clearly depict the overall outline of the trajectory line, but also accurately extract real data, greatly improving the real-time performance of the recorder and the accuracy of the data.
[0063] The embodiments of the present invention are described in detail above, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A method for processing a line drawing image of a recorder, characterized in that: include: S1: using a camera to vertically capture an image of a recording paper of a recorder, wherein the image includes a pointer line drawn by the recorder; S2: Use the pointer to draw a straight line with zero data to mark the image processing frame in the image; S3: intercepting the image corresponding to the image processing frame and removing the scale lines and digital interference of the recording paper on the image; S4: extracting the outline of the pointer line in the image obtained in S3; S5: Extract the skeleton of the pointer line contour on the image obtained in S4.
2. The method for processing line drawing images of a recorder according to claim 1, characterized in that: In S1, the camera is fixedly installed above the recorder and illuminated by an external light source.
3. The method for processing line drawing images of a recorder according to claim 1, characterized in that: In S3, the scale lines of the recording paper are removed by illuminating the corresponding color of the light when the image is collected in the early stage.
4. The method for processing line drawing images of a recorder according to claim 1, characterized in that: In S3, the digital scale on the recording paper is identified and removed according to the grayscale and length-area characteristics.
5. The method for processing line drawing images of a recorder according to claim 1, characterized in that: The steps of S4 are as follows: S41: Divide the image obtained in S3 into small rectangular grids with fixed width and height; S42: Calculate the grayscale of each small rectangular grid, wherein the grayscale of the small rectangular grid refers to the average grayscale of all pixels in the grid; S43: Assume that the moving direction of the track without information is the Y axis, and the direction with information is the X axis. Then, search for the track points of each row in turn along the Y axis to obtain the outline of the pointer drawing.
6. The method for processing line drawing images of a recorder according to claim 5, characterized in that: The method for finding the trajectory point of the hth row on the Y axis is as follows: S431: Select the initial track point of the hth row on the Y axis, where if the hth row is the bottom row on the Y axis, the grid with the lowest gray value in the hth row on the Y axis is used as the initial track point of the row; otherwise, the initial track point of the row is selected from the grids above all the track points in the h+1th row on the Y axis; S432: Calculate the grayscale value of the neighborhood grid within the row of the initial trajectory point and compare it with the grayscale value of the initial trajectory point. If the difference between the grayscale value of the neighborhood grid and the grayscale value of the trajectory point is less than the maximum neighborhood grayscale difference, then include the neighborhood grid in the row of trajectory points and continue to compare the grayscale value of the trajectory point with that of its domain grid until no new trajectory points are generated. Otherwise, directly end the search for the row of trajectory points. The maximum neighborhood grayscale difference is dynamically set. The larger the grayscale value of the trajectory point, the smaller the maximum neighborhood grayscale difference corresponding to the trajectory point.
7. The method for processing line images of a recorder according to claim 6, characterized in that: Maximum neighborhood grayscale difference=(255-track point grayscale value)*coefficient, where the coefficient is 0.1-0.
3.
8. The method for processing line drawing images of a recorder according to claim 1, characterized in that: Before skeleton extraction, the image is first binarized so that the pointer line is white and the background is black. Then, a row of 255 pixels is added at the top and bottom of the pointer line outline.
9. The method for processing line drawing images of a recorder according to claim 1, characterized in that: Also includes: S6: Determine the fluctuation data corresponding to the pointer drawing line using the skeleton line of the pointer drawing line obtained in S5.
10. A recorder line drawing image processing system, characterized in that: Used to execute the recorder line image processing method described in any one of claims 1-9.