Multi-frame difference detection algorithm of self-adaptive threshold
By adopting the method of adaptive threshold and weight weighted fusion in the multi-frame differential detection algorithm, detection problems under environmental changes, noise interference and complex backgrounds are solved, and detection accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202510143036.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-10
- Publication Date
- 2025-06-20
AI Technical Summary
When faced with environmental changes, noise interference and complex backgrounds, existing multi-frame differential detection algorithms have problems such as false detection, missed detection and lack of adaptability, resulting in insufficient accuracy and robustness of detection.
Using a multi-frame differential detection algorithm with adaptive thresholds, a frame window containing continuous k frames is set, image alignment and difference operations are performed, differential image weights are assigned to weight fusion, and the threshold is dynamically adjusted to adapt to environmental changes.
It effectively reduces the impact of environmental changes, noise interference and complex backgrounds on detection, improves the real-time, robustness and accuracy of detection, and is suitable for infrared detection and other complex object detection fields.
Smart Images

Figure CN120182327A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of moving target detection, and particularly relates to a multi-frame inter-frame difference detection algorithm with an adaptive threshold. Background Art
[0002] The multi-frame inter-frame difference method is a moving target detection technology that identifies moving objects in a scene by comparing consecutive multi-frame images; compared with the double-frame and triple-frame inter-frame difference methods, the multi-frame inter-frame difference method increases the computational amount and algorithm complexity, but improves the detection performance in complex and harsh environments and reduces the influence of factors such as illumination changes, shadow interference, and high background complexity.
[0003] The threshold setting in the multi-frame difference algorithm is a very crucial step; the choice of threshold directly affects the accuracy and robustness of moving target detection; in practical applications, the choice of threshold needs to balance multiple factors, including noise suppression, adaptability to illumination changes, and sensitivity to moving targets, etc.; the contradictions in threshold selection include but are not limited to: (1) the influence of environmental changes: when using a fixed threshold, the algorithm is very sensitive to changes in illumination conditions. If the light in the scene suddenly brightens or darkens, even if there is no actual movement, the pixel difference between adjacent frames may exceed the preset threshold, resulting in a large number of "false" moving areas being misdetected; in low-light environments, real movement may not trigger the threshold condition due to insufficient brightness, causing missed detection problems; weather factors such as rain, snow, and fog will also affect the image quality and thus affect the target recognition result; (2) noise problems: there are various forms of noise in the video sequence, including the thermal noise of the camera itself, interference during transmission, etc.; if a fixed threshold is adopted, it is difficult to distinguish the pixel changes caused by real movement from the fluctuations caused by random noise, especially in low-contrast or high-noise environments, this distinction becomes more difficult; too low a threshold will cause a large number of noise points to be wrongly marked as moving areas, while too high a threshold will mask some subtle but important movement information; (3) poor performance in complex backgrounds: in complex backgrounds containing rich details or frequently changing elements, such as swaying leaves and sparkling water surfaces, the method of using a fixed threshold is more prone to false alarms because such scenes themselves contain a lot of temporal and spatial changes, and even if there are no obvious moving objects, many seemingly reasonable differential signals will be generated; at this time, simple binary processing is difficult to accurately separate the real moving target; (4) lack of adaptability: using a set fixed threshold lacks the ability to detect dynamic environmental changes. As the relationship between the background and the foreground changes over time and space, ideally, the system should be allowed to automatically adjust parameters according to the current situation; however, a fixed threshold cannot do this and can only be optimized once under specific conditions, and once the environment changes, the threshold needs to be recalibrated or manually modified, which is disadvantageous for applications running for a long time.
[0004] Currently, when users utilize the multi-frame detection algorithm, they usually make qualitative estimations based on experience, then set fixed thresholds, and repeatedly trial and error until the optimal threshold is found. Once the environment or other factors change, the threshold needs to be readjusted again, resulting in blindness and inaccuracy in practical applications. Summary of the Invention
[0005] The objective of the present invention is to overcome the deficiencies of the prior art and provide a multi-frame differential detection algorithm with an adaptive threshold, so as to solve the adverse effects of factors such as environmental changes, noise interference, and complex environments, and achieve the real-time performance, robustness, and accuracy of the application.
[0006] The technical solution adopted by the present invention is as follows:
[0007] A multi-frame differential detection algorithm with an adaptive threshold adopts a threshold weighted fusion calculation method. The specific steps are as follows:
[0008] S1: Set a frame window containing k consecutive frames, perform an alignment operation on the first k - 1 frame images and the current frame image, and use image alignment to eliminate the position deviation caused by jitter, etc.
[0009] S2: Perform a differential operation on each of the aligned first k - 1 frame images and the current frame image to obtain k - 1 differential images. This process is expressed as:
[0010] Assume that f1(x, y) is the grayscale image of the current frame. Within the frame window of k consecutive frames, the k grayscale images from the current frame can be expressed as f k (x, y). Then the k - 1 differential images can be expressed as:
[0011] d k-1 (x, y) = |f1(x, y) - f k (x, y)|;
[0012] S3: Assign a set of weights {w1, w2,..., w k-1} to each differential image, perform a weighted sum on all differential images to obtain a fused weighted differential image W(x, y), which can be expressed as:
[0013]
[0014] S4: Select the maximum value of the fused weighted differential image as the threshold T; compare each pixel of W(x, y) with the threshold T. Pixels greater than or equal to the threshold T are identified as targets, otherwise they are identified as the background, and a motion representation frame image b(x, y) is obtained, thereby preliminarily determining the target position. This process is expressed as:
[0015]
[0016] S5: Based on the target position determined in S4, perform connected component analysis. If the regions are connected, it is identified as the same target; otherwise, it is considered multiple targets. Finally, determine the number of targets N.
[0017] S6: Use the threshold T to perform target detection operations. Determine whether the number of detected targets N meets the requirement of the maximum number limit M (i.e., the maximum tolerance limit) detected by the optical device. If N is less than or equal to M, then set T = T - 1, and repeat the operations in steps S4 and S5; stop until N is greater than M. At this time, set T min = T + 1, and T min is the optimal detection threshold under the maximum detection target constraint and is also the most sensitive threshold.
[0018] S7: Use the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target positions, and mark the detected targets on the image with red rectangular frames for subsequent actual visualization applications.
[0019] S8: In practice, since frame images are usually continuous, repeat the operations from S1 to S7 for all images to be processed in chronological order until the task ends.
[0020] An adaptive threshold multi-frame inter-frame difference detection algorithm uses a logical AND operation method. The specific steps are as follows:
[0021] S1: Set a frame window containing k consecutive frames, align the first k - 1 frame images with the current frame image, and use image alignment to eliminate position deviations caused by jitter, etc.
[0022] S2: Perform difference operations between the aligned first k - 1 frame images and the current frame image respectively to obtain k - 1 difference images. This process is expressed as:
[0023] Assume that f1(x, y) is the grayscale image of the current frame. Within the frame window of k consecutive frames, the k grayscale images from the current frame can be expressed as f k (x, y). Then the k - 1 difference images can be expressed as:
[0024] d k-1 (x, y) = |f1(x, y) - f k (x, y)|;
[0025] S3: Select the maximum value of all difference images to obtain the maximum values of the k - 1 difference images, and select the minimum value among these maximum values as the threshold T. Compare the pixels of the difference images with the threshold T respectively. For pixels greater than or equal to the threshold T, take 1; otherwise, take 0 to obtain the motion representation frame image b1 t-1 (x, y); This process is expressed as:
[0026]
[0027] S4: Perform a logical AND operation on all motion representation frame images to obtain the fused image b2(x, y), and this process is expressed as:
[0028] b2(x, y) = b11(x, y) & b12(x, y) &... & b1 k-1 (x, y)
[0029] The positions where the pixels of b2(x, y) are 1 are preliminarily determined as moving targets;
[0030] S5: According to the target positions determined in S4, perform connectivity analysis. If the regions are connected, they are recognized as the same target; otherwise, they are considered multiple targets. Finally, determine the number of targets N;
[0031] S6: Use the threshold T to perform target detection operations, and determine whether the number of detected targets meets the requirement of the maximum number limit M detected by the optical device, that is, the maximum tolerance limit. If N is less than or equal to M, then set T = T - 1, and repeat the operations in steps S4 and S5; stop until N is greater than M. At this time, set T min = T + 1, T min is the optimal detection threshold under the constraint of the maximum detected targets, and it is also the most sensitive threshold;
[0032] S7: Use the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target positions, and mark the detected targets on the image with red rectangular frames for subsequent actual visualization applications;
[0033] S8: In practice, since the frame images are usually continuous, during processing, the operations in S1 to S7 can be repeated for all images to be processed in chronological order until the task ends.
[0034] An adaptive threshold multi-frame inter-frame difference detection algorithm, adopting a logical OR operation method, and the specific steps are as follows:
[0035] S1: Set a frame window containing k consecutive frames, perform alignment operations on the first k - 1 frame images and the current frame image, and use image alignment to eliminate the position deviations caused by jitter, etc.;
[0036] S2: Perform difference operations on the aligned first k - 1 frame images and the current frame image respectively to obtain k - 1 difference images, and this process is expressed as:
[0037] Assume that f1(x, y) is the grayscale image of the current frame. Within the frame window of k consecutive frames, the k grayscale images from the current frame can be expressed as f k(x, y), then the k - 1 differential images can be expressed as:
[0038] d k-1 (x, y) = |f1(x, y) - f k (x, y)|;
[0039] S3: Select the maximum value of all differential images to obtain the maximum values of the k - 1 differential images. Then select the maximum value among these maximum values as the threshold T. Compare the pixels of the differential images with the threshold T respectively. For pixels greater than or equal to the threshold T, take 1, otherwise take 0, to obtain the motion representation frame image b1 k-1 (x, y); This process is expressed as:
[0040]
[0041] S4: Perform a logical OR operation on all differential images to obtain the fused image b3(x, y). This process is expressed as:
[0042] b3(x, y) = b11(x, y) OR b12(x, y) OR … OR b1 k-1 (x, y)
[0043] The positions where the pixels of b3(x, y) are 1 are preliminarily determined as moving targets, otherwise they are considered as the background;
[0044] S5: According to the target positions determined in S4, perform connectivity analysis. If the regions are connected, they are identified as the same target, otherwise they are considered as multiple targets. Finally, determine the number of targets N;
[0045] S6: Use the threshold T to perform target detection operations. Judge whether the number of detected targets meets the requirement of the maximum number limit that can be detected by the optical device, that is, the maximum tolerance limit M. If N is less than or equal to M, then let T = T - 1, and repeat the operations in steps S4 and S5; Stop until N is greater than M. At this time, let T min = T + 1, T min is the optimal detection threshold under the constraint of the maximum detected target, and it is also the most sensitive threshold;
[0046] S7: Use the updated optimal detection threshold T min , perform S4 and S5 to obtain the final detected target positions, and mark the detected targets on the image with red rectangular frames for subsequent actual visualization applications;
[0047] S8: In practice, since the frame images are usually continuous, when processing, the operations in S1 to S7 can be repeated for all images to be processed in chronological order until the task ends.
[0048] Due to the adoption of the above - mentioned technical solution, the present invention has the following advantages:
[0049] An adaptive threshold multi-frame differential detection algorithm of the present invention effectively solves problems such as the influence of environmental changes, internal and external noise interference, and poor performance in complex background environments of the fixed threshold algorithm for multi-frame differential detection, and improves the disadvantages of real-time performance, robustness, and accuracy that the fixed threshold differential detection algorithm does not have. This algorithm is not only applicable to target detection fields such as infrared detection, but can also be migrated to other complex target detection fields that require high precision and high timeliness, and has broad application prospects. Brief Description of the Drawings
[0050] Figure 1 It is a schematic flowchart of Embodiment 1 of the present invention.
[0051] Figure 2 It is a schematic flowchart of Embodiment 2 of the present invention.
[0052] Figure 3 It is a schematic flowchart of Embodiment 3 of the present invention.
[0053] Figure 4 It is a scene situation table of the weak aircraft target detection and tracking dataset in the ground / air background in the embodiments of the present invention.
[0054] Figure 5 It is the first 5 frames of images of the UAV target after alignment processing in the data21 dataset in the embodiments of the present invention.
[0055] Figure 6 It is the final detection result diagram of Embodiment 1 of the present invention.
[0056] Figure 7 It is the result diagram of the optimal detection threshold of each frame image in Embodiment 1 of the present invention.
[0057] Figure 8 It is the final detection result diagram of Embodiment 2 of the present invention.
[0058] Figure 9 It is the result diagram of the optimal detection threshold of each frame image in Embodiment 2 of the present invention.
[0059] Figure 10 It is the final detection result diagram of Embodiment 3 of the present invention.
[0060] Figure 11 It is the result diagram of the optimal detection threshold of each frame image in Embodiment 3 of the present invention. Detailed Embodiments
[0061] The present invention will be further explained below in conjunction with the drawings and embodiments. The protection scope of the present invention cannot be limited hereby. The purpose of disclosing the present invention is to protect all technical improvements within the scope of the present invention.
[0062] The embodiments of the present invention are all implemented relying on a computer equipped with an AMD Ryzen 5 5600K CPU, 16GB RAM, RTX3060 GPU hardware functions, and MATLAB 2024a software; the dataset is selected as the "Infrared Image Small Aircraft Target Detection and Tracking Dataset under Ground / Air Background", as Figure 2 shown. This dataset is provided by the ATR Key Laboratory of the School of Electronic Science, National University of Defense Technology, providing 21 types of frame sequence infrared image data and having relatively complete information markings; the image data for this data collection is captured by an infrared device with a frequency of 100Hz, and the maximum detection tolerance limit M of the detection device is 5. Since the higher the frequency of infrared shooting, the less obvious the spatio-temporal change of the target between frame sequences, making it difficult to be detected; therefore, usually the method of reducing the frequency is adopted, with a step size of 4 frames; in order to simulate long-distance detection under complex backgrounds, the data21 dataset is selected, which is one of the two datasets with the lowest signal-to-noise ratio. The signal-to-noise ratio describes the difficulty of detecting small infrared targets. Usually, the lower the signal-to-noise ratio, the more difficult it is to detect the target; in the embodiment, the detection probability is the number of frames correctly detecting the target divided by the total number of image frames.
[0063] Embodiment 1
[0064] An adaptive threshold multi-frame inter-frame difference detection algorithm, the specific steps are as follows:
[0065] Execute S1. First, take the first 5 frames of images, and use the 5th frame of image as a reference for alignment operations. Adopt the method based on feature point alignment to eliminate the position deviation caused by jitter and the like through image alignment; the current frame of image is as Figure 5 (a) shown, and the four frames of images after alignment processing are as Figure 5 (b) to (e) shown.
[0066] Execute S2. Perform difference operations on the current frame of image and the first 4 subsequent frame images respectively to obtain 4 difference images.
[0067] Execute S3. Assign an average weight to each difference image, that is Perform weighted summation on all images to obtain a fused weighted difference image.
[0068] Execute S4. Select the maximum value of the fused weighted difference image respectively to obtain the threshold T as 103. Compare the fused weighted image with the threshold T, take the positions greater than or equal to T as 1, calculate the positions where the pixel is 1, and initially determine the target position.
[0069] Execute S5. According to the target position determined in S4, perform connectivity analysis. If the regions are connected, it is considered the same target, otherwise it is considered multiple targets, and obtain the current number of detected targets N as 1.
[0070] Execute S6, perform target detection operations using the threshold T, and determine whether the number of detected targets meets the requirement of the maximum number limit M detected by the optical device, i.e., the maximum tolerance limit M; from S5, N is 1. Since M is 5, N is less than M. Let T = T - 1, and repeat the operations in steps S4 and S5 until N is greater than 5 and then stop. At this time, let T min = T + 1 to obtain T min = 38, T min is the optimal detection threshold under the constraint of the maximum detected target, and it is also the most sensitive threshold.
[0071] Execute S7, use the updated optimal detection threshold T min , execute S4 and S5 to obtain the final positions of the detected targets, and mark the detected targets on the image with red rectangular frames for subsequent actual visualization applications; as Figure 6 shown, a total of 5 targets are detected, meeting the requirement that the maximum detected number is less than or equal to 5. Among them, all 5 are false targets, and it is determined that no target is detected.
[0072] S8: Repeat the operations in S1 to S7 for all images to be processed in chronological order until the task ends; as Figure 7 shown, when processing 121 frames of images, it can be seen that under the condition of meeting the maximum tolerance limit, the target detection threshold of each frame of image is different and adaptively changes according to changes in information such as the background and target positions; the detection probability of the 121-frame image targets in this embodiment is 76.86%.
[0073] Embodiment 2
[0074] A multi-frame inter-frame difference detection algorithm with an adaptive threshold, and the specific steps are as follows:
[0075] Execute S1. First, take the first 5 frames of images, and use the 5th frame of image as a reference for alignment operations. Adopt a method based on feature point alignment to eliminate the position deviation caused by jitter and the like using image alignment. The current frame of image is as Figure 5 (a) shown, and the four frames of images after alignment processing are as Figure 5 (b) to (e) shown.
[0076] Execute S2, perform difference operations on the current frame of image and the first 4 subsequent frames of images respectively to obtain 4 difference images.
[0077] Execute S3, select the maximum values of the 4 difference images to obtain 4 maximum values of the difference images, which are: 163, 160, 78, 20. Take the minimum value among these maximum values to obtain the threshold T as 20. Compare the pixels of the difference images with the threshold T respectively. For pixels greater than or equal to the threshold T, take 1, otherwise take 0, to obtain 4 frame motion representation images.
[0078] Execute S4, perform a logical AND operation on all motion representation frame images to obtain the fused image b2(x, y). The positions where the pixels of b2(x, y) are 1 are preliminarily determined as moving targets.
[0079] Execute S5. According to the target positions determined in S4, perform connectivity analysis. If the regions are connected, they are identified as the same target; otherwise, they are considered multiple targets. Finally, determine that the number of targets N is 1.
[0080] Execute S6, perform target detection operations using the threshold T, and determine whether the number of detected targets meets the requirement of the maximum number limit M detected by the optical device, that is, the maximum tolerance limit. Since N is 1 obtained from S5 and M is 5, so N is less than M. Let T = T - 1, and repeat the operations in steps S4 and S5 until N is greater than 5 and then stop. At this time, let T min = T + 1, and obtain T min = 10, T min is the optimal detection threshold under the constraint of the maximum detected target, and it is also the most sensitive threshold.
[0081] Execute S7, use the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target positions, and mark the detected targets on the image with red rectangles for subsequent actual visualization applications; as Figure 8 shown, a total of 5 targets are detected, meeting the requirement that the maximum detected number is less than or equal to 5. Among them, 1 is a real target and 4 are false targets, and it is determined that targets are detected.
[0082] S8: Repeat the operations in S1 to S7 for all images to be processed in chronological order until the task ends; as Figure 9 shown, when processing 121 frame images, it can be seen that under the condition of meeting the maximum tolerance limit, the target detection thresholds of each frame image are different and adaptively change according to changes in information such as the background and target positions; the detection probability of the 121 frame image targets in this embodiment is 66.94%.
[0083] Embodiment 3
[0084] An adaptive threshold multi-frame inter-frame difference detection algorithm, the specific steps are as follows:
[0085] Execute S1. First, take the first 5 frame images, use the 5th frame image as a reference, perform alignment operations, and adopt a feature point-based alignment method to eliminate the position deviation caused by jitter and the like using image alignment. The current frame image is as Figure 5 (a) shown, and the four frame images after alignment processing are as Figure 5 (b) to (e) shown.
[0086] Execute S2, perform differential operations on the current frame image and the first 4 frame images following it respectively to obtain 4 differential images.
[0087] Execute S3, obtain the maximum values of the 4-frame differential images to get 4 maximum values of the differential images, which are: 163, 160, 78, 20 respectively. Take the maximum value among these maximum values to get T as 163. Compare the pixels of the differential images with the threshold T respectively. For pixels greater than or equal to the threshold T, take 1, otherwise take 0, to obtain 4-frame motion representation frame images.
[0088] Execute S4, perform a logical OR operation on all the motion representation frame images to obtain the fused image b3(x, y). The positions where the pixels of b3(x, y) are 1 are preliminarily determined as moving targets.
[0089] Execute S5, perform connectivity analysis based on the target positions determined in S4. If the regions are connected, they are recognized as the same target, otherwise they are considered as multiple targets. Finally, determine that the number of targets N is 1.
[0090] Execute S6, perform target detection operations using the threshold T, and determine whether the number of detected targets meets the requirement of the maximum number limit M detected by the optical device, that is, the maximum tolerance limit M; from S5, N is 1. Since M is 5, so N is less than M. Let T = T - 1, and repeat the operations in steps S4 and S5 until N is greater than 5 and then stop. At this time, let T min = T + 1, to obtain T min = 57, T min is the optimal detection threshold under the constraint of the maximum detected targets, and is also the most sensitive threshold.
[0091] Execute S7, use the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target positions, and mark the detected targets on the image with red rectangles for subsequent actual visualization applications; as Figure 10 shown, a total of 4 targets are detected, meeting the requirement that the maximum detected number is less than or equal to 5. Among them, 1 is a real target and 3 are false targets, and it is determined that targets are detected.
[0092] S8: Repeat the operations in S1 to S7 for all the images to be processed in chronological order until the task ends; as Figure 11 shown, when processing 121 frame images, it can be seen that under the condition of meeting the maximum number, that is, the tolerance limit M, the target detection thresholds of each frame image are different and adaptively change according to the changes of information such as the background and target positions, etc.; the detection probability of the 121-frame image targets in this embodiment is 59.50%.
[0093] The parts not detailed in the present invention are prior arts.
[0094] The embodiments selected herein for the purpose of disclosing the invention of the present invention are currently considered to be suitable. However, it should be understood that the present invention is intended to cover all variations and improvements of all embodiments that fall within the scope of this concept and invention.
Claims
1. An adaptive threshold multi-frame difference detection algorithm adopts a threshold weighted fusion calculation method, and the specific steps are: S1: Set a frame window containing k consecutive frames, align the previous k-1 frame images with the current frame image, and use image alignment to eliminate position deviations caused by jitter; S2: Perform differential operations on the first k-1 aligned frame images and the current frame image to obtain k-1 differential images. The process is expressed as: Assume that f1(x, y) is the grayscale image of the current frame. In the frame window of consecutive k frames, the grayscale image k away from the current frame can be expressed as f k (x, y), then the k-1 difference images can be expressed as: d k-1 (x,y)=|f1(x,y)-f k (x,y)|; S3: Assign each differential image a set of weights {w1, w2, ..., w k-1 }, perform weighted summation on all difference images to obtain the fused weighted difference image W(x, y), which can be expressed as: S4: Select the maximum value of the fused weighted difference image as the threshold T; compare W(x, y) with the threshold T pixel by pixel, and the pixels greater than or equal to the threshold T are identified as the target, otherwise they are identified as the background, and the motion representation frame image b(x, y) is obtained, thereby preliminarily determining the target position. The process is expressed as: S5: According to the target position determined in S4, a connected domain analysis is performed. If the regions are connected, they are considered to be the same target. Otherwise, they are considered to be multiple targets. Finally, the number of targets N is determined. S6: Determine whether the number of detected targets N meets the maximum number limit detected by the optical device, that is, the maximum tolerance value M. If N is less than or equal to M, set T = T-1 and repeat the operations of steps S4 and S5 until N is greater than M. At this time, set T min =T+1,T min That is, it is the optimal detection threshold under the constraint of the maximum detection target, and it is also the most sensitive threshold; S7: Using the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target position, and mark the detected target on the image with a red rectangular frame for subsequent actual visualization applications; S8: In practice, since frame images are usually continuous, the operations from S1 to S7 are repeated for all images to be processed in chronological order until the task is completed.
2. An adaptive threshold multi-frame difference detection algorithm, using a logical AND operation method, the specific steps are: S1: Set a frame window containing k consecutive frames, align the previous k-1 frame images with the current frame image, and use image alignment to eliminate position deviations caused by jitter; S2: Perform differential operations on the first k-1 aligned frame images and the current frame image to obtain k-1 differential images. The process is expressed as: Assume that f1(x, y) is the grayscale image of the current frame. In the frame window of consecutive k frames, the grayscale image k away from the current frame can be expressed as f k (x, y), then the k-1 difference images can be expressed as: d k-1 (x,y)=|f1(x,y)-f k (x,y)|; S3: Select the maximum value of all differential images to obtain k-1 differential image maximum values, select the minimum value among these maximum values as the threshold T, compare the differential image pixels with the threshold T respectively, take 1 for pixels greater than or equal to the threshold T, otherwise take 0, and obtain the motion representation frame image b1 t-1 (x, y); the process is expressed as: S4: Perform a logical AND operation on all motion representation frame images to obtain the fused image b2 (x, y). The process is expressed as: b2(x,y)=b11(x,y)&b12(x,y)&…&b1 k-1 (x,y), The position where the pixel b2(x, y) is 1 is preliminarily determined as a moving target; S5: Perform connectivity analysis based on the target location determined in S4. If the regions are connected, they are considered to be the same target. Otherwise, they are considered to be multiple targets. Finally, the number of targets N is determined. S6: Determine whether the number of detected targets meets the maximum number limit detected by the optical device, that is, the maximum tolerance value M. If N is less than or equal to M, set T = T-1 and repeat the operations of steps S4 and S5 until N is greater than M. At this time, set T min =T+1,T min That is, it is the optimal detection threshold under the constraint of the maximum detection target, and it is also the most sensitive threshold; S7: Using the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target position, and mark the detected target on the image with a red rectangular frame for subsequent actual visualization applications; S8: In practice, since frame images are usually continuous, during processing, the operations from S1 to S7 can be repeated for all images to be processed in chronological order until the task is completed.
3. An adaptive threshold multi-frame difference detection algorithm, using a logical OR operation method, the specific steps are: S1: Set a frame window containing k consecutive frames, align the previous k-1 frame images with the current frame image, and use image alignment to eliminate position deviations caused by jitter; S2: Perform differential operations on the first k-1 aligned frame images and the current frame image to obtain k-1 differential images. The process is expressed as: Assume that f1(x, y) is the grayscale image of the current frame. In the frame window of consecutive k frames, the grayscale image k away from the current frame can be expressed as f k (x, y), then the k-1 difference images can be expressed as: d k-1 (x,y)=|f1(x,y)-f k (x,y)|; S3: Select the maximum value of all differential images to obtain k-1 differential image maximum values, select the maximum value among these maximum values as the threshold T, compare the differential image pixels with the threshold T respectively, take 1 for pixels greater than or equal to the threshold T, otherwise take 0, and obtain the motion representation frame image b1 k-1 (x, y); the process is expressed as: S4: Perform a logical OR operation on all the difference images to obtain the fused image b3 (x, y). The process is expressed as: b3(x,y)=b11(x,y)OR b12(x,y)OR…ORb1 k-1 (x,y) The position where the pixel b3(x, y) is 1 is preliminarily determined to be a moving target, otherwise it is considered to be the background; S5: Perform connectivity analysis based on the target location determined in S4. If the regions are connected, they are considered to be the same target. Otherwise, they are considered to be multiple targets. Finally, the number of targets N is determined. S6: Determine whether the number of detected targets meets the maximum number limit detected by the optical device, that is, the maximum tolerance value M. If N is less than or equal to M, set T = T-1 and repeat the operations of steps S4 and S5 until N is greater than M. At this time, set T min =T+1,T min That is, it is the optimal detection threshold under the constraint of the maximum detection target, and it is also the most sensitive threshold; S7: Using the updated optimal detection threshold T min , execute S4 and S5 to obtain the final detected target position, and mark the detected target on the image with a red rectangular frame for subsequent actual visualization applications; S8: In practice, since frame images are usually continuous, during processing, the operations from S1 to S7 can be repeated for all images to be processed in chronological order until the task is completed.