Method and electronic device for determining sample drift
By performing sub-image segmentation and cross-correlation algorithm analysis on the original image of biological samples, the problem of sample drift interference is solved, and the analysis accuracy and diagnostic efficiency of biological sample detection are improved.
Patent Information
- Application Number
- CN202011464994.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-14
AI Technical Summary
In the detection of biological samples, the complexity of the movement of liquid samples under capillary force causes the sample to drift, affecting the results of microscopic image analysis. In particular, false negative results may occur in semen analysis, and the imaging system is susceptible to external mechanical vibration interference. .
By obtaining two original sample images at different times, segment them into sub-images, analyze the similarity and offset of the sub-images, use the cross-correlation algorithm to calculate the offset distance and direction standard deviation of the sub-images, determine whether the sample has drifted, and distinguish Autonomous movement and drift.
Quickly and effectively determine whether the sample has drifted, reducing the error of analysis results, improving the accuracy of diagnosis, and avoiding the occurrence of false negative results.
Smart Images

Figure CN112580478B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of biological sample detection and analysis. Background Art
[0002] Microscopic image counting is a commonly used method for testing and analyzing biological samples (such as semen, blood, and urine). The sample is placed in a cell counting chamber or biological slide. Driven by capillary action, the liquid sample fills the entire sample space. The microscopic imaging system then captures the sample, acquiring image data. This data is then analyzed using appropriate image processing techniques to perform other functions, such as counting, classification, and statistics.
[0003] Ideally, after the sample is added to a cell counting chamber or biological slide, it will remain stationary within the sample chamber for a short period of time, allowing for observation and analysis. However, due to the complex motion of liquid samples under capillary forces, maintaining this stationary state is difficult. In some cases, it can even drift back and forth, which can last for several minutes. In such cases, the sample's motion can sometimes cause a smear in the microscopic image, interfering with the software algorithm and potentially resulting in unexpected analysis results. Furthermore, when motility analysis is required, particularly in semen analysis, this motion can directly affect the analysis, potentially resulting in false negative results and hindering the provision of timely and effective diagnostic solutions for patients. Furthermore, during imaging system operation, interference from stage sway or other external mechanical vibrations can cause drift in the captured sample image sequence.
[0004] Therefore, before processing the microscopic image data, whether the sample is drifting should be used as one of the judgment conditions for subsequent image processing. It is also necessary to provide a method for judging whether the sample is drifting. Summary of the Invention
[0005] One aspect of the present disclosure solves a technical problem by providing a method for determining sample drift and a corresponding electronic device.
[0006] The technical solution adopted by the present invention to solve the technical problem is: a method for determining sample drift, the method comprising the following contents:
[0007] S1, obtain two sample original images at different times;
[0008] S2, split the two original images into several corresponding sub-images;
[0009] S3, analyzing whether the sub-images corresponding to each two positions are similar;
[0010] S4, analyzing the offset distance and offset direction of similar subgraph groups;
[0011] S5, if the sub-image groups that are similar and have an offset distance greater than a preset offset threshold are possible drift sub-image groups, and if the number of possible drift sub-image groups exceeds a preset number, it is determined that the sample has motion;
[0012] S6, after determining that the sample has moved, analyzing the standard deviation of the offset direction of all possible drifting sub-image groups, if the standard deviation of the offset direction is less than a preset standard deviation threshold, the sample is determined to be drifting.
[0013] As described above, the method for determining sample drift further includes step S5, wherein similar sub-image groups with an offset distance less than or equal to a preset offset threshold are considered as possible static sub-image groups, and if the number of possible static sub-image groups exceeds a preset number, the sample is determined to be static.
[0014] As described above, in the method for determining sample drift, in step S6, if the standard deviation in the offset direction is greater than or equal to the preset standard deviation threshold, it is determined that the sample is in autonomous motion.
[0015] As described above, the method for determining sample drift uses a cross-correlation algorithm in steps S3 and S4, specifically including:
[0016] S100, image Fourier transform. Assume that the two sub-images used for analysis in the sub-image group are image f(i, j) and image g(i, j), and use the following formula to convert image f(i, j) and image g(i, j) into images F(u, v) and G(u, v) in the frequency domain.
[0017]
[0018] Where f(x,y) represents the image in the spatial domain, F(μ,v) represents the image in the frequency domain, M and N represent the size of the image, and j is the imaginary unit;
[0019] S101, performing spectrum centering on the Fourier transformed image to obtain images F1(u,v) and G1(u,v);
[0020] S102, split the image F1(u,v) into real and imaginary parts, negate the imaginary part and merge it with the real part to form a complex number, and obtain the conjugate image F1 * (u,v);
[0021] S103, image F1 * After (u, v) and image G1(u, v) are split into real and imaginary parts, they are multiplied and then merged into complex numbers to obtain the result φ(u, v) after the frequency domain multiplication of the two images;
[0022] S104, image inverse Fourier transform, substitute φ(u,v) into the formula,
[0023]
[0024] Obtain the result of convolution of two images in the spatial domain:
[0025] S105, will Divide the quadrant into 4 regions and swap the diagonal regions to obtain the cross-correlation spectrum
[0026] S106, cross-correlation spectrum Normalized processing to obtain the cross-correlation spectrum
[0027] S107, by cross-correlation spectrum Get the amplitude and coordinate information of the maximum peak and the second largest peak;
[0028] S108, the peak-to-peak ratio is obtained by comparing the amplitude of the maximum peak with the amplitude of the second largest peak. If the peak-to-peak ratio is greater than the preset peak-to-peak ratio threshold, the sub-image groups are determined to be similar; the offset from the origin is calculated based on the maximum peak coordinate information of the similar sub-image groups to obtain the offset distance and offset direction of the sub-image groups.
[0029] As described above, in the method for determining sample drift, in step S101 , the images F(u,v) and G(u,v) are divided into four regions by quadrants, and the diagonals are interchanged to achieve spectrum centering.
[0030] As described above, in the method for determining sample drift, in step S107 , the maximum peak and the second-largest peak are processed using a sub-pixel precision fitting method.
[0031] As described above, the method for determining sample drift includes the following steps: obtaining a video sample by gaze shooting, splitting the video sample into an image sequence in frames, and selecting any two of them as the sample original images; in step S2, the spacing between the sub-images of the two original images in the X-axis direction is Δx, and the spacing in the Y-axis direction is Δy.
[0032] As described above, in the method for determining sample drift, in step S3, if the sub-image groups are dissimilar, the analysis of the dissimilar sub-image groups is terminated; if the number of dissimilar sub-image groups exceeds a preset number, the analysis of the sample is terminated.
[0033] As described above, in the method for determining sample drift, if the two original images for which sample drift is determined are adjacent, it is defined as fast drift; if there is a gap between the two original images for which sample drift is determined, it is defined as slow drift.
[0034] An electronic device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for determining sample drift as described in any of the preceding items.
[0035] One beneficial effect brought about by one aspect of the present disclosure is that the original image of the sample is divided into small sub-images, and by comparing and analyzing the sub-images at the same position, it is possible to quickly and effectively determine whether the sample is drifting. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Some specific embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings in an exemplary and non-limiting manner. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale.
[0037] In the attached figure:
[0038] Figure 1 It is a schematic diagram of the process of the present invention;
[0039] Figure 2 Schematic diagram of segmentation of two original images of the present invention;
[0040] Figure 3 Schematic diagram of the cross-correlation algorithm of the present invention;
[0041] Figure 4 Schematic diagram of sub-images at the same position at different times according to the present invention;
[0042] Figure 5 Schematic diagram of the cross-correlation spectrum of the present invention; DETAILED DESCRIPTION
[0043] To make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0044] Based on the described embodiments of the present invention, all other embodiments derived by persons of ordinary skill in the art without inventive effort are within the scope of protection of the present invention. Unless otherwise defined, technical or scientific terms used in this disclosure shall have the same ordinary meaning as understood by persons of ordinary skill in the art to which the present invention belongs.
[0045] The terms "first", "second" and similar terms used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, terms such as "one", "an" or "the" do not indicate a quantity limitation, but rather indicate the presence of at least one. Terms such as "include" or "comprise" mean that the elements or objects preceding the term include the elements or objects listed after the term and their equivalents, without excluding other elements or objects. Terms such as "connect" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Terms such as "upper", "lower", "left", and "right" are only used to indicate relative positional relationships. When the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0046] See attached Figure 1-5 , which relates to a method for determining sample drift, the method includes the following contents:
[0047] S1, obtain two sample original images at different times;
[0048] The two original images to be analyzed come from the same sample sequence. Depending on the application scenario, the two original images can be taken at adjacent times or at non-adjacent times with an interval. The analysis is performed on the two original images taken at different times, and the changes between the two images are used to determine whether the sample has drifted. For different application scenarios, video samples of the gaze shooting type (where the camera lens and the chamber containing the sample are relatively stationary) are collected and split into a frame-by-frame image sequence. Two frames, either adjacent or separated by a few frames, are selected as the original images.
[0049] S2, split the two original images into several corresponding sub-images;
[0050] The two original images are divided into corresponding sub-images, and the number, size and position of the sub-images are the same. Figure 2 As shown in the figure, for example, assuming that the pixel size of the original image to be analyzed is 128*128, a sub-image of size 16*16 is extracted for subsequent analysis, and the original image is divided into 16 sub-images. Figure 1 Including sub Figure 1 ...Sub-image 16, original Figure 2 Including sub Figure 1 ...Sub-image 16, original Figure 1 son Figure 1 Yohara Figure 2 son Figure 1The size and position of each subimage correspond, and so on. The 16 subimages in both images are one-to-one. The position of the subimage represents the area of interest. This image shows that we are interested in the central area of the original image. This central area is divided into 16 subimages for subsequent analysis, while the areas of interest at the edges of the original image are ignored. The center positions of adjacent subimages in the horizontal direction differ by Δx, and the center positions of adjacent subimages in the vertical direction differ by Δy. The position and number of subimages should reflect the overall information of the original image as much as possible.
[0051] S3, analyzing whether the sub-images corresponding to each two positions are similar;
[0052] The premise of this method is that the same target group should appear in the two sub-images to be analyzed at different times, so that the subsequent analysis results will be reliable. This premise can be achieved by controlling the time interval between the two original images used for calculation. Therefore, when drift occurs, the two sub-images must be similar. Figure 4 Figures A and B in the middle show drifting situations.
[0053] If the analyzed sub-images are not similar, it can be considered that the target features in the image have changed. In the technical field mentioned in this article, for example, the direction of sperm autonomous movement is random, and the morphological features (mutual position relationship or grayscale distribution features) of a target group may be difficult to maintain at the next moment, so its morphological features will be different. Figure 4 Figures A and E are dissimilar. This paper does not investigate the reasons for their dissimilarity, but only determines the relationship between them. Since these two figures are dissimilar, they certainly do not fall under the drift condition defined herein, and are therefore determined to be non-drift. Specifically, if a sub-image group is dissimilar, analysis of that dissimilar sub-image group terminates. If the number of dissimilar sub-image groups exceeds a preset number, analysis of the sample terminates, and the output is a dissimilarity judgment, indicating that the sample has no drift.
[0054] S4, analyzing the offset distance and offset direction of the similar sub-image group (including two sub-images with corresponding and similar positions);
[0055] In this method, similar sub-image groups are meaningful for further analysis. Similar sub-image groups generally have the following possibilities: the two sub-images are relatively still or moving, and the movement can be further divided into autonomous movement and drifting.
[0056] S5, if the sub-image groups that are similar and have an offset distance greater than a preset offset threshold are possible drift sub-image groups, and if the number of possible drift sub-image groups exceeds a preset number, it is determined that the sample has motion;
[0057] The movement of the sample may be its autonomous behavior, such as the autonomous movement of sperm, or it may be drift caused by external interference, so further analysis is required.
[0058] Sub-image groups that are similar and whose offset distance is less than or equal to a preset offset threshold are considered as possible stationary sub-image groups. If the number of possible stationary sub-image groups exceeds a preset number, the sample is determined to be stationary.
[0059] When the sample target is stationary, the same sample target is in the same position in the two sub-images, and the offset distance is approximately equal to 0. By setting an offset threshold, it is possible to effectively distinguish whether the target is stationary or in motion. If the vast majority of the sample's sub-image groups are stationary, the sample can be determined to be stationary. The preset number of possible stationary sub-image groups can be determined based on the accuracy of the analysis. If the accuracy requirement is extremely high, the preset number can be set to the total number of sub-image groups, that is, when the number of possible stationary sub-image groups is equal to the total number of sub-image groups, the sample is judged to be stationary. The offset threshold can also be considered and set in the same way. For example, if the offset threshold is set to 0, it is only judged to be stationary when it is equal to 0; or if the offset threshold is set to 0.01, an offset within the range of 0.01 is considered to be stationary.
[0060] S6, after determining that the sample has moved, analyzing the standard deviation of the offset direction of all possible drifting sub-image groups, if the standard deviation of the offset direction is less than a preset standard deviation threshold, the sample is determined to be drifting.
[0061] If biological sample targets exhibit autonomous motion characteristics (such as sperm), their motion direction is usually random. However, in a drifting state, the motion direction of each biological sample target is relatively consistent. A statistical analysis of the motion directions of the sample targets in each sub-image is performed to obtain the standard deviation of the offset angles of all targets. By setting a standard deviation threshold, it is possible to effectively distinguish whether the target is in autonomous motion or drifting state. When the offset direction standard deviation is less than the preset standard deviation threshold, the sample target's motion direction is relatively consistent and is judged to be drifting. If the offset direction standard deviation is greater than or equal to the preset standard deviation threshold, the sample target's motion direction is relatively random and is judged to be autonomous motion.
[0062] The field of image analysis is relatively mature, and there are many existing technologies that can analyze image similarity, offset parameters, etc. Figure 3 ,This method uses the cross-correlation algorithm to analyze the similarity, offset distance, and offset direction of the images, specifically including the following:
[0063] S100, image Fourier transform. Assume that the two sub-images used for analysis in the sub-image group are image f(i, j) and image g(i, j), and use the following formula to convert image f(i, j) and image g(i, j) into images F(u, v) and G(u, v) in the frequency domain.
[0064]
[0065] Among them, f(x,y) represents the image in the spatial domain, F(μ,v) represents the image in the frequency domain, M and N represent the size of the image, and j is the imaginary unit.
[0066] This paper uses the conventional Fourier transform method. f(x,y) and F(μ,v) are mathematically agreed-upon correspondences, representing functions in the spatial and frequency domains, respectively. F(μ,v) is the Fourier transform of f(x,y). In this paper, (i,j) represents the coordinates in the spatial domain, and (u,v) represents the coordinates in the frequency domain. Similarly, transforming the spatial domain signals f(i,j) and g(i,j) yields the corresponding frequency domain signals F(u,v) and G(u,v). Converting from the spatial domain to the frequency domain facilitates calculations by leveraging the frequency domain properties of image signals, reducing the amount of computation required.
[0067] S101, performing spectrum centering on the Fourier transformed image to obtain images F1(u,v) and G1(u,v);
[0068] After Fourier transformation, low-frequency information is distributed around the image, while high-frequency information is distributed in the center. To facilitate observation and subsequent restoration of the frequency domain image to the spatial domain, spectral centering is performed. Specifically, the images F(u,v) and G(u,v) are divided into four regions by quadrant. The diagonal first and third quadrants, and the second and fourth quadrants are swapped to complete spectral centering.
[0069] S102, split the image F1(u,v) into real and imaginary parts, negate the imaginary part and merge it with the real part to form a complex number, and obtain the conjugate image F1 * (u,v);
[0070] The result F1(u,v) after conversion by the Fourier transform formula is in complex form and contains the imaginary unit j.
[0071] S103, image F1 * After (u, v) and image G1(u, v) are split into real and imaginary parts, they are multiplied and then merged into complex numbers to obtain the result φ(u, v) after the frequency domain multiplication of the two images;
[0072] S104, image inverse Fourier transform, substitute φ(u,v) into the formula,
[0073]
[0074] Obtain the result of convolution of two images in the spatial domain:
[0075] Here, φ(u,v) is F(μ,v) in the formula, f(x,y) in the formula is a mathematically agreed-upon correspondence between f(x,y) and F(μ,v), representing functions in the spatial domain and frequency domain respectively. f(x,y) is generally considered to be the inverse Fourier transform result of F(μ,v). Similarly, It is considered to be the inverse Fourier transform result of φ(u,v). In the present invention, (i,j) is the coordinate expression method in the spatial domain, and (u,v) is the coordinate expression method in the frequency domain.
[0076] S105, will Divide the quadrant into 4 regions and swap the diagonal regions to obtain the cross-correlation spectrum That is, the first and third quadrants will be swapped, and the second and fourth quadrants will be swapped;
[0077] S106, cross-correlation spectrum Normalized processing to obtain the cross-correlation spectrum
[0078] Normalization is a common simplified calculation method in data processing. It can turn dimensional expressions into dimensionless expressions, making it easier for indicators of different units or magnitudes to be compared. The method used in the present invention is: find the maximum value in the cross-correlation spectrum result, divide all the results by the maximum value, and limit all the results to the interval [0,1] to complete the normalization. There are many methods of normalization. Only the simplest linear function normalization is mentioned here. Other normalization methods include zero mean normalization, neural network normalization, etc. This method does not focus on the specific value of the cross-correlation spectrum, but only focuses on the position and relative size relationship of these values.
[0079] S107, by cross-correlation spectrum Get the amplitude and coordinate information of the maximum peak and the second largest peak;
[0080] As attached Figure 5 As shown, the cross-correlation spectrum can be understood as a three-dimensional graph composed of countless sets of three-dimensional data. The three-dimensional data can be represented as (X, Y, Z), where X and Y represent the horizontal and vertical coordinates, and Z represents the amplitude. All this information is known, and we can use the peak search method (for an N*N search area, the Z value of the center point is always higher than the Z values of the surrounding points) and sort the multiple Z values found to find the maximum and second maximum Z values and their corresponding coordinates.
[0081] S108, the peak-to-peak ratio is obtained by comparing the amplitude of the maximum peak with the amplitude of the second largest peak. If the peak-to-peak ratio is greater than the preset peak-to-peak ratio threshold, the sub-image groups are determined to be similar; the offset from the origin is calculated based on the maximum peak coordinate information of the similar sub-image groups to obtain the offset distance and offset direction of the sub-image groups.
[0082] See also the attached Figure 4The five sub-images (in the form of sub-images) are from images at different times. For the sub-images corresponding to the same position, the three circular targets in Figure A are translated to Figure B, Figure C is two circular targets plus one star-shaped target, Figure D is three star-shaped targets, and Figure E is three obliquely distributed star-shaped targets. Based on the known information, Figure A is calculated with Figure B, Figure C, Figure D, and Figure E according to the aforementioned cross-correlation algorithm to obtain the cross-correlation results. Based on the cross-correlation results, the peak-to-peak ratio Z can be obtained. AB ,Z AC ,Z AD ,Z AE ,According to the acceptable similarity level, a threshold is set, and the peak-to-peak ratio is compared with the threshold.,If the peak-to-peak ratio is greater than the threshold, it is judged as similar, and if the peak-to-peak ratio is less than or equal to the threshold, it is judged as dissimilar.
[0083] Sub-pixel precision fitting is performed on the peak position searched in the cross-correlation spectrum, which can improve the peak position result from pixel precision to sub-pixel precision, effectively improving the accuracy of the calculation result and helping to improve the reliability of subsequent calculation links.
[0084] Specifically, the cross-correlation spectrum is normalized. After processing, there will be many peaks in the spectrum. The corresponding peak coordinate information (i, j) can be obtained. Generally, the coordinate information of the maximum peak is extracted for analysis. The one-dimensional Gaussian function model is used to fit the horizontal i value and the vertical j value respectively.
[0085]
[0086] If the peak coordinates are (i, j), then the coordinates of the three points (i-1, j), (i, j), and (i+1, j) are taken for horizontal Gaussian fitting. If the peak coordinates are at the edge of the image, that is, i = 0 or i = N (N is the horizontal pixel size of the image), then the three points (0, j), (1, j), (2, j) and (N-2, j), (N-1, j), and (N, j) are taken for horizontal Gaussian fitting, and then the vertical Gaussian fitting is performed in the same way to obtain sub-pixel coordinate information.
[0087] In application scenarios where the amount of computation is not a concern, a two-dimensional Gaussian function model can be directly used for fitting.
[0088]
[0089] In addition to the Gaussian curve fitting method, the polynomial fitting method can also be used. Among the polynomial fitting methods, the parabolic function is preferably selected for fitting.
[0090] Based on the relationship between the input images, the method can identify drift states with different drift speed characteristics, improving its applicability. For a set of images, if a sample is determined to be drifting, if the input images are two adjacent frames, it indicates that the sample is drifting rapidly; if there are several frames between the input images, it indicates that the sample is drifting slowly.
[0091] The present invention also provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method for determining sample drift as described in any of the preceding items are implemented.
[0092] In summary, the method for determining sample drift proposed in the present invention can quickly determine whether the sample image captured by the imaging system is drifting in the field of biological sample detection and analysis. The sample image is a gaze-shot type, but this method is not limited to gaze-shot type images.
[0093] The method for determining sample drift proposed in the present invention utilizes a sub-image-based analysis method to reduce the size of the image to be analyzed, thereby further reducing the computational complexity of the cross-correlation analysis process.
[0094] The method for determining sample drift proposed in the present invention adopts a calculation method based on fast Fourier transform (FFT) and inverse fast Fourier transform (IFFT), which greatly reduces the amount of calculation in the process and shortens the analysis time.
[0095] The method for determining sample drift proposed in the present invention uses a sub-pixel precision fitting method to improve the peak position result from pixel precision to sub-pixel precision, effectively improving the accuracy of the calculation result and facilitating the improvement of the reliability of subsequent calculation links.
[0096] The method for determining sample drift proposed by the present invention has a similarity function determination module, which can determine whether two input images are similar.
[0097] The present invention provides a method for quickly determining sample drift, which has a still image / moving image distinguishing function module and can distinguish still images from moving images.
[0098] The present invention proposes a method for quickly determining sample drift, which has an autonomous motion / drift distinction function module and can distinguish the autonomous motion behavior of a sample target from the sample drift.
[0099] The present invention provides a method for quickly determining sample drift, which includes a drift speed determination function module and can measure the speed of sample drift.
[0100] The method proposed in this paper can be used as a method for determining whether image data meets analysis requirements in the field of image processing-based biological sample testing. Image drift is an unavoidable phenomenon that interferes with automated image processing and analysis. Failure to identify this phenomenon can easily lead to erroneous output results. Therefore, an efficient and rapid method for determining sample drift is essential.
[0101] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that the present invention is susceptible to various modifications, combinations, and variations. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of the claims.
Claims
1. A method for determining sample drift, characterized in that: The method comprises the following: The sample is sperm; S1, obtain two sample original images at different times; S2, split the two original images into several corresponding sub-images; S3, analyzing whether the sub-images corresponding to each two positions are similar; If the sub-image groups are not similar, the analysis of the dissimilar sub-image groups is terminated, and it is determined that the sample has no drift; if the number of dissimilar sub-image groups exceeds a preset number, the analysis of the sample is terminated, and it is determined that the sample has no drift; S4, analyzing the offset distance and offset direction of similar sub-graph groups; S5, if the sub-image groups that are similar and whose offset distance is greater than a preset offset threshold are possible drifting sub-image groups, and if the number of possible drifting sub-image groups exceeds a preset number, it is determined that the sample has motion; The sub-image groups that are similar and whose offset distance is less than or equal to the preset offset threshold are the possible static sub-image groups. If the number of possible static sub-image groups exceeds the preset number, the sample is determined to be static. S6, after determining that the sample has moved, analyzing the standard deviation of the offset direction of all possible drifting sub-image groups, if the standard deviation of the offset direction is less than a preset standard deviation threshold, the sample is determined to be drifting; If the standard deviation of the offset direction is greater than or equal to the preset standard deviation threshold, the sample is determined to be in autonomous motion.
2. The method for determining sample drift as claimed in claim 1, characterized in that: Steps S3 and S4 use a cross-correlation algorithm, specifically including: S100, image Fourier transform, assuming that the two sub-images used for analysis in the sub-image group are image f(i, j) and image g(i, j), respectively, and the following formula is used to transform image f(i, j) and image g(i, j) into images F(u, v) and G(u, v) in the frequency domain; Among them, f(x,y) represents the image in the spatial domain, F(μ,v) represents the image in the frequency domain, M and N represent the size of the image, and j is an imaginary unit; S101, performing spectrum centering on the Fourier transformed image to obtain images F1(u,v) and G1(u,v); S102, split the image F1(u,v) into real and imaginary parts, negate the imaginary part and merge it with the real part to form a complex number, and obtain the conjugate image F1 * (u,v); S103, image F1 * After (u, v) and image G1(u, v) are split into real and imaginary parts, they are correspondingly multiplied and then merged into complex numbers to obtain the result φ(u, v) of the frequency domain multiplication of the two images; S104, image inverse Fourier transform, substitute φ(u,v) into the formula, Get the result of convolution of two images in the spatial domain: S105, Divide the quadrants into 4 regions and swap the diagonal regions to obtain the cross-correlation spectrum S106, cross-correlation spectrum Normalized processing to obtain the cross-correlation spectrum S107, by cross-correlation spectrum The amplitude and coordinate information of the maximum peak and the second largest peak are obtained; S108, the peak-to-peak ratio is obtained by comparing the amplitude of the maximum peak with the amplitude of the second largest peak. If the peak-to-peak ratio is greater than a preset peak-to-peak ratio threshold, the sub-image groups are determined to be similar; the offset from the origin is calculated based on the maximum peak coordinate information of the similar sub-image groups to obtain the offset distance and offset direction of the sub-image groups.
3. The method for determining sample drift as claimed in claim 2, characterized in that: In step S101, the images F(u,v) and G(u,v) are divided into four regions by quadrants, and the diagonals are interchanged to complete the spectrum centering.
4. The method for determining sample drift as claimed in claim 3, characterized in that: In step S107, the maximum peak and the second maximum peak are processed using a sub-pixel precision fitting method.
5. The method for determining sample drift as claimed in claim 1, characterized in that: Step S1 includes the following contents: obtaining a video sample by staring shooting, splitting the video sample into an image sequence in frames, and taking any two of them as sample original images; In step S2, the distance between the sub-images of the two original images in the X-axis direction is Δx, and the distance between the sub-images in the Y-axis direction is Δy.
6. The method for determining sample drift as claimed in claim 1, characterized in that: If the two original images for determining sample drift are adjacent, it is defined as fast drift; if there is a gap between the two original images for determining sample drift, it is defined as slow drift.
7. An electronic device, characterized in that: The device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for determining sample drift as described in any one of claims 1 to 6.
