Spectral data recovery method, device and storage medium
By acquiring spectral images, cropping, edge detection, coordinate conversion and interpolation processing, the accuracy and efficiency problems of spectral data recovery in images are solved, and a method of efficiently recovering spectral data from screenshots is realized.
Patent Information
- Application Number
- CN202410966188.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-18
AI Technical Summary
In the field of image processing, it is difficult for existing technologies to recover spectral data from images accurately and efficiently, especially when the original data cannot be directly accessed due to data loss or storage limitations.
By acquiring the spectral image, determining the position of the data curve, cropping the data curve image, performing edge detection to extract contour pixel points, converting them into coordinate points, performing coordinate flipping and interpolation processing, combined with data scale and range reset, and finally cleaning the recovered data. Realize the recovery of spectral data.
It achieves fast and accurate recovery of spectral data from screenshots or pictures, reduces "bursts" in the data recovery process, and improves computing efficiency and reliability of data recovery.
Smart Images

Figure CN118505573B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a spectral data recovery method, device and storage medium. Background Art
[0002] In the field of image processing and data analysis, recovering spectral data from images has always been a challenging task. Spectral data usually contains rich information about material composition, concentration, and structure, which is of great significance to scientific research, industrial detection, and environmental monitoring.
[0003] However, in practical applications, due to various reasons (such as data loss, storage limitations, or incomplete experimental records), there may only be image screenshots containing spectral data, but no direct access to the original data.
[0004] Therefore, there is an urgent need for a technical solution that can accurately and efficiently recover spectral data from images. Summary of the invention
[0005] In order to achieve the above objectives, the present application provides a spectral data recovery method, device and storage medium, which can accurately and efficiently recover spectral data from an image.
[0006] In a first aspect, the present application provides a spectral data recovery method, the method comprising:
[0007] S1. Acquire a spectral image, wherein the spectral image at least includes: a data curve drawn using spectral data to be restored;
[0008] S2, determining the position of the data curve from the spectral image, and cutting out a data curve image from the spectral image;
[0009] S3, performing edge detection on the data curve image to extract a set of contour pixel points of the data curve, wherein the set of contour pixel points describes the shape and relative position of the data curve in the spectral image;
[0010] S4, converting each contour pixel point in the contour pixel point set into a coordinate point to obtain a coordinate point set corresponding to the data curve;
[0011] S51, taking the midpoint of the range of the ordinate variation in the coordinate point set as a virtual origin, replacing the ordinate of each coordinate point in the coordinate point set with an opposite number on the ordinate axis relative to the virtual origin;
[0012] S52. Reset the replaced coordinate point set using the data scale and data range corresponding to the spectral data to obtain a restored data set, wherein the data scale describes the numerical value of the spectral data to be restored, and the data range describes the numerical variation range of the spectral data to be restored.
[0013] In a possible implementation manner, the data range includes a target horizontal coordinate range and a target vertical coordinate range, and resetting the replaced coordinate point set using the data scale and data range corresponding to the spectral data includes:
[0014] A. interpolating the horizontal coordinates of each coordinate point in the coordinate point set according to a first preset step length, so that the coordinate point set is within the target horizontal coordinate range, and every two horizontal coordinates are separated by the first preset step length;
[0015] According to a second preset step length, interpolating the ordinate of each coordinate point in the coordinate point set, so that the coordinate point set is within the target ordinate range and every two ordinates are separated by the second preset step length;
[0016] B. According to the transformation relationship between the numerical variation range described by the data scale and the coordinate variation range of the coordinate point set, each coordinate in the coordinate point set is transformed into the numerical variation range.
[0017] In one possible implementation, the step B includes:
[0018] Determine a target horizontal coordinate range, a target vertical coordinate range, an original horizontal coordinate range and an original vertical coordinate range of the coordinate point set;
[0019] Calculating a horizontal axis transformation parameter and a vertical axis transformation parameter, wherein the horizontal axis transformation parameter represents a transformation relationship between an original horizontal coordinate range and a target horizontal coordinate range, and the vertical axis transformation parameter represents a transformation relationship between an original vertical coordinate range and a target vertical coordinate range;
[0020] According to the horizontal axis transformation parameter and the vertical axis transformation parameter, the horizontal coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target horizontal coordinate range, and the vertical coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target vertical coordinate range.
[0021] In a possible implementation manner, the calculating of the horizontal axis transformation parameter and the vertical axis transformation parameter includes:
[0022] Calculate the horizontal axis linear transformation parameter according to the ratio between the target horizontal coordinate range and the original horizontal coordinate range;
[0023] Determining a horizontal axis translation parameter according to the horizontal axis linear transformation parameter and a horizontal axis translation distance between a target horizontal coordinate range and an original horizontal coordinate range;
[0024] Calculate the longitudinal axis linear transformation parameters according to the ratio between the target longitudinal coordinate range and the original longitudinal coordinate range;
[0025] A longitudinal axis translation parameter is determined according to the longitudinal axis linear transformation parameter and a longitudinal axis translation distance between a target longitudinal coordinate range and an original longitudinal coordinate range.
[0026] In a possible implementation manner, step S2 includes:
[0027] In response to a selection event of any pixel point in the spectral image in a preset detection window, obtaining a position of the selected pixel point in the spectral image and establishing a pixel point position mapping relationship;
[0028] In response to a cropping event of the spectral image, the position of the data curve in the spectral image is acquired according to a cropping frame and a mapping relationship between pixel positions, and the data curve image is cropped.
[0029] In a possible implementation manner, after step S5, the method further includes: performing data cleanup on the reset recovery data set.
[0030] In a possible implementation manner, the step of cleaning up the reset recovery data set includes:
[0031] Pre-marking extreme value points in the restored data set, wherein the extreme value points are coordinate points whose ordinate values exceed a preset threshold value within a preset local range, and the preset threshold value is determined according to the mean value and / or standard deviation of the ordinates in the restored data set;
[0032] The extreme value points are skipped, and non-extreme value points in the restored data set are subjected to median filtering and smoothing.
[0033] In a possible implementation manner, the spectral image is: a screenshot of the original image of the data curve.
[0034] In a second aspect, a spectral data recovery device is provided, the device comprising a plurality of functional modules, configured to execute corresponding steps in the spectral data recovery method provided in the first aspect.
[0035] In a third aspect, a computing device is provided, the computing device comprising a memory and a processor, the memory storing at least one program, the at least one program being executed by the processor to implement the spectral data recovery method provided in the first aspect.
[0036] In a fourth aspect, a computer-readable storage medium is provided, wherein at least one program is stored in the storage medium, and the at least one program is executed by a processor to implement the spectral data recovery method provided in the first aspect.
[0037] In a fifth aspect, a computer program product is provided, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the spectral data recovery method provided in the first aspect is implemented.
[0038] The technical solution provided by this application includes at least the following technical effects:
[0039] The present application proposes to establish a transformation relationship between pixel points and curve data points, and combines image processing technology and curve data transformation characteristics to quickly and accurately restore curve data from screenshots or pictures. The application can be widely used to restore curve data from the only remaining screenshots or pictures. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 is a flow chart of a spectral data recovery method provided in an embodiment of the present application;
[0041] Figure 2 is a schematic diagram of a spectral data screenshot provided in an embodiment of the present application;
[0042] Figure 3 This is a schematic diagram of pixel position provided in an embodiment of the present application;
[0043] Figure 4 This is a code schematic diagram of a pixel position detection provided by an embodiment of the present application;
[0044] Figure 5 It is a data curve image schematic diagram provided in an embodiment of the present application;
[0045] Figure 6 is a schematic diagram of an edge image provided in an embodiment of the present application;
[0046] Figure 7 is a code schematic diagram of a coordinate conversion provided by an embodiment of the present application;
[0047] Figure 8 It is a drawing of a set of coordinate points provided in an embodiment of the present application;
[0048] Fig. 9 is a data curve chart after range reset provided in an embodiment of the present application;
[0049] Fig.10 This is a code schematic diagram of a data range reset provided by an embodiment of the present application;
[0050] Fig.11This is a schematic diagram of a data cleaning effect provided by an embodiment of the present application;
[0051] Fig.12 This is a code schematic diagram of data cleaning provided by an embodiment of the present application;
[0052] Fig.13 is a flow chart of another spectral data recovery method provided by an embodiment of the present application;
[0053] Fig.14 is a schematic diagram of a spectral data recovery device provided in an embodiment of the present application;
[0054] Fig.15 It is a schematic diagram of the hardware structure of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0055] To further illustrate each embodiment, the present application provides drawings. These drawings are part of the disclosure of the present application, which are mainly used to illustrate the embodiments, and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, a person of ordinary skill in the art should be able to understand other possible implementations and the advantages of the present application. The components in the figures are not drawn to scale, and similar component symbols are generally used to represent similar components. The term "at least one" in the present application means one or more, and the term "multiple" in the present application means two or more, for example, multiple coordinate points refer to two or more coordinate points.
[0056] In view of the fact that the original experimental data is lost after the experimental results or data plotting during the data processing process, and only screenshots or picture screenshots are left, but the curve graph cannot be drawn again, the present application proposes an effective, fast and accurate spectral data recovery method. The technical solution of the present application is further explained below in conjunction with some drawings and specific implementation methods.
[0057] Figure 1 is a flow chart of a spectral data recovery method provided in an embodiment of the present application, such as Figure 1 As shown, the method includes steps S1 to S5.
[0058] S1. Acquire spectral image.
[0059] The spectral image at least includes: a data curve drawn using the spectral data to be restored.
[0060] Exemplarily, the spectral data includes multiple data points, and each data point can be regarded as a coordinate point on the coordinate axis. By reading the spectral data as two one-dimensional arrays, a spectral curve can be drawn on a rectangular coordinate system. Based on this, each pixel point in the spectral image can also be regarded as a coordinate point on the pixel plane. Therefore, the present application can utilize the characteristics of the spectral data curve combined with image processing to restore the spectral data.
[0061] In a possible implementation manner, the spectral image is a screenshot of the original image where the data curve is located, or is a saved original image where the data curve is located. Figure 2 is a schematic diagram of a spectral data screenshot provided in an embodiment of the present application, such as Figure 2 As shown, the data curve chart corresponding to "Figure 1" in the entire screenshot is actually the part that needs to be extracted.
[0062] In one possible implementation, the process of acquiring a spectral image refers to: reading the spectral image from a file / image format into a three-dimensional array that is easy to process. Exemplarily, the three dimensions of the three-dimensional array include: image height, image width, and color channel. For example, for a color image, the three dimensions of the three-dimensional array are usually: height * width * 3, where 3 represents the three color channels of the red channel, the green channel, and the blue channel, and the value of each channel represents the intensity or brightness of the pixel on the channel.
[0063] In a possible implementation, an image reading function may be used to implement the above process of reading the three-dimensional array. The image reading function is, for example, the cv2.imread() function in OpenCV. For example, when a color image with a size of 100*100 pixels is read using the cv2.imread() function, a three-dimensional array is obtained, which can be expressed as:
[0064] Dimension 1 (height) has 100 elements.
[0065] Dimension 2 (width) has 100 elements.
[0066] Dimension 3 (color channels) has 3 elements, corresponding to the red channel, green channel, and blue channel.
[0067] Here is a possible code form:
[0068] Spectral image three-dimensional array PicturePixels = cv2.imread(file index filename);
[0069] PicturePixels=[[[255 255 255],[255 255 255],…,[255 255 255]]].
[0070] In the embodiment of the present application, the spectral data to be restored is only represented in the spectral image in the form of a data curve. Through the above process, the image can be read into a form that is easy to process, so that the spectral data can be accurately restored from the image later.
[0071] Of course, the OpenCV mentioned above is only one possible choice. Other image processing tools may also be used in different real-time modes, such as Python image processing library, MATLAB image processing toolbox, etc. This application does not limit this.
[0072] S2. Determine the position of the data curve from the spectrum image, and cut out the data curve image from the spectrum image.
[0073] This step S2 is used to accurately crop the required image portion, reduce the interference of unnecessary information, and improve image processing efficiency.
[0074] In a possible implementation manner, this step S2 includes:
[0075] S21. In response to a selection event of any pixel point in the spectral image in a preset detection window, obtain the position of the selected pixel point in the spectral image and establish a pixel point position mapping relationship.
[0076] Exemplarily, the preset detection window refers to a pre-set image editing window. When an operation such as a mouse click, a box selection, or a selection event triggered by other programs is detected in the window, a pixel point position mapping relationship can be established based on the position of the current preset detection window itself and the position of the selected pixel point in the spectral image. Among them, the position in the spectral image corresponds to the horizontal and vertical coordinates of the pixel point, and the vertical coordinate is actually the value of the data corresponding to the pixel point. It should be noted that the value obtained after clicking at this time is not the real value, but a relative value obtained only based on the position relationship of the pixel points.
[0077] In one possible implementation, OpenCV is used to detect and mark the mouse click event in a preset detection window. Specifically, when a point in the spectral image to be processed is clicked with a mouse, the numerical information corresponding to the pixel in the spectral image can be displayed in the image through the above-mentioned pixel position mapping relationship.
[0078] Figure 3 is a schematic diagram of pixel position provided in an embodiment of the present application, such as Figure 3As shown, the data point values displayed by clicking are 635,471, 1121,136, and 1224,209.
[0079] Figure 4 is a schematic diagram of a code for pixel position detection provided in an embodiment of the present application, such as Figure 4 As shown, an OpenCV library is provided to implement the detection and annotation functions of mouse click events in a preset image window.
[0080] S22, in response to a cropping event of the spectral image, obtaining the position of the data curve in the spectral image according to the cropping frame and the mapping relationship between the pixel positions, and cropping the data curve image.
[0081] In this step S22, the curve part in the spectrum image is cut out separately.
[0082] Specifically, according to the cropping event, a cropping frame is generated in the preset detection window, and according to the pixel position mapping relationship, the array range can be selected from the corresponding three-dimensional array in the spectral image. The selected three-dimensional array is the data curve image obtained after cropping the spectral image. Figure 5 is a schematic diagram of a data curve image provided in an embodiment of the present application, such as Figure 5 As shown, the area framed by the curve is the cropped data curve image.
[0083] S3. Perform edge detection on the data curve image to extract a set of contour pixel points of the data curve.
[0084] Among them, the contour pixel set describes the shape and relative position of the data curve in the spectral image.
[0085] In the embodiment of the present application, edge detection is performed on the cropped data curve image.
[0086] Exemplarily, the data curve image is first converted from a color image to a grayscale image, and then a given edge detection operator is used to detect edge information in the image to obtain an edge image. Further, the outermost contour line is determined from the edge image and is determined as a contour curve. The outermost contour curve refers to the line closest to the direction of numerical growth for an edge region covering multiple pixels and having a certain area range.
[0087] Optionally, the edge detection operator may be any one of: Roberts operator, Prewitt operator, Sobel operator, Laplacian operator, and Canny operator.
[0088] In the embodiment of the present application, after edge detection is completed, the pixel points on the contour curve obtained by edge detection can be determined as a contour pixel set. The horizontal coordinate of each contour pixel point is its position in the width direction, and the vertical coordinate of each contour pixel point is its position in the height direction. Figure 6 It is a schematic diagram of an edge image provided in an embodiment of the present application.
[0089] S4. Convert each contour pixel point in the contour pixel point set into a coordinate point to obtain a coordinate point set corresponding to the data curve.
[0090] In the embodiment of the present application, step S4 is equivalent to drawing a data curve according to the contour pixel point set. The contour pixel points are traversed in the order of the pixel point positions, and the coordinate point set is obtained by recording the coordinates of each contour pixel point in the current drawn image. It can be understood that the contour pixel points reflect the position and shape of the spectral curve in the image.
[0091] For example, Figure 7 is a code schematic diagram of a coordinate conversion provided by an embodiment of the present application. The process of converting a contour pixel point set into a coordinate pixel point set can be specifically adopted Figure 7 The code shown is implemented as follows, Figure 7 The code is only an example. Other programming methods can be used according to different programming languages and different image tools.
[0092] It should be noted that the above process of obtaining the coordinates of the data curve according to the contour pixel points is equivalent to rearranging the pixel points on a two-dimensional plane into the curve shape described by the contour pixel point set. From the perspective of drawing, this process starts from the upper left corner of the two-dimensional plane and ends at the lower right corner. Therefore, the contour corresponding to the obtained coordinate point set is consistent with the original shape in the width (horizontal axis) direction, but is actually opposite in the height (vertical axis) direction. In other words, in the two-dimensional coordinate system where the coordinate point set is located, the coordinates in the X-axis direction increase from left to right, but the actual spectral data values corresponding to the pixel points actually decrease from bottom to top on the Y-axis. It is equivalent to reversing the direction of the value change of the Y-axis to the opposite of the original when the coordinate point set is obtained by drawing according to the contour pixel point set. Figure 8 is a drawing of a set of coordinate points provided in an embodiment of the present application, such as Figure 8 As shown, the plotting results and Figure 6 In contrast, the changes in the values along the Y-axis are completely opposite.
[0093] Through the above process, the contour of the data curve is accurately extracted and reproduced in the form of a set of data points, effectively improving the reliability of data recovery.
[0094] S5. Reset the coordinate point set to obtain a restored data set.
[0095] The embodiment of the present application calibrates the actual value of the data by resetting the coordinate range of the coordinate point set to achieve accurate recovery of the spectral data. In one possible implementation, the process of resetting the coordinate range of the coordinate point set includes the following steps S51 and S52, first flipping the coordinate point set on the Y axis, then interpolating the flipped coordinates according to the range of the horizontal and vertical coordinates, and then scaling the range.
[0096] S51. Coordinate flipping.
[0097] The Y-axis rotation problem that occurs during the process of rearranging the pixels into a curve shape on the two-dimensional plane can be effectively corrected through this step S51.
[0098] Specifically, before the coordinates are flipped, the horizontal coordinate value of the leftmost pixel on the X-axis of the coordinate point set is 0, and gradually increases to the right. When it reaches the rightmost side, the horizontal coordinate value is the image width minus 1 (i.e., width - 1). The vertical coordinate value of the top pixel point on the Y-axis of the coordinate point set in the contour pixel point set is actually 0. The vertical coordinate in the contour pixel point set gradually increases from the top to the bottom of the Y-axis in the two-dimensional coordinate system corresponding to the coordinate point set. Correspondingly, the Y coordinate gradually increases downward, and when it reaches the bottom, the vertical coordinate value is the image height minus 1 (i.e., height - 1).
[0099] From the perspective of the flipping principle, the embodiment of the present application first takes the midpoint of the vertical coordinate variation range in the coordinate point set as the virtual origin, and replaces the vertical coordinate of each coordinate point in the coordinate point set with the opposite number on the vertical axis relative to the virtual origin.
[0100] S52. Coordinate scaling.
[0101] In the embodiment of the present application, the data scale and data range corresponding to the given spectral data are used to reset the set of coordinate points obtained by replacement to obtain a restored data set. The data scale describes the numerical size of the spectral data to be restored, and the data range describes the numerical variation range of the spectral data to be restored.
[0102] In a possible implementation manner, the data range includes a target horizontal coordinate range and a target vertical coordinate range, and this step S52 further includes the following steps A to B.
[0103] A. According to a first preset step length, interpolate the horizontal coordinates of each coordinate point in the coordinate point set, so that the coordinate point set is within the target horizontal coordinate range, and every two horizontal coordinates are separated by the first preset step length.
[0104] According to the second preset step length, the ordinate of each coordinate point in the coordinate point set is interpolated so that the coordinate point set is within the target ordinate range and every two ordinates are spaced by the second preset step length.
[0105] Exemplarily, the first preset step length is x=1; and the second preset step length is y=1.
[0106] Considering that the above coordinate point set is obtained by pixel point conversion, there may be many pixels per unit length, and the thickness of the curve is not just one pixel width, which causes many glitches in the curve coordinates extracted from the image when used for drawing. Through the above interpolation process, the number of pixels in a step can be reduced after the horizontal coordinate step is interpolated to 1, which helps to reduce the "glitches" of the curve. In addition, since the interpolation of the horizontal and vertical coordinates is processed synchronously, the number of horizontal coordinates and the number of vertical coordinates correspond to each other after interpolation, and integer multiple linear modification can be supported in subsequent range modification to improve calculation efficiency.
[0107] B. According to the transformation relationship between the numerical variation range described by the data scale and the coordinate variation range of the coordinate point set, each coordinate in the coordinate point set is transformed into the numerical variation range.
[0108] Exemplarily, this step B includes:
[0109] B1. Determine the target horizontal coordinate range, the target vertical coordinate range, the original horizontal coordinate range and the original vertical coordinate range of the coordinate point set;
[0110] Specifically, the target horizontal coordinate range is expressed as [new_x min , new_x max ]; The target vertical coordinate range is expressed as [new_y min ,new_y max ]; the original horizontal coordinate range of the coordinate point set is expressed as [x min ,x max ]; the original vertical coordinate range is expressed as [y min, y max ].
[0111] B2. Calculate the horizontal axis transformation parameter and the vertical axis transformation parameter, the horizontal axis transformation parameter represents the transformation relationship between the original horizontal coordinate range and the target horizontal coordinate range, and the vertical axis transformation parameter represents the transformation relationship between the original vertical coordinate range and the target vertical coordinate range.
[0112] Specifically, the horizontal axis linear transformation parameter is calculated according to the ratio between the target horizontal coordinate range and the original horizontal coordinate range. The horizontal axis translation parameter is determined according to the horizontal axis linear transformation parameter and the horizontal axis translation distance between the target horizontal coordinate range and the original horizontal coordinate range; the vertical axis linear transformation parameter is calculated according to the ratio between the target vertical coordinate range and the original vertical coordinate range;
[0113] The longitudinal axis translation parameter is determined according to the longitudinal axis linear transformation parameter (such as a ratio) and the longitudinal axis translation distance between the target longitudinal coordinate range and the original longitudinal coordinate range. The above process can be expressed by formulas (1) and (2).
[0114] A x = (new_x max -new_x min ) / (x max -x min )(1)
[0115] B x = new_x min - A x * x min (2)
[0116] The target horizontal coordinate range is expressed as [new_x min , new_x max ]; The target vertical coordinate range is expressed as [new_y min ,new_y max ]; the original horizontal coordinate range of the coordinate point set is expressed as [x min ,x max ]; the original vertical coordinate range is expressed as [y min, y max ]; A x is the horizontal axis linear transformation parameter, B x is the horizontal translation parameter.
[0117] Accordingly, the longitudinal axis linear transformation parameters and longitudinal axis translation parameters can be calculated by formulas (3)-(4).
[0118] A y = (new_y max -new_y min ) / (y max -y min )(3)
[0119] B y = new_y min - A y * y min (4)
[0120] Among them, Ay is the longitudinal axis linear transformation parameter, B y is the vertical axis translation parameter.
[0121] B3. According to the horizontal axis transformation parameter and the vertical axis transformation parameter, the horizontal coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target horizontal coordinate range, and the vertical coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target vertical coordinate range, so as to obtain the restored data set.
[0122] Specifically, step B3 can be implemented using the following formulas (5)-(6).
[0123] new_x = A x * xi + B x (5)
[0124] new_y = A y * yi + B y (6)
[0125] Among them, (xi, yi) are the coordinates before scaling; (new_x, new_y) are the coordinates after scaling.
[0126] Fig. 9 is a data curve chart after range reset provided in an embodiment of the present application, such as Fig. 9 As shown in the figure, after the range is reset, the data range of the horizontal and vertical axes conforms to the numerical range of the original data.
[0127] Fig.10 It is a code diagram of a data range reset provided in an embodiment of the present application, which is used to execute the steps of data coordinate flipping, data interpolation, and data range scaling described in the above steps S51-S52.
[0128] In a possible implementation manner, after executing step S5, further including step S6.
[0129] S6. Clean up the restored data set obtained by the reset.
[0130] Specifically, data cleaning includes: pre-marking extreme value points in the restored data set, where extreme value points are coordinate points whose ordinate values exceed a preset threshold within a preset local range; skipping extreme value points, and performing median filtering and smoothing on non-extreme value points in the restored data set. That is, extreme value points are skipped during smoothing, and only non-extreme value points are subjected to median filtering. Extreme value points are retained when filtering outliers to ensure that extreme value points are not misjudged as outliers.
[0131] The preset threshold is determined according to the mean and / or standard deviation of the ordinate in the restored data set. Exemplarily, the preset threshold is set to three times the standard deviation of the ordinate.
[0132] Fig.11 is a schematic diagram of a data cleaning effect provided by an embodiment of the present application, such as Fig.11 As shown, (a) is the curve before data cleaning, and (b) is the curve after data cleaning. Median filtering is used to smooth the data to reduce noise, and then statistical methods are used to remove outliers, and finally the cleaned spectral curve data is obtained.
[0133] Fig.12 It is a code diagram of data cleaning provided in an embodiment of the present application.
[0134] In order to better understand the above steps S1 to S5 and various possible implementations, Fig.13 is a flow chart of another spectral data recovery method provided by an embodiment of the present application. Fig.13 As shown, firstly, the position of the data curve in the image is obtained, and then the data curve area in the spectral image is cropped out; then, edge detection is performed on the cropped data curve area, and the pixel point set detected by the edge is converted into a curve coordinate point set; then, the coordinate point set is reset to obtain the restored data set, and finally, data cleaning is performed on the restored data set to complete the recovery of the spectral data.
[0135] This application proposes to establish a transformation relationship between pixel points and curve data points, and combines image processing technology and curve data transformation characteristics to quickly and accurately restore curve data from screenshots or pictures. It can be widely used to restore curve data from the only remaining screenshots or pictures. Furthermore, the "burrs" of the restored data curve are reduced through interpolation processing, and the subsequent integer multiple linear coordinate scaling is supported by regularizing the horizontal and vertical coordinate ranges to improve computing efficiency.
[0136] The present application also provides a spectral data recovery device. Fig.14 is a schematic diagram of a spectral data recovery device provided in an embodiment of the present application, with reference to Fig.14 , the device comprises:
[0137] An image acquisition module, used for acquiring a spectral image, wherein the spectral image at least includes: a data curve drawn using the spectral data to be restored;
[0138] A data recovery module is used to: determine the position of the data curve from the spectral image, and cut out the data curve image from the spectral image; perform edge detection on the data curve image, and extract a set of contour pixel points of the data curve, wherein the set of contour pixel points describes the shape and relative position of the data curve in the spectral image;
[0139] Convert each contour pixel point in the contour pixel point set into a coordinate point to obtain a coordinate point set corresponding to the data curve;
[0140] The midpoint of the vertical coordinate variation range in the coordinate point set is taken as the virtual origin, and the vertical coordinate of each coordinate point in the coordinate point set is replaced by an opposite number on the vertical axis relative to the virtual origin; the replaced coordinate point set is reset using the data scale and data range corresponding to the spectral data to obtain a restored data set, wherein the data scale describes the numerical size of the spectral data to be restored, and the data range describes the numerical variation range of the spectral data to be restored.
[0141] The present application proposes to establish a transformation relationship between pixel points and curve data points, and combines image processing technology and curve data transformation characteristics to quickly and accurately restore curve data from screenshots or pictures. The application can be widely used to restore curve data from the only remaining screenshots or pictures.
[0142] It should be noted that the spectral data recovery device provided in the above embodiment only uses the division of the above functional modules as an example when implementing the corresponding steps. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the spectral data recovery device provided in the above embodiment and the above spectral data recovery method belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0143] The spectral data recovery method provided in the present application can be executed by a computing device, which may be a server, a server cluster consisting of multiple physical servers, or a distributed file system, or a cloud server cluster that provides basic cloud computing services such as cloud storage and cloud services, cloud databases, cloud computing, cloud functions, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), big data and artificial intelligence platforms, etc. The present application does not limit this.
[0144] Fig.15 is a schematic diagram of the hardware structure of a computing device provided in an embodiment of the present application, such as Fig.15 As shown, the computing device includes a processor 1501, a memory 1502, a bus 1503, and a computer program stored in the memory 1502 and executable on the processor 1501. The processor 1501 includes one or more processing cores. The memory 1502 is connected to the processor 1501 via the bus 1503. The memory 1502 is used to store program instructions. When the processor executes the computer program, all or part of the steps in the above method embodiments provided in the present application are implemented.
[0145] Further, as an executable solution, the computing device may be a computer unit, which may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The computer unit may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the composition structure of the computer unit is merely an example of a computer unit and does not constitute a limitation on the computer unit, and may include more or fewer components than the above, or a combination of certain components, or different components. For example, the computer unit may also include input and output devices, network access devices, buses, etc., which are not limited in the embodiments of the present application.
[0146] Further, as an executable solution, the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the computer unit, and various interfaces and lines are used to connect various parts of the entire computer unit.
[0147] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the computer unit by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0148] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, all or part of the steps of the above-mentioned spectral data recovery method of the embodiment of the present application are implemented.
[0149] The present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements all or part of the steps of the above-mentioned spectral data recovery method in the embodiment of the present application.
[0150] If the module / unit integrated in the above-mentioned computing unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the spectral data recovery method of the above-mentioned embodiment, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0151] Although the present application has been specifically shown and described in conjunction with the preferred embodiments, those skilled in the art should understand that various changes may be made to the present application in form and details without departing from the spirit and scope of the present application as defined by the appended claims, all of which are within the scope of protection of the present application.
Claims
1. A spectrum data recovery method, characterized in that: The method comprises: S1. Acquire a spectral image, wherein the spectral image at least includes: a data curve drawn using spectral data to be restored; S2, determining the position of the data curve from the spectral image, and cutting out a data curve image from the spectral image; S3, performing edge detection on the data curve image to extract a set of contour pixel points of the data curve, wherein the set of contour pixel points describes the shape and relative position of the data curve in the spectral image; S4, converting each contour pixel point in the contour pixel point set into a coordinate point to obtain a coordinate point set corresponding to the data curve; S51, taking the midpoint of the range of the ordinate variation in the coordinate point set as a virtual origin, replacing the ordinate of each coordinate point in the coordinate point set with an opposite number on the ordinate axis relative to the virtual origin; S52A, interpolating the horizontal coordinates of each coordinate point in the replaced coordinate point set according to the first preset step length, so that the coordinate point set is within the target horizontal coordinate range corresponding to the spectral data, and every two horizontal coordinates are spaced by the first preset step length; interpolating the vertical coordinates of each coordinate point in the coordinate point set according to the second preset step length, so that the coordinate point set is within the target vertical coordinate range corresponding to the spectral data, and every two vertical coordinates are spaced by the second preset step length; S52B, according to the transformation relationship between the numerical variation range described by the data scale corresponding to the spectral data and the coordinate variation range of the coordinate point set, each coordinate in the coordinate point set is transformed into the numerical variation range to obtain a restored data set.
2. The spectral data recovery method according to claim 1, characterized in that: Step S52B includes: Determine a target horizontal coordinate range, a target vertical coordinate range, an original horizontal coordinate range and an original vertical coordinate range of the coordinate point set; Calculating a horizontal axis transformation parameter and a vertical axis transformation parameter, wherein the horizontal axis transformation parameter represents a transformation relationship between an original horizontal coordinate range and a target horizontal coordinate range, and the vertical axis transformation parameter represents a transformation relationship between an original vertical coordinate range and a target vertical coordinate range; According to the horizontal axis transformation parameter and the vertical axis transformation parameter, the horizontal coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target horizontal coordinate range, and the vertical coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target vertical coordinate range.
3. The spectral data recovery method according to claim 2, characterized in that: The calculating of the horizontal axis transformation parameter and the vertical axis transformation parameter comprises: Calculate the horizontal axis linear transformation parameter according to the ratio between the target horizontal coordinate range and the original horizontal coordinate range; Determining a horizontal axis translation parameter according to the horizontal axis linear transformation parameter and a horizontal axis translation distance between a target horizontal coordinate range and an original horizontal coordinate range; Calculate the longitudinal axis linear transformation parameters according to the ratio between the target longitudinal coordinate range and the original longitudinal coordinate range; A longitudinal axis translation parameter is determined according to the longitudinal axis linear transformation parameter and a longitudinal axis translation distance between a target longitudinal coordinate range and an original longitudinal coordinate range.
4. The spectral data recovery method according to claim 1, characterized in that: The step S2 comprises: In response to a selection event of any pixel point in the spectral image in a preset detection window, obtaining a position of the selected pixel point in the spectral image and establishing a pixel point position mapping relationship; In response to a cropping event of the spectral image, the position of the data curve in the spectral image is acquired according to a cropping frame and a mapping relationship between pixel positions, and the data curve image is cropped.
5. The spectral data recovery method according to claim 1, characterized in that: After step S52B, the method further includes: performing data cleaning on the reset recovery data set.
6. The spectral data recovery method according to claim 5, characterized in that: The data cleaning of the reset recovery data set includes: Pre-marking extreme value points in the restored data set, wherein the extreme value points are coordinate points whose ordinate values exceed a preset threshold value within a preset local range, and the preset threshold value is determined according to the mean value and / or standard deviation of the ordinates in the restored data set; The extreme value points are skipped, and non-extreme value points in the restored data set are subjected to median filtering and smoothing.
7. The spectral data recovery method according to claim 1, characterized in that: The spectral image is a screenshot of the original image of the data curve.
8. A spectral data recovery device, characterized in that: The device comprises: An image acquisition module, used for acquiring a spectral image, wherein the spectral image at least includes: a data curve drawn using the spectral data to be restored; A data recovery module is used to: determine the position of the data curve from the spectral image, and cut out the data curve image from the spectral image; perform edge detection on the data curve image, and extract a set of contour pixel points of the data curve, wherein the set of contour pixel points describes the shape and relative position of the data curve in the spectral image; Convert each contour pixel point in the contour pixel point set into a coordinate point to obtain a coordinate point set corresponding to the data curve; Taking the midpoint of the vertical coordinate variation range in the coordinate point set as the virtual origin, the vertical coordinate of each coordinate point in the coordinate point set is replaced by the opposite number on the vertical axis relative to the virtual origin; according to the first preset step length, the horizontal coordinates of each coordinate point in the replaced coordinate point set are interpolated, so that the coordinate point set is within the target horizontal coordinate range corresponding to the spectral data, and every two horizontal coordinates are spaced by the first preset step length; according to the second preset step length, the vertical coordinates of each coordinate point in the coordinate point set are interpolated, so that the coordinate point set is within the target vertical coordinate range corresponding to the spectral data, and every two vertical coordinates are spaced by the second preset step length; according to the transformation relationship between the numerical variation range described by the data scale corresponding to the spectral data and the coordinate variation range of the coordinate point set, each coordinate in the coordinate point set is transformed into the numerical variation range to obtain a restored data set.
9. The spectral data recovery device according to claim 8, characterized in that: The data recovery module is used for: Determine a target horizontal coordinate range, a target vertical coordinate range, an original horizontal coordinate range and an original vertical coordinate range of the coordinate point set; Calculating a horizontal axis transformation parameter and a vertical axis transformation parameter, wherein the horizontal axis transformation parameter represents a transformation relationship between an original horizontal coordinate range and a target horizontal coordinate range, and the vertical axis transformation parameter represents a transformation relationship between an original vertical coordinate range and a target vertical coordinate range; According to the horizontal axis transformation parameter and the vertical axis transformation parameter, the horizontal coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target horizontal coordinate range, and the vertical coordinate of each coordinate point in the coordinate point set is scaled and aligned to the target vertical coordinate range.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one program, and the at least one program is executed by a processor to implement the spectral data recovery method according to any one of claims 1 to 7.
