A filtering method, filtering device and computer readable storage medium
By quantizing the input signals in computer vision tasks and Kalman filtering, a stable filtering signal is generated, which solves the problem of unstable output in the calculation of the proportion of segmented target area, and realizes filtering with strong anti-interference ability and high real-time performance Effect.
Patent Information
- Application Number
- CN202210508010.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2042-05-10
AI Technical Summary
In computer vision tasks, the calculation of the proportion of segmented target area due to the difference between the computing platform and the segmentation algorithm, resulting in large fluctuations in the number of target segmented pixels, resulting in a sudden change or continuous change in the proportion, and the output information is unstable.
By quantizing the input signal, the same continuous quantization value intervals are determined, and filtered signals based on these intervals are generated. The Kalman filtering method is used to filter to generate a stable filtered signal.
It realizes a stable output filter signal, strong anti-interference ability, high real-time performance, can maintain a relatively stable output under large fluctuations, and has strong applicability.
Smart Images

Figure CN114998118B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a filtering method, a filtering device, and a computer-readable storage medium. Background Art
[0002] In computer vision tasks, it is often necessary to calculate the proportion of the segmented target area. However, due to differences in computing platforms and segmentation algorithms, as well as occlusion or slight disturbances of targets in the image, the number of target segmentation pixels in continuous time is different, and the number of difference pixels ranges from thousands to tens of thousands of pixels, causing sudden or continuous changes in the proportion value, resulting in continuous changes in the output information rather than outputting a stable value. Therefore, how to output a stable number of pixels has become an urgent problem to be solved. Summary of the invention
[0003] The present application provides a filtering method, a filtering device and a computer-readable storage medium, which can output a stable filtering signal with strong anti-interference ability and high real-time performance.
[0004] To solve the above technical problems, the technical solution adopted in the present application is: to provide a filtering method, the method comprising: obtaining a first input signal; quantizing the first input signal to obtain a quantized signal, the quantized signal comprising multiple quantized values; based on the quantized signal, determining at least one signal interval, the signal interval comprising consecutive and identical quantized values whose number is greater than a preset number threshold; based on the signal interval, generating a second input signal; filtering the second input signal to obtain a filtered signal.
[0005] In order to solve the above technical problems, another technical solution adopted by the present application is: to provide a filtering device, the filtering device comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the filtering method in the above technical solution.
[0006] To solve the above technical problem, another technical solution adopted in the present application is: providing a computer-readable storage medium, which is used to store a computer program. When the computer program is executed by a processor, it is used to implement the filtering method in the above technical solution.
[0007] Through the above scheme, the beneficial effects of the present application are: first, the acquired first input signal is quantized to obtain a quantized signal, which includes multiple quantized values; then, the number of consecutive identical quantized values in the first input signal is obtained, and the number is compared with a preset number threshold to obtain at least one signal interval, which includes consecutive identical quantized values whose number is greater than the preset number threshold; then, all signal intervals are used to generate a second input signal; and then the second input signal is filtered to obtain a filtered signal; since the first input signal is quantized and consecutive identical quantized values are obtained to generate an input signal for the filtering operation (i.e., the second input signal), a filtered signal with smaller fluctuations can be obtained and does not deviate from the first input signal, and has a stronger anti-interference ability; moreover, the real-time performance of the present scheme is higher, and it is easier to apply to other schemes, and it can perform stability filtering on similar data, and has a stronger applicability. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0009] Figure 1 It is a flow chart of an embodiment of a filtering method provided by the present application;
[0010] Figure 2 is a flow chart of another embodiment of the filtering method provided by the present application;
[0011] Figure 3 is a schematic diagram of the quantification process provided by the present application;
[0012] Figure 4 It is a schematic diagram of the connection stabilization point provided by the present application;
[0013] Figure 5 is a schematic diagram of a first input signal and a filtered signal provided by the present application;
[0014] Figure 6 It is a structural schematic diagram of an embodiment of a filtering device provided by the present application;
[0015] Figure 7 It is a structural schematic diagram of an embodiment of a computer-readable storage medium provided by the present application. DETAILED DESCRIPTION
[0016] The present application is further described in detail below in conjunction with the accompanying drawings and examples. It is particularly noted that the following examples are only used to illustrate the present application, but are not intended to limit the scope of the present application. Similarly, the following examples are only some embodiments of the present application rather than all embodiments, and all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
[0017] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0018] It should be noted that the terms "first", "second" and "third" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first", "second" and "third" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0019] Although some solutions in the related art can achieve relatively stable output when data fluctuations are small and data accuracy is high, they cannot process continuous signals with large fluctuations and cannot guarantee stable output; based on this, the present application provides a new solution, which is described in detail below.
[0020] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of a filtering method provided by the present application. The execution subject of the present solution is a filtering device, which can be a device with computing functions such as a computer. The method includes:
[0021] S11: Acquire a first input signal.
[0022] A first input signal (i.e., original input signal) sent by other devices may be received, or the first input signal may be captured by the device itself, and the first input signal may include multiple data values. Specifically, the first input signal may be the proportion of the segmented area, i.e., the number of pixels corresponding to the segmented area, for example, the proportion of segmented area A in the first frame image is 5000, and the proportion of segmented area A in the second frame image is 7500.
[0023] It can be understood that the solution of this embodiment involves fields such as computer vision and image processing, especially fields such as image segmentation, filtering and tracking, but this embodiment is not only applicable to filtering the proportion of segmented areas, but also to filtering other signals.
[0024] S12: Perform quantization processing on the first input signal to obtain a quantized signal.
[0025] After the first input signal is acquired, the first input signal may be quantized to generate a corresponding processed signal (ie, a quantized signal), wherein the quantized signal includes a plurality of quantized values, and the quantized values correspond one-to-one to the data values in the first input signal.
[0026] S13: Determine at least one signal interval based on the quantized signal.
[0027] After obtaining the quantization signal, the quantization values in the quantization signal are processed to determine whether the consecutive quantization values are the same. If there are multiple consecutive identical quantization values, the number of identical quantization values is compared with a preset number threshold set in advance to generate a signal interval, which includes consecutive identical quantization values whose number is greater than the preset number threshold.
[0028] S14: Generate a second input signal based on the signal interval.
[0029] After the signal interval is acquired, the second input signal can be generated using all signal intervals; specifically, the quantization value in the signal interval is determined as the value of the second input signal, that is, the second input signal includes a quantization value that satisfies a preset condition, and the preset condition may be that the number of consecutive identical quantization values is greater than a preset number threshold, that is, if the number of consecutive identical quantization values is greater than the preset number threshold, the quantization value is placed in the second input signal. For example, assuming that the quantization signal includes A1 to A40, the preset number threshold is 7, assuming that A3 to A10 are the same, A20 to A30 are the same, and A32 to A38 are the same, then the quantization values in the second input signal include A3, A20, and A32.
[0030] S15: Filter the second input signal to obtain a filtered signal.
[0031] After the second input signal is acquired, the second input signal is filtered using a filtering method in the related art to generate a corresponding filtered signal.
[0032] The present embodiment provides a universal filtering scheme. In order to obtain an output signal with smaller fluctuations and not deviating from the original input signal, the original input signal is quantized and the number of consecutive identical quantization values is obtained to generate a second input signal. The filtered signal of the original input signal can be obtained by filtering the second input signal. The present embodiment has a strong anti-interference ability and can still obtain a relatively stable output when the original input signal fluctuates greatly. Moreover, the present embodiment has high real-time performance and is easier to integrate into other schemes, and can perform stability filtering on similar data.
[0033] See also Figure 2 , Figure 2 : is a flow chart of another embodiment of the filtering method provided by the present application, the method comprising:
[0034] S21: Acquire a first input signal.
[0035] S21 is the same as S11 in the above embodiment and will not be described again.
[0036] S22: quantize each data value in the first input signal to an integer multiple of a preset quantization level to obtain a quantization value corresponding to each data value in the first input signal.
[0037] In order to quantize the first input signal input in real time, the ratio of the data value in the first input signal to the preset quantization level can be calculated first, and the ratio can be rounded to obtain a first value; then the first value is multiplied by the preset quantization level to obtain a corresponding quantization value; for example, taking the first input signal as the proportion of the segmented area as an example, assuming that the preset quantization level is 5, the following formula can be used for calculation:
[0038] ratio=INT(ratio / 5)*5 (1)
[0039] Among them, "INT" is the rounding up function.
[0040] S23: Obtain the number of consecutive identical quantization values in the quantization signal to obtain the current number.
[0041] After obtaining the quantization signal, the number of consecutive identical quantization values in the quantization signal can be obtained according to the time sequence of the quantization values in the quantization signal to obtain the current number. Specifically, the current number can be set to a first preset value, which is 0; then a quantization value is taken out from the quantization signal according to the time sequence to obtain the current quantization value; then it is determined whether the current quantization value is the same as the previous quantization value; if the current quantization value is the same as the previous quantization value, the sum of the current number and the preset step length is determined as the current number, and the preset step length can be 1.
[0042] It can be understood that when the current quantization value is different from the previous quantization value, the process returns to the step of taking out a quantization value from the quantization signal in chronological order to obtain the current quantization value.
[0043] S24: Determine whether the current quantity is greater than a preset quantity threshold.
[0044] After obtaining the number corresponding to the same continuous quantization value (ie, the current number), the current number may be compared with a preset number threshold to determine whether the current number is greater than the preset number threshold.
[0045] S25: If the current number is greater than a preset number threshold, the quantization values corresponding to the current number are combined into a signal interval.
[0046] If it is detected that the current number is greater than the preset number threshold, it indicates that there are many consecutive identical quantization values. At this time, the quantization value corresponding to the current number can be determined as a stable point, that is, the consecutive identical quantization value is extracted as a stable point. For example, the preset number threshold can be set to 8. After the consecutive identical quantization value is maintained for 8 times, it is identified as a stable point. For example, Figure 3 As shown in the figure, the curve ① represented by a solid line is a schematic diagram of the first input signal, and the flat part of the curve ② represented by a dotted line is the stable point generated after quantization processing.
[0047] It can be understood that after determining that the current number is greater than the preset number threshold, the process can return to the step of taking out a quantized value from the quantized signal in chronological order to obtain the current quantized value, so as to count all stable points.
[0048] S26: Connect two adjacent signal intervals to obtain a second input signal.
[0049] Determine whether each signal interval meets the preset conditions; if the signal interval meets the preset conditions, expand the signal interval so that the difference between the first moment and the second moment is less than or equal to the preset time threshold, the first moment is the moment corresponding to the last quantized value in the expanded signal interval, and the second moment is the moment corresponding to the first quantized value in the next signal interval.
[0050] Further, determine whether the order of the signal interval is the last one and whether the difference between the first moment and the second moment is greater than the preset time threshold. When the order of the signal interval is not the last one and the difference between the first moment and the second moment is greater than the preset time threshold, determine that the signal interval meets the preset conditions; otherwise, determine that the signal interval does not meet the preset conditions.
[0051] In one embodiment, after obtaining the stable point, the first input signal can be integerized using the stable point to obtain the second input signal; specifically, the stable point at the current moment is maintained until a new stable point is generated, for example, Figure 4 As shown, the curve ① represented by a dotted line is a schematic diagram of the first input signal, and the curve ② represented by a solid line is a schematic diagram of a signal generated after connecting the stable points (ie, the second input signal).
[0052] S27: Using a Kalman filtering method to filter the quantized value in the second input signal to obtain a current filtered estimated value.
[0053] The filtered signal includes a plurality of filtered output values corresponding to the quantized values in the second input signal, and can be filtered using the following scheme:
[0054] (1) Initialize the error parameters.
[0055] The initialization model of Kalman can be set as a constant model, and error parameters can be set for the region segmentation task. The error parameters include estimation error, observation error and process error, namely, initialization estimation error (P), observation error (Q) and process error (R).
[0056] Furthermore, since the first input signal is one-dimensional data, that is, this embodiment performs filtering on one-dimensional data, the estimation error, observation error and process error are all constants, which can be set to: P=360000, Q=8, R=40000.
[0057] (2) Select a quantized value from the second input signal in chronological order to obtain a current value to be filtered.
[0058] (3) Based on the previous estimation error and the previous process error, calculate the current Kalman gain.
[0059] The sum of the last estimated error and the last process error is calculated to obtain a third value, where the last estimated error is determined by the last Kalman gain and the observation error; the ratio of the last estimated error to the third value is calculated to obtain the current Kalman gain, that is, the current Kalman gain is calculated using the following formula:
[0060]
[0061] Where K is the current Karman gain.
[0062] (4) Generate a current filter estimate based on the current Kalman gain, the previous filter estimate, and the current value to be filtered.
[0063] To make the best estimate for the current state, the formula used is as follows:
[0064] X' t =X t +K(YX t ) (3)
[0065] Among them, X' t is the current filter estimate, X t is the previous filter estimate, and Y is the current value to be filtered.
[0066] (5) Based on the current Kalman gain and the previous estimation error, generate the current estimation error.
[0067] The difference between the second preset value and the current Kalman gain is calculated to obtain a sixth value, where the second preset value may be 1; the product of the sixth value and the previous estimated error is calculated to obtain the current estimated error, that is, the current estimated error is calculated using the following formula:
[0068] P'=(1-K)P (4)
[0069] Where P' is the current estimation error.
[0070] (6) Based on the current estimated error and the observed error, generate the next estimated error.
[0071] Based on the current system information, the next state information is predicted and the system parameters are updated at the same time. The specific formula is as follows:
[0072] X k =X' t (5)
[0073] P k =P'+Q (6)
[0074] Among them, X k is the filter estimate value at the next moment (referred to as the next filter estimate value), P k is the estimated error at the next moment (referred to as the next estimated error). From formula (6), we can see that the next estimated error can be obtained by calculating the sum of the current estimated error and the observed error.
[0075] It can be understood that when the next value to be filtered of the current value to be filtered arrives, similar processing can be performed according to the above steps (2)-(6) to achieve real-time filtering.
[0076] S28: Determine whether the difference between the current filtered estimated value and the quantized value falls within a preset error range.
[0077] Calculate the difference between the current filter estimate and the quantized value, and then determine whether the difference falls within a preset error range; for example, assuming the preset error range is [-H, H], it is equivalent to determining whether the absolute value of the difference is greater than H.
[0078] Furthermore, if the difference between the current filtered estimate and the quantized value does not fall within the preset error range, the step of returning to filtering the quantized value in the second input signal using the Kalman filtering method to obtain the current filtered estimate is performed until the difference between the current filtered estimate and the quantized value falls within the preset error range.
[0079] S29: If the difference between the current filter estimation value and the stable value falls within a preset error range, the current filter estimation value is determined as the filter output value.
[0080] After the constant model and parameters (including observation error and process error) are set, the filtering system tends to converge, the Kalman gain decreases, and the response to real mutation data is slow, so a restart mechanism is added. Specifically, the filtering result is subtracted from the filtered input signal. If the difference falls within the preset error range, it indicates that the difference between the two is small. At this time, the filter output value is the current filter estimate; if the difference does not fall within the preset error range, it indicates that the difference between the two is large. At this time, the error parameter can be reset and the filtering process can be restarted. That is, when the difference between the current filter estimate and the quantized value does not fall within the preset error range, return to the step of initializing the error parameter, that is, return to the above step (1); for example, the parameter H can be set to 200, that is, for time k, if |X k -Y|>200, then return to the above step (1).
[0081] In one embodiment, Kalman filtering is performed on the stable points extracted in real time to obtain Figure 5 As shown in the schematic diagram, curve ① represented by a dotted line is the first input signal, and curve ② represented by a solid line is the filtered signal corresponding to the first input signal. It can be seen that compared with the first input signal, the filtered signal is relatively smooth.
[0082] This embodiment combines the principle of Kalman filtering, and obtains relatively stable data (i.e., stable points) from a complex first input signal by adopting a method of pre-quantization and stable point identification; after establishing a constant model, the stable points are tracked by Kalman filtering so that the real-time output filter output value fluctuates less and does not deviate from the stable data in the first input signal; moreover, the input signal of the Kalman filter in this scheme is a stable point, rather than all the original input signals, which can reduce the amount of filtered data, reduce the amount of filtering processing tasks, consume less computing resources, and can be integrated in surveillance cameras or other embedded platforms in related technologies; moreover, a restart mechanism is set in the filtering system to prevent the filtering system from deviating from the output range of the actual data; in addition, the real-time performance of this embodiment is relatively high, and it can tolerate fluctuation noise to a large extent.
[0083] See also Figure 6 , Figure 6 It is a structural diagram of an embodiment of a filtering device provided in the present application. The filtering device 60 includes a memory 61 and a processor 62 connected to each other. The memory 61 is used to store a computer program. When the computer program is executed by the processor 62, it is used to implement the filtering method or gait recognition method in the above-mentioned embodiment.
[0084] See also Figure 7 , Figure 7 It is a structural diagram of an embodiment of a computer-readable storage medium provided in the present application. The computer-readable storage medium 70 is used to store a computer program 71. When the computer program 71 is executed by a processor, it is used to implement the filtering method or gait recognition method in the above-mentioned embodiment.
[0085] The computer-readable storage medium 70 may be a server, a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other media that can store program codes.
[0086] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.
[0087] In the several embodiments provided in this application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only illustrative, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0088] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0089] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0090] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A filtering method, It is characterized in that include: Obtaining a first input signal; quantizing the first input signal to obtain a quantized signal, wherein the quantized signal includes a plurality of quantized values; Based on the quantized signal, determining at least one signal interval, wherein the signal interval includes consecutive quantized values that are the same and whose number is greater than a preset number threshold; The step of determining at least one signal interval based on the quantized signal includes: obtaining the number of consecutive identical quantized values in the quantized signal to obtain a current number; determining whether the current number is greater than the preset number threshold; if so, forming the signal interval with the quantized values corresponding to the current number; Based on the signal interval, generating a second input signal; The step of generating a second input signal based on the signal interval includes: determining a quantized value in the signal interval as a value of the second input signal; The second input signal is filtered to obtain a filtered signal.
2. The filtering method according to claim 1, It is characterized in that The step of quantizing the first input signal to obtain a quantized signal comprises: Each data value in the first input signal is quantized to an integer multiple of a preset quantization level to obtain a quantization value corresponding to each data value in the first input signal.
3. The filtering method according to claim 1, It is characterized in that The step of generating a second input signal based on the signal interval comprises: Two adjacent signal intervals are connected to obtain the second input signal.
4. The filtering method according to claim 3, It is characterized in that Before the step of connecting two adjacent signal intervals to obtain the second input signal, the method includes: Determining whether the signal interval meets a preset condition; If so, the signal interval is expanded so that the difference between the first moment and the second moment is less than or equal to a preset time threshold, the first moment is the moment corresponding to the last quantized value in the expanded signal interval, and the second moment is the moment corresponding to the first quantized value in the next signal interval.
5. The filtering method according to claim 4, It is characterized in that The step of determining whether the signal interval meets a preset condition comprises: When the signal interval is not the last one and the difference between the first moment and the second moment is greater than the preset time threshold, it is determined that the signal interval meets the preset condition.
6. The filtering method according to claim 1, It is characterized in that The filtered signal includes a plurality of filtered output values corresponding to the quantized values, and the step of filtering the second input signal to obtain the filtered signal includes: Using a Kalman filter method to filter the quantized value in the second input signal to obtain a current filtered estimated value; Determine whether the difference between the current filtered estimated value and the quantized value falls within a preset error range; If so, determining the current filtered estimated value as the filtered output value; If not, return to the step of filtering the quantized value in the second input signal using the Kalman filtering method to obtain a current filtered estimated value, until the difference between the current filtered estimated value and the quantized value falls within the preset error range.
7. The filtering method according to claim 6, It is characterized in that The step of filtering the quantized value in the second input signal using the Kalman filtering method to obtain a current filtered estimated value comprises: Initializing error parameters, wherein the error parameters include estimated error, observed error, and process error; Selecting a quantized value from the second input signal in chronological order to obtain a current value to be filtered; Calculating a current Kalman gain based on a previous estimated error and a previous process error, wherein the previous estimated error is determined by a previous Kalman gain and the observation error; Generate the current filtered estimated value based on the current Kalman gain, the previous filtered estimated value and the current value to be filtered; The method further comprises: When the difference between the current filtered estimated value and the quantized value does not fall within the preset error range, return to the step of initializing the error parameter.
8. A filtering device, It is characterized in that The invention comprises a memory and a processor connected to each other, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, it is used to implement the filtering method according to any one of claims 1 to 7.
9. A computer-readable storage medium for storing a computer program, It is characterized in that When the computer program is executed by a processor, it is used to implement the filtering method according to any one of claims 1 to 7.
