A paper electrocardiogram digitization method based on a classical statistical method
By combining multiple FoF clustering and kernel density estimation with principal component analysis, the problem of noise in manually captured paper electrocardiograms was solved, achieving efficient digital processing that is suitable for electrocardiogram digitization under different conditions.
Patent Information
- Application Number
- CN202211389769.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-08
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-11-08
AI Technical Summary
Existing technologies struggle to effectively remove shadows and wrinkles caused by manual shooting in paper electrocardiograms, and are unsuitable for users with insufficient machine scanning capabilities, resulting in low digitization efficiency.
Multiple FoF clustering algorithms are used in combination with kernel density estimation and principal component analysis to remove classes with a small number of pixels and grid noise. Noise in the shadow area is removed through multiple clustering and grayscale processing.
It enables the rapid and effective removal of shadows and wrinkles from paper electrocardiograms, improves digitization efficiency, is suitable for manually captured electrocardiograms, and simplifies the processing workflow.
Smart Images

Figure CN115690435B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of electrocardiogram digitization, in particular to a paper electrocardiogram digitization method based on a classical statistical method. BACKGROUND
[0002] Electrocardiogram has important reference value in the research of heart-related diseases. However, some electrocardiograms are recorded on paper, which may produce a lot of noise. Digitizing paper electrocardiogram records into high-quality signals is essential for further analysis. The digitized electrocardiogram signal is not only beneficial to the management of patient information in hospitals, the teaching and research of clinicians, but also allows doctors to use the large amount of data obtained to make more detailed quantitative statistical analysis and diagnosis of heart disease, discover more and more accurate clinical diagnosis standards, improve the accuracy of patient condition diagnosis, and provide better treatment options.
[0003] However, there are still some difficulties in the current paper electrocardiogram digitization. During the acquisition of paper electrocardiogram, some noise may be generated in some areas, which will change the pixel value size of the local area in the obtained image, greatly affecting the digitization result. In addition, for some users who do not have machine scanning conditions, they can only manually take electrocardiograms, resulting in slight wrinkles and shadows in the pictures, thereby producing more noise.
[0004] The prior art scheme includes the following steps: obtaining an electrocardiogram image; extracting a region of interest from the image, and extracting an electrocardiogram waveform from the region of interest; using a segmentation network to separate the background and the waveform of the electrocardiogram waveform, and using horizontal projection and vertical projection to segment different lead waveforms to obtain electrocardiograms corresponding to different leads. However, the related art has the disadvantages of complex structure, slightly low digitization efficiency, and the like compared to the present application, and the related art is only suitable for electrocardiograms obtained by machine scanning, and is not suitable for removing shadow noise caused by manually taking electrocardiograms. SUMMARY
[0005] In view of the above technical defects, the present application provides a paper electrocardiogram digitization method based on a classical statistical method, which includes the following steps:
[0006] An image to be processed is obtained, and the image to be processed is subjected to grayscale processing to obtain a grayscale image, and an electrocardiogram waveform is obtained based on the grayscale image;
[0007] A kernel density estimation map is made based on the grayscale image, and part of the grayscale data is removed according to the kernel density estimation map to obtain a first image;
[0008] The first image is subjected to a first FoF clustering to obtain a second image;
[0009] For the largest noisy classes in the second image, some grayscale data is removed according to the kernel density estimation map to obtain the third image;
[0010] The third image is subjected to a second FoF clustering, and further filtered based on the dispersion to obtain the fourth image;
[0011] Remove the grid noise that intersects with the electrocardiogram waveform in the fourth image to obtain the fifth image;
[0012] The fifth image is subjected to a third FoF clustering to obtain the image after noise removal.
[0013] Preferably, the method for obtaining the electrocardiogram waveform includes: projecting the grayscale image horizontally and vertically to determine the rectangular region where the electrocardiogram waveform is located; and segmenting the rectangular region based on the number of grids in the rectangular region to obtain the electrocardiogram waveform.
[0014] Preferably, the method for obtaining the first image includes: setting a first threshold based on the kernel density estimation map, and changing grayscale values greater than the first threshold to 0 to remove most of the grid.
[0015] Preferably, the method for obtaining the second image includes: performing a first FoF clustering on the first image, setting the parameter eps of the first clustering to 1 and the parameter min_samples to 1, where eps represents the radius of the neighborhood around a point and min_samples represents the number of points contained in the neighborhood, and the distance between two points is measured by Euclidean distance; then removing classes with less than a second threshold data to obtain the second image.
[0016] Preferably, the method for obtaining the third image includes: performing a second FoF clustering on the second image, setting the parameter eps of the second FoF clustering to 1, and setting min_samples to 1; finding the class with more than a third threshold, and changing the grayscale of the image with more than the third threshold to 0, thereby obtaining the third image.
[0017] Preferably, the method for obtaining the fourth image includes: performing a third FoF clustering on the third image, setting the third FoF clustering parameter eps to 1 and min_samples to 1; removing classes with fewer than a fourth threshold of pixels; observing the diffusion of each class with more than the fourth threshold, and simultaneously setting the grayscale value of the midpoint of the class with diffusion less than a fifth threshold to 0, thereby obtaining the fourth image.
[0018] Preferably, the method for obtaining the fifth image includes:
[0019] The fourth image is intersected with the electrocardiogram waveform. For each region containing an electrocardiogram waveform, principal component analysis is performed every three columns. The pixels with the smallest gray values in each column are retained to obtain the fifth image.
[0020] Preferably, the method for obtaining the noise-removed image includes:
[0021] The fifth image is subjected to a fourth clustering process, with the parameters eps and min_samples set to 1. The number of pixels removed after clustering is set to less than the number of points retained in each column of the fifth image, thus obtaining the noise-removed image.
[0022] Compared with the prior art, the beneficial effects of this application are as follows:
[0023] This application features a simple structure and employs the FoF clustering algorithm multiple times. This algorithm is applicable to millions of data points and is fast and effective, resulting in faster processing speed and improved digitization efficiency. Existing technologies involve machine scanning of paper electrocardiograms followed by noise removal, which does not address noise in shadow areas and is therefore unsuitable for removing shadow noise. For users without machine scanning capabilities, manual electrocardiogram photography is necessary, leading to slight wrinkles and shadows in the images. This application achieves noise removal in shadow areas through multiple FoF clustering operations and the removal of clusters with fewer pixels. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a schematic diagram of the method flow of an embodiment of this application;
[0026] Figure 2 This is a schematic diagram of the region containing the electrocardiogram waveform according to an embodiment of this application;
[0027] Figure 3 This is a schematic diagram of kernel density estimation based on grayscale images, according to an embodiment of this application.
[0028] Figure 4 This is a schematic diagram of the first image in an embodiment of this application;
[0029] Figure 5 This is a second schematic diagram of an embodiment of this application;
[0030] Figure 6 This is a schematic diagram of the final image of an embodiment of this application. Detailed Implementation
[0031] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0032] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0033] like Figure 1 The diagram shown is a schematic representation of a method flow according to an embodiment of this application. The steps include:
[0034] The image to be processed is acquired and then converted to grayscale to obtain a grayscale image. An electrocardiogram (ECG) waveform is then derived from this grayscale image. The grayscale conversion uses a common grayscale formula. In this embodiment, the grayscale formula used is:
[0035] gray=R×0.299+G×0.587+B×0.114
[0036] Where gray represents grayscale value, R represents Red (red pixel value), G represents Green (green pixel value), and B represents Blue (blue pixel value). The grayscale conversion formula can also be a Gamma-corrected grayscale conversion formula, i.e., the grayscale conversion formula is:
[0037] gray={[R^2.2+(1.5×G)^2.2+(0.6×B)^2.2] / [1+1.5^2.2+0.6^2.2]}^(1 / 2.2).
[0038] The obtained grayscale image is then projected horizontally and vertically. The two rows with the highest and furthest grayscale values obtained from the horizontal projection represent the top and bottom edges of the rectangular region containing the ECG waveform. Similarly, the two columns with the highest and furthest grayscale values obtained from the vertical projection represent the left and right edges of the rectangular region containing the ECG waveform, thus determining the rectangular region containing the ECG waveform. Dividing the rectangular region according to the number of grid cells allows for the approximate location of each grid cell, thereby determining the region containing each ECG waveform, resulting in the ECG waveform, as shown below. Figure 2 As shown.
[0039] Kernel density estimation map based on grayscale image, such as Figure 3 As shown, the first image is obtained by removing some grayscale data based on the kernel density estimation map. A kernel density estimation map is performed on the grayscale image data, and some grayscale data is removed based on the kernel density estimation map. Since the pixel grayscale values of the grid are usually greater than the grayscale values of the electrocardiogram waveform, a first threshold is set based on the kernel density estimation map, and grayscale values greater than the first threshold are set to 0 to remove most of the grid. To retain as much information as possible, this first threshold is manually adjusted. The resulting first image is shown below. Figure 4 As shown.
[0040] Perform the first FoF clustering on the first image to obtain the second image, as shown below. Figure 5 As shown. Due to imaging issues, some areas of the paper electrocardiogram image may have shadows, resulting in lower grayscale values for the grid in these areas. Therefore, the above steps cannot remove all grids. Thus, a first FoF clustering is performed on the image data of the first image. FoF clustering actually uses a kd-tree to build an index, employing the FoF clustering method and inverse clustering. Therefore, the parameter eps is set to 1, and min_samples is set to 1. Here, eps represents the radius of the neighborhood around a point, and min_samples represents the number of points contained within the neighborhood. The distance between two points is measured using Euclidean distance. After clustering, classes with fewer than a second threshold are removed. In this embodiment, the second threshold is 100 and was manually adjusted.
[0041] Other clustering methods perform poorly. In particular, kd-trees combined with DBSCAN are a fast and efficient FoF clustering method used in astronomy for cosmic particles. Compared to most clustering algorithms, FoF clustering can handle millions of data points. Furthermore, FoF clustering does not require a pre-defined number of clusters.
[0042] For the largest noisy clusters in the second image, some grayscale data is removed based on the kernel density estimation map to obtain the third image. A second clustering process is performed on the second image, setting the FoF clustering parameter eps to 1 and min_samples to 1; the largest noisy clusters are identified, i.e., those with more pixels than a third threshold. In this embodiment, the third threshold is 10000 and was manually adjusted. Then, the grayscale values of these largest noisy clusters are set to 0 to obtain the third image.
[0043] A second FoF clustering was performed on the third image, and further filtering was conducted based on the diffusion to obtain the fourth image. The threshold for removing classes with fewer data points differed from the threshold for pixel count in the second image, and was appropriately relaxed. The FoF clustering parameter eps was set to 1, and min_samples was set to 1. After clustering, classes with fewer than the fourth threshold were removed; in this embodiment, the fourth threshold was 250 and was manually adjusted. Then, for classes with more than 250 pixels, the diffusion of each class was observed, and the grayscale values of points in classes with diffusion less than the fifth threshold were set to 0; in this embodiment, the fifth threshold was 10 and was manually adjusted. The fourth image was then obtained.
[0044] The fifth image is obtained by removing grid noise that intersects the fourth image with the ECG waveform. The noise in the fourth image consists only of grid lines perpendicular to the ECG waveform. For each ECG waveform, principal component analysis (PCA) is performed on every three columns from left to right within its region. PCA is only performed on data with non-zero grayscale values to obtain the eigenvectors of the covariance matrix. If the eigenvectors are nearly perpendicular to the horizontal vectors, it indicates that the region contains vertical grid noise. For pixels with non-zero grayscale values in these three columns, the pixels with the smallest grayscale values in each column, along with the two pixels above and below them, are retained. In this embodiment, 10% of the pixels are selected; this 10% is manually adjusted. The fifth image is then obtained.
[0045] A third FoF clustering operation is performed on the fifth image to obtain the noise-removed image. After the above steps, the grid noise intersecting with the ECG waveform in the fifth image is no longer continuous, so another FoF clustering operation is performed to remove the noise. The FoF clustering parameters eps and min_samples are set to 1. The threshold for removing fewer data points in this operation differs from the pixel threshold in step five. The threshold for removing fewer pixels after clustering is set based on the number of points retained in each column of the fifth image. In this embodiment, since each column of the fifth image retains a cluster of 5 points, clusters with fewer than 5 pixels are removed. The final noise-removed image is shown below. Figure 6 As shown.
[0046] The embodiments described above are merely preferred embodiments of this application and are not intended to limit the scope of this application. Any modifications and improvements made to the technical solutions of this application by those skilled in the art without departing from the spirit of this application shall fall within the protection scope defined by the claims of this application.
Claims
1. A method for digitizing paper electrocardiograms based on classical statistical methods, characterized by the following steps: include: The image to be processed is acquired and grayscale is processed to obtain a grayscale image. An electrocardiogram waveform is obtained based on the grayscale image. A kernel density estimation map is generated based on the grayscale image, and some grayscale data is removed according to the kernel density estimation map to obtain the first image; Perform a first FoF clustering on the first image to obtain the second image; A second FoF clustering is performed on the second image. For the largest noisy cluster in the second image, some grayscale data is removed according to the kernel density estimation map to obtain the third image. The third image is subjected to a third FoF clustering, and further filtered based on the dispersion to obtain the fourth image; The method for removing grid noise at the intersection of the fourth image and the electrocardiogram waveform to obtain the fifth image includes: intersecting the fourth image with the electrocardiogram waveform; performing principal component analysis once every three columns for each region where the electrocardiogram waveform is located; and retaining the pixel with the smallest gray value in each column to obtain the fifth image. The fifth image is subjected to a fourth FoF clustering to obtain the image after noise removal.
2. The paper electrocardiogram digitization method based on classical statistical methods according to claim 1, characterized in that, The method for obtaining the electrocardiogram waveform includes: projecting the grayscale image horizontally and vertically to determine the rectangular region where the electrocardiogram waveform is located; and segmenting the rectangular region based on the number of grids in the rectangular region to obtain the electrocardiogram waveform.
3. The method for digitizing paper electrocardiograms based on classical statistical methods according to claim 2, characterized in that, The method for obtaining the first image includes: setting a first threshold based on the kernel density estimation map, and changing grayscale values greater than the first threshold to 0 in order to remove most of the grid.
4. The paper electrocardiogram digitization method based on classical statistical methods according to claim 3, characterized in that, The method for obtaining the second image includes: performing a first FoF clustering on the first image, setting the parameter eps of the first FoF clustering to 1 and the parameter min_samples to 1, where eps represents the radius of the neighborhood around a point and min_samples represents the number of points contained in the neighborhood, and the distance between two points is measured by Euclidean distance; then removing classes with less than a second threshold data to obtain the second image.
5. The method for digitizing paper electrocardiograms based on classical statistical methods according to claim 4, characterized in that, The method for obtaining the third image includes: performing a second FoF clustering on the second image, setting the parameter eps of the second FoF clustering to 1, and setting min_samples to 1; finding the class with more than a third threshold, and changing the grayscale of the image with more than the third threshold to 0, thereby obtaining the third image.
6. The method for digitizing paper electrocardiograms based on classical statistical methods according to claim 5, characterized in that, The method for obtaining the fourth image includes: performing a third FoF clustering on the third image, setting the third FoF clustering parameter eps to 1 and min_samples to 1; removing classes with fewer than a fourth threshold of pixels; observing the diffusion of each class with more than the fourth threshold, and simultaneously setting the grayscale value of the midpoint of the class with diffusion less than a fifth threshold to 0, thereby obtaining the fourth image.
7. The method for digitizing paper electrocardiograms based on classical statistical methods according to claim 1, characterized in that, The method for obtaining the noise-removed image includes: The fifth image is subjected to a fourth clustering process, with the parameters eps and min_samples set to 1. The number of pixels removed after clustering is set to less than the number of points retained in each column of the fifth image, thus obtaining the image after noise removal.
Citation Information
Patent Citations
Rapid picture correction method realized based on classical statistical method
CN115272120A
Method and apparatus for mathematical characterization of the electrocardiogram
US4736295A