Image processing method and device, program product, storage medium and electronic equipment

By calculating gradient values ​​and grayscale differences in multiple directions of an image, the target direction is determined, which solves the problem of inaccurate image anomaly detection and enables accurate detection of abnormal pixels in complex scenes.

CN121010584APending Publication Date: 2025-11-25ZHEJIANG PIXFRA TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202511152466.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-15
Publication Date
2025-11-25

AI Technical Summary

Technical Problem

Existing technologies are easily affected by various target objects in the scene during image anomaly detection, leading to false detections and failing to accurately detect abnormal pixels.

Method used

The target direction is determined by calculating gradient values ​​in multiple directions of the image, and anomaly detection is performed based on the gray value of the target pixel in the target direction and the gray value difference of the neighboring pixels.

Benefits of technology

It can more accurately detect abnormal pixels in images under different lighting conditions or complex scenes, reducing false detections and missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121010584A_ABST
    Figure CN121010584A_ABST
Patent Text Reader

Abstract

The invention discloses an image processing method and device, a program product, a storage medium and electronic equipment, and the method comprises the steps: determining a plurality of gradient values of a target pixel point in an image in a plurality of directions, the target pixel point being any pixel point in the image, the direction being the direction defined on the coordinate axis of the image, and the gradient values being the gradient values of the target pixel point in the image; the gradient value is used for representing the gray level change rate of the target pixel point in the direction; determining a target direction from the plurality of directions by using the plurality of gradient values; and on the basis of the gray value of the target pixel point in the target direction and the gray difference between the target pixel point and a target neighborhood pixel point, abnormality judgment is performed on the target pixel point, and the target neighborhood pixel point is a pixel point adjacent to the target pixel point in the target direction. Through application of the method and the device, the problem of inaccurate image anomaly detection in related technologies is solved, and the effect of accurately detecting the abnormal pixel points in the image is further achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of image processing, in particular, to an image processing method and device, program product, storage medium, and electronic device. BACKGROUND

[0002] In the related art, scene data of an image is directly used for analysis in image anomaly detection, but due to the influence of various target objects in the scene, false detection is likely to occur in the detection of abnormal pixel points, thereby affecting the details of the target objects.

[0003] There is no effective solution to the problem of inaccurate anomaly detection of an image in the related art. SUMMARY

[0004] Embodiments of the present application provide an image processing method and device, program product, storage medium, and electronic device to at least solve the technical problem of inaccurate anomaly detection of an image in the related art.

[0005] According to an aspect of embodiments of the present application, an image processing method is provided, including: determining a plurality of gradient values of a target pixel point in an image in a plurality of directions, wherein the target pixel point is any pixel point in the image, the direction is a direction defined on a coordinate axis of the image, and the gradient value is used to represent a gray level change rate of the target pixel point in the direction; determining a target direction from the plurality of directions by using a plurality of the gradient values; and performing anomaly judgment on the target pixel point based on a gray level value of the target pixel point in the target direction and a gray level difference value between the target pixel point and a target neighborhood pixel point, wherein the target neighborhood pixel point is a pixel point adjacent to the target pixel point in the target direction.

[0006] According to another aspect of embodiments of the present application, an image processing device is also provided, including: a first determination module configured to determine a plurality of gradient values of a target pixel point in an image in a plurality of directions, wherein the target pixel point is any pixel point in the image, the direction is a direction defined on a coordinate axis of the image, and the gradient value is used to represent a gray level change rate of the target pixel point in the direction; a second determination module configured to determine a target direction from the plurality of directions by using a plurality of the gradient values; and a first judgment module configured to perform anomaly judgment on the target pixel point based on a gray level value of the target pixel point in the target direction and a gray level difference value between the target pixel point and a target neighborhood pixel point, wherein the target neighborhood pixel point is a pixel point adjacent to the target pixel point in the target direction.

[0007] According to a further aspect of the embodiments of the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is configured to be executed by a processor to perform the steps in any of the method embodiments.

[0008] According to a further aspect of the embodiments of the present application, a computer program product or computer program is provided, and the computer program product or computer program includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the steps in any of the method embodiments.

[0009] According to a further aspect of the embodiments of the present application, an electronic device is provided, and the electronic device includes a memory and a processor. The memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the method embodiments.

[0010] According to the embodiments of the present application, since the gradient values are calculated in multiple directions, the gray scale change around the target pixel point can be more comprehensively understood, and the target direction is determined from multiple directions by using multiple gradient values, and the gray scale difference between the gray scale value in the target direction and the target neighborhood pixel point is used for anomaly judgment, which can more accurately judge the pixel point anomaly under different light conditions or complex scenes. Therefore, the problem of inaccurate anomaly detection of images in related technologies can be solved, and the effect of accurately detecting abnormal pixel points in images can be achieved. BRIEF DESCRIPTION OF DRAWINGS

[0011] Figure 1 is an application scenario schematic diagram of an image processing method according to an embodiment of the present application;

[0012] Figure 2 is a flowchart of an optional image processing method according to an embodiment of the present application;

[0013] Figure 3 is a schematic diagram of an optional pixel window according to an embodiment of the present application;

[0014] Figure 4 is a schematic diagram of an optional pixel gray scale value according to an embodiment of the present application;

[0015] Figure 5 is a flowchart of another optional image processing method according to an embodiment of the present application;

[0016] Figure 6 is a structural block diagram of an optional image processing method device according to an embodiment of the present application;

[0017] Figure 7 is a computer system structure block diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to make the personnel in the art better understand the scheme of the present application, the technical scheme in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by the person of ordinary skill in the art without creative labor should be within the protection scope of the present application.

[0019] It should be noted that the terms "first", "second" and the like in the specification and claims of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or a chronological sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in other than the order illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to the process, method, product or device.

[0020] According to an aspect of an embodiment of the present application, an image processing method is provided. Optionally, in the present embodiment, the above-mentioned image processing method can be applied in, but is not limited to, a hardware environment as shown in Figure 1 The server 104 can be connected with the terminal device 102 through a network, and can be used to provide services (for example, application services, etc.) for the terminal device 102 or a client installed on the terminal device 102, and a database can be set on the server 104 or independently of the server 104, and used to provide data storage services for the server 104.

[0021] The above-mentioned network can include, but is not limited to, at least one of the following: a wired network, a wireless network. The above-mentioned wired network can include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, a local area network, and the above-mentioned wireless network can include, but is not limited to, at least one of the following: Wireless Fidelity (WIFI), Bluetooth. The terminal device 102 can be, but is not limited to, a personal computer (PC), a mobile phone, a tablet computer, etc. The server 104 can be, but is not limited to, a cloud server, a server cluster or other server types.

[0022] The image processing method of the embodiments of the present application can be executed by the server 104, or by the terminal device 102, or by the server 104 and the terminal device 102 jointly. The terminal device 102 executing the image processing method of the embodiments of the present application can also be executed by a client installed thereon.

[0023] Taking the image processing method in the embodiments executed by the server 104 as an example, Figure 2 is a flow diagram of an optional image processing method according to the embodiments of the present application, as Figure 2 shown, the flow of the method can include the following steps:

[0024] Step S202, determining a plurality of gradient values of a target pixel point in an image in a plurality of directions, wherein the target pixel point is any pixel point in the image, the direction is a direction defined on a coordinate axis of the image, and the gradient value is used to represent a gray level change rate of the target pixel point in the direction;

[0025] Step S204, determining a target direction from a plurality of the directions by using a plurality of the gradient values;

[0026] Step S206, performing an abnormality judgment on the target pixel point based on a gray level value of the target pixel point in the target direction and a gray level difference value between the target pixel point and a target neighborhood pixel point, wherein the target neighborhood pixel point is a pixel point adjacent to the target pixel point in the target direction.

[0027] The image processing method in the embodiments can be applied to the field of image processing, and can be specifically applied to the scene of infrared thermal imaging image processing. For example, in the scene of bad point detection of infrared thermal imaging, bad point detection can generally be divided into two categories based on calibration and scene. The calibration-based method can calculate the response rate of each pixel of the infrared detector using a black body, and compare it with the set threshold value. If the difference is large, it can be considered as a bad point; or directly use the data collected by the infrared detector against the black body for analysis and detection. Because it is black body data, theoretically all pixel gray level values are close to each other. At this time, if there is a significant difference between the gray level value of a certain pixel and the gray level values of other pixels, it can be considered that the pixel is a bad point. Because the calibration-based method requires the use of a black body, it is less operable for on-site use of equipment, so the scene-based bad point detection method has emerged. This method directly uses scene data for analysis, but because it is affected by each target object in the scene, it is easy to cause false detection when detecting bad points, and cannot accurately detect bad points.

[0028] Optionally, in step S202, the target pixel refers to a single pixel that is currently being analyzed or processed. In this embodiment, the target pixel is each pixel in the image in turn, with the aim of checking and correcting potential abnormal pixels (bad pixels).

[0029] Optionally, in step S202, the direction is a definition on the image coordinate axis, including horizontal (along X-axis), vertical (along Y-axis) and diagonal directions (e.g. 45°, 135°, etc.). The gradient value reflects the rate of change of the gray scale of the target pixel in the specified direction, i.e. the degree of change in brightness (or temperature in infrared images) between adjacent pixels. In calculating the gradient value, a difference operation or a more complex mathematical model can be used to evaluate the difference between the pixels.

[0030] Optionally, in step S204, among the multiple calculated gradient directions, the target direction can be the direction with the smallest gradient change, i.e. the gray scale value of the image in this direction changes most gently, and it is generally considered that the pixel in this direction is more likely to be normally distributed.

[0031] Optionally, in step S206, the abnormality judgment of the target pixel is based on the gray scale value of the target pixel in the target direction and the gray scale difference between the target pixel and its adjacent pixels, to determine whether the pixel is a bad pixel. If the gray scale value of the target pixel is significantly different from the gray scale value of its target neighborhood pixel and exceeds a pre-set threshold, it can be determined that the pixel is abnormal or a bad pixel.

[0032] For example, in one specific embodiment, it is assumed that an infrared image is being processed, with an image size of 512x512. The goal is to detect and correct bad pixels in the image. The specific steps are as follows:

[0033] S1. For each pixel Pij in the image, calculate the gradient value in four directions: horizontal (0°), vertical (90°), positive diagonal (45°) and negative diagonal (135°). The gradient value calculation can be based on the gray scale difference between the pixels.

[0034] S2. After determining the gradient values in the four directions, find the smallest gradient value. Assuming that for Pij, the smallest gradient value appears in the vertical direction, then the vertical direction is determined as the target direction.

[0035] S3. Using the determined target direction, check whether Pij is a bad pixel. First, calculate the gray scale difference between Pij and its target neighborhood (adjacent pixels P(i-1, j) and P(i+1, j) in the vertical direction). If the gray scale value of Pij is significantly different from the gray scale values of P(i-1, j) and P(i+1, j) (exceeding the adaptive threshold), then Pij is determined to be a bad pixel.

[0036] S4, if Pij is determined as a bad pixel, the average value of the target neighborhood pixels is adopted for correction.

[0037] It should be noted that one detection and correction may not be sufficient to completely remove all bad pixels. Therefore, the algorithm can be designed to iterate multiple times until a certain stopping condition is met (such as no new bad pixels are found in several consecutive iterations, or the maximum number of iterations is reached).

[0038] Through the embodiments provided in the present application, since the gradient values are calculated in multiple directions, the gray level change around the target pixel can be more comprehensively understood, and the target direction is determined from multiple directions using multiple gradient values, and the gray level difference between the gray level value in the target direction and the target neighborhood pixel is used for abnormality judgment, which can more accurately judge the pixel abnormality under different light conditions or complex scenes. Therefore, the problem of inaccurate abnormality detection of images in related technologies can be solved, and the effect of accurately detecting abnormal pixels in images can be achieved.

[0039] In one example embodiment, in step S202, the multiple gradient values of the target pixel in the image in multiple directions are determined, including: for each direction, the gradient value of the target pixel in the direction is determined by the following method to obtain multiple gradient values: calculating the absolute difference value of the gray level between each pixel pair included in N pixel pairs to obtain N absolute difference values, wherein N pixel pairs are pixel pairs selected along the direction, each pixel pair includes two adjacent pixel points, and N is a natural number greater than or equal to 1; the weighted sum of N absolute difference values is obtained to obtain a sum value; the ratio between the sum value and N is calculated to obtain the gradient value.

[0040] Optionally, in the present embodiment, N pixel pairs refer to a set of pixel pairs selected along a certain direction for calculating the gradient value of the target pixel in that direction. Each pixel pair consists of two adjacent pixel points, which is usually a comparison of the current value of the pixel point and the next (or previous) pixel value along the specified direction. N is a natural number greater than or equal to 1, which reflects the number of pixel points considered in gradient calculation. The selection of N value will affect the accuracy and stability of gradient calculation. If N value is too small, it may be affected by local noise, resulting in fluctuations in gradient value; and if N value is too large, it may increase the amount of calculation, affecting the processing efficiency.

[0041] Optionally, in the present embodiment, the absolute difference value is determined by calculating the difference between the gray level values of the two pixel points in the pixel pair and then taking the absolute value. The absolute difference value reflects the amount of gray level change between the pixel points and is the basis for calculating the gradient.

[0042] Optionally, in this embodiment, the weighted sum is the weighted sum of the N absolute differences, and the weights can be uniform or assigned according to the position or importance of the pixel relative to the target pixel. The purpose of the weighted sum is to consider the contribution of all pixels in calculating the gradient and avoid the abnormal value of some positions having too much impact on the final result.

[0043] Optionally, in this embodiment, the ratio calculation is to divide the sum value obtained by the weighted sum by N, and the quotient is the gradient value of the target pixel in that direction. This calculation method averages the gray level change along the direction and provides an index to quantify the gray level change rate.

[0044] For example, in a specific embodiment, as shown in Figure 3 , a 5x5 image region is taken as an example, and the target pixel is located at the center position, i.e. P33. The gradient values of the point in four directions (0°, 45°, 90°, 135°) are calculated. Assuming N=4 and using equal weights, the gradient value calculation formula of the point in four directions (0°, 45°, 90°, 135°) is as follows:

[0045]

[0046] According to the above calculation, the gradient values of the target pixel in four directions are obtained, and the gradient values of the four directions 0°, 45°, 90°, 135° are 0, 12.5, 12.5, 12.5 respectively. This embodiment selects the direction with the smallest gradient value as the target direction, and the gradient value of the horizontal direction 0° is the smallest, so the horizontal direction is determined as the target direction.

[0047] Optionally, in some cases, some pixel points in the pixel pair may be more representative or important than others. For example, pixel points close to the image boundary or specific features (such as edges, textures) may need higher weights. In this case, different weights can be set for each pixel pair when performing weighted sum to reflect their different contributions in calculating the gradient.

[0048] Optionally, in addition to the basic four directions, this embodiment can consider finer direction division, such as 8 or 16 directions, which will increase the complexity of calculation, but at the same time may improve the accuracy and robustness of bad pixel detection.

[0049] This embodiment calculates the gradient of the pixel point in multiple directions by calculating the absolute difference and performing weighted sum, and then obtains the ratio as the gradient value, which can more comprehensively evaluate the gray level change of the target pixel and its neighborhood, can adapt to the gray level change characteristics of different image regions, and thus improves the accuracy of bad pixel detection.

[0050] In an exemplary embodiment, in step S204, determining a target direction from a plurality of directions using a plurality of gradient values ​​includes: determining a target gradient value from the plurality of gradient values, wherein the target gradient value satisfies a first threshold; and determining the direction corresponding to the target gradient value as the target direction.

[0051] Optionally, in this embodiment, the first threshold is a preset judgment criterion used to filter gradient values ​​and determine which directions' gradient values ​​can be considered as target gradient values. The first threshold is set based on the characteristics of the image, the expected distribution of bad pixels, and application requirements. Setting the first threshold helps to eliminate gradient value anomalies caused by noise or other non-bad pixel factors, ensuring that the determined target direction accurately reflects the normal grayscale change trend around the target pixel. The magnitude of the first threshold directly affects the accuracy of target direction judgment. If the threshold is set too low, directions with large normal grayscale changes may be misjudged as target directions; if the threshold is set too high, truly abnormal directions may be missed, leading to bad pixel detection failure. Therefore, reasonably adjusting the first threshold is crucial for the algorithm's performance.

[0052] Optionally, in this embodiment, the target gradient value is a gradient value that satisfies a first threshold condition. Among multiple calculated gradient values, the target gradient value is selected to determine the target direction. It is a value that is smaller or close to zero relative to the gradient values ​​of other directions, indicating that the grayscale change along this direction is relatively gentle.

[0053] Optionally, in this embodiment, the target direction is the direction corresponding to the target gradient value, which is considered the most suitable direction for further detection and determination of whether the target pixel is a bad pixel. The selection of the target direction is based on a comparison of the magnitude of the gradient value and a first threshold, aiming to find the direction with the least gray-level change around the pixel, thereby reducing false detections. For example, assuming... Figure 3 The grayscale value corresponding to a pixel is as follows Figure 4 As shown in the above embodiment, the gradient values ​​in the four directions of 0°, 45°, 90°, and 135° are 0, 12.5, 12.5, and 12.5, respectively. Therefore, the direction with the smallest gradient is the horizontal direction at 0°.

[0054] For example, in one specific embodiment, considering a 5x5 image region, the goal is to determine the gradient values ​​of the center pixel (i.e., the target pixel) in different directions and select the target direction for subsequent bad pixel detection. Specific steps include:

[0055] S1. Assume that the gradient values ​​of the target pixel in the horizontal 0°, diagonal 45°, vertical 90° and anti-diagonal 135° directions have been calculated, and are as follows: G0°=10, G45°=20, G90°=15, G135°=5.

[0056] S2, assuming the first threshold is set to 15, means that any direction with a gradient value less than or equal to 15 will be considered a potential target direction.

[0057] S3, among the given gradient values, G0°=10 and G135°=5 satisfy the first threshold condition. From the gradient values ​​that satisfy the condition, select the smallest gradient value as the target gradient value, which in this example is G135°=5.

[0058] S4, determine the target direction as the anti-angle direction of 135°.

[0059] It should be noted that in complex images, a single first threshold may not adequately reflect the diversity and distribution of defective pixels. Therefore, a multi-level thresholding system can be established, dynamically adjusting the first threshold based on the characteristics of the image region to adapt to scenarios with different grayscale change rates and improve the accuracy of defective pixel detection. Furthermore, in some cases, it may be known beforehand that defective pixels are more common or representative in certain directions. In such cases, these directions can be given higher priority, and even if their gradient values ​​are slightly larger, they may be considered as target directions.

[0060] To detect bad pixels more accurately, it is advisable to further subdivide each major direction into multiple smaller directions for gradient calculation. This helps to capture more subtle grayscale changes and improve the accuracy of direction selection.

[0061] In determining the target direction, in addition to relying on the gradient value, other features of the image can be combined, such as the neighborhood statistical features of pixels and the local texture information of the image, to enhance the reliability of direction selection.

[0062] This embodiment determines the direction corresponding to the minimum gradient value that satisfies the first threshold as the target direction. This means that the grayscale change is the smoothest in this direction, which can more accurately locate the direction where there may be bad pixels, thereby improving the accuracy of subsequent bad pixel detection and reducing false detection and false negative detection.

[0063] In an exemplary embodiment, in step S206, an anomaly judgment is made on the target pixel based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and the target neighboring pixels. This includes: comparing the grayscale value of the target pixel in the target direction with a maximum or minimum value in the target direction to obtain a first comparison result, wherein the maximum value represents the maximum grayscale value of the target pixel and the minimum value represents the minimum grayscale value of the target pixel; comparing the absolute value of the grayscale difference with a second threshold to obtain a second comparison result; and making an anomaly judgment on the target pixel based on the first comparison result and the second comparison result.

[0064] Optionally, in this embodiment, the maximum or minimum value obtained by comparing the grayscale value of a target pixel with the grayscale values ​​of other pixels in its neighborhood in a given direction is called the maximum or minimum value. Specifically, a maximum value refers to the case where the grayscale value of the target pixel in the target direction is higher than the grayscale values ​​of all pixels in its neighborhood; conversely, a minimum value refers to the case where the grayscale value of the target pixel is lower than the grayscale values ​​of all pixels in its neighborhood. The determination of the maximum and minimum values ​​is used to identify whether the grayscale value of the target pixel in the target direction significantly deviates from the grayscale trend of the pixels in its neighborhood. If the grayscale value of the target pixel is much higher or lower than the grayscale values ​​of the pixels in its neighborhood, this may indicate that the target pixel is a bad pixel or an abnormal pixel. For example, as... Figure 4 As shown, if P33 is the minimum or maximum value in the gradient direction, and the absolute value of the grayscale difference between P33 and the target neighboring pixels is greater than the set second threshold T, then P33 is considered a bad pixel. In this case, the difference between the pixel P33 to be processed and its left and right neighbors in the 0° direction is 50. Therefore, when the set second threshold is less than 50, the pixel can be considered a bad pixel.

[0065] Optionally, in this embodiment, the second threshold is a preset standard used to determine whether the absolute value of the grayscale difference between the target pixel and its neighboring pixels reaches an abnormal level. This threshold is set comprehensively based on the requirements for image quality, bad pixel identification accuracy, and required processing speed. The introduction of the second threshold ensures that a target pixel is considered a potential anomalous point only when the grayscale difference between it and its neighboring pixels is significant. This reduces false positives and ensures that only pixels that may truly have quality problems are marked and processed.

[0066] For example, in one specific embodiment, suppose we are processing the center pixel (i.e., the target pixel) of an infrared image, with a grayscale value of 250. It has been determined that the grayscale change of this pixel is smoothest along the anti-retrograde angle of 135°, so this direction is chosen as the target direction. Along the anti-retrograde angle, four pixels on either side of the target pixel are selected as neighboring pixels, with grayscale values ​​of 240, 245, 243, and 248 respectively. It can be observed that the grayscale value of the target pixel is the maximum in this direction.

[0067] Then, the absolute values ​​of the grayscale differences between the target pixel and its neighboring pixels are calculated, and the results are 10, 5, 7, and 2, respectively. This embodiment focuses on the largest grayscale difference, which is 10.

[0068] If the second threshold is set to 10, then the absolute value of the grayscale difference between the target pixel and its neighboring pixels is exactly equal to the second threshold, that is, the second comparison result is that the difference is greater than or equal to the threshold.

[0069] Combining the results of the first and second comparisons, it can be determined that the target pixel is an abnormal or bad pixel.

[0070] In addition, the second threshold can be dynamically adjusted. A reasonable threshold can be automatically set according to the statistical characteristics of the image region (such as standard deviation, mean, etc.) to adapt to bad pixel detection in different scenarios and environments, thereby improving the robustness and adaptability of anomaly judgment.

[0071] Optionally, when calculating the absolute value of the gray-level difference, the selection and weighting of neighboring pixels are crucial to the accuracy of anomaly detection. More complex neighborhood structures (such as elliptical or ring-shaped structures) and non-uniform weighting strategies (e.g., distance-based weights or weights based on local gray-level change rates) can be considered to obtain more refined and reliable gray-level difference estimates.

[0072] Optionally, in real-time image stream processing, data from historical frames can be incorporated to optimize anomaly detection. For example, if a target pixel exhibits significant grayscale value deviations across several consecutive frames, it can be considered an anomaly even if the grayscale difference in the current frame is slightly below a second threshold, thereby improving the continuity and effectiveness of detection.

[0073] This embodiment can more accurately identify abnormal points by comparing the grayscale value of the target pixel with its maximum or minimum value in the target direction. Comparing the absolute value of the grayscale difference between the target pixel and its neighboring pixels with a second threshold can effectively identify pixels whose grayscale values ​​deviate from the normal range. Combining the first and second comparison results provides dual verification for anomaly detection, improving the reliability and accuracy of anomaly detection.

[0074] In an exemplary embodiment, after determining the target pixel to be abnormal based on the first comparison result and the second comparison result, the method further includes: determining that the target pixel is abnormal if the gray value of the target pixel in the target direction is determined to be the maximum value or the minimum value from the first comparison result, and the absolute value of the gray value difference is determined to be greater than the second threshold from the second comparison result.

[0075] Optionally, in this embodiment, a pixel is marked as abnormal only if both the first comparison result and the second comparison result are satisfied (i.e., the grayscale value of the target pixel is a maximum or minimum value, and the absolute value of the grayscale difference is greater than the second threshold). This dual-condition judgment strategy can significantly improve the accuracy and robustness of bad pixel detection, ensuring that only truly abnormal pixels are processed. For example, in an image region with a gentle temperature gradient, even if the grayscale value of the target pixel shows a slight difference, if the difference does not exceed the second threshold, then the pixel will not be incorrectly judged as abnormal.

[0076] For example, suppose we are processing a region of an infrared image. The target pixel P has a grayscale value of 255 in the target direction (let's say horizontal), while the grayscale values ​​of its neighboring pixels range from 200 to 210. In the first comparison result, the grayscale value of point P is a maximum. In the second comparison result, the absolute value of the grayscale difference between point P and its neighboring pixels is 45 ((255-210)). If the second threshold is set to 30, the difference is greater than that threshold. Therefore, the target pixel P will be marked as an outlier and requires further correction or processing.

[0077] This embodiment uses a comprehensive judgment strategy based on the first comparison result and the second comparison result to ensure the accuracy of anomaly detection, reduce false alarms and false negatives, and demonstrate stronger robustness when processing complex images and high-noise environments.

[0078] In an exemplary embodiment, before comparing the absolute value of the grayscale difference with a second threshold to obtain a second comparison result, the method further includes: setting a pixel window based on the coordinates of the target pixel, wherein the pixel window includes a plurality of neighboring pixels adjacent to the target pixel in a plurality of directions; determining thresholds in the pixel window for the plurality of directions, wherein the thresholds are used to represent the grayscale variation range of pixels in the image in the direction; and determining the second threshold corresponding to the target direction from the plurality of thresholds.

[0079] Optionally, in this embodiment, a pixel window is a fixed-size neighborhood surrounding a target pixel in image processing, used to collect and analyze information around that pixel. In this embodiment, the pixel window includes multiple neighboring pixels adjacent to the target pixel, distributed in multiple directions to facilitate evaluation of the grayscale value of the target pixel relative to its neighborhood. The pixel window setting provides context for local information, which is crucial for determining abnormal states of the target pixel. By comparing the grayscale value of the target pixel with that of its neighboring pixels within the pixel window, pixels exhibiting abnormal changes in specific directions—i.e., potential bad pixels—can be identified more accurately.

[0080] Optionally, in this embodiment, a threshold is set for the grayscale variation range in each direction within the pixel window to quantify whether the grayscale variation between pixels is abnormal. These thresholds reflect the typical grayscale variation range of pixels in different directions in the image and are key criteria for distinguishing normal pixels from potential anomalies. The definition of directional thresholds makes anomaly judgment more specific and refined, enabling adaptive judgments based on the characteristics of different parts and directions of the image. This strategy can improve the accuracy and robustness of detection, especially when processing complex scenes or high-resolution images, avoiding the limitations that a single threshold may bring.

[0081] Optionally, in this embodiment, the second threshold is a direction threshold corresponding to the target direction. It is a standard for measuring whether the grayscale difference between the target pixel and its neighboring pixels in the target direction is abnormal. After determining the target direction, the second threshold is used to determine whether the target pixel is truly abnormal. Only when the absolute value of the grayscale difference between the target pixel and its neighboring pixels exceeds the second threshold will the pixel be considered abnormal and require further processing or correction.

[0082] For example, in one specific embodiment, suppose we are analyzing a 512x512 infrared image, where the target pixel coordinates are (150, 200). A 3x3 pixel window is used to evaluate the local environment of this point, i.e., the neighborhood around pixel (150, 200) includes pixels such as (149, 199) and (151, 201). Specific steps include:

[0083] S1 calculates the grayscale variation range of neighboring pixels relative to the target pixel in four directions: 0°, 45°, 90°, and 135°, and sets corresponding directional thresholds. For example, in the 0° direction, the grayscale variation range is 10 to 30, so the directional threshold can be set to 25.

[0084] S2, by analyzing the gradient values ​​in the four directions mentioned above, the target direction was determined to be 45°, because the gradient change is gentlest in this direction. Therefore, the threshold 20 (hypothetical value) corresponding to the 45° direction was selected as the second threshold.

[0085] S3 compares the absolute value of the grayscale difference between the target pixel and all neighboring pixels within the window in the target direction (45° in this case) with a second threshold. If any absolute value of the difference is greater than the second threshold of 20, the target pixel will be marked as abnormal and requires further processing or correction.

[0086] This embodiment selects the optimal threshold corresponding to the target direction as the second threshold from multiple directions, which ensures accurate judgment in the direction most likely to reflect bad spot characteristics, avoids the limitations of a single-direction threshold, and improves the targeting and accuracy of anomaly detection.

[0087] In an exemplary embodiment, determining thresholds in multiple directions within the pixel window includes: for each direction, determining the threshold by: determining the neighboring pixels corresponding to the direction from the pixel window; determining the maximum and minimum grayscale values ​​of the neighboring pixels; and calculating the threshold using the maximum value, the minimum value, and a preset threshold range.

[0088] In conjunction with the above embodiments, a 3*3 pixel window is set with the target pixel as the center, and the 8 neighboring pixels (excluding itself) are calculated (i.e. Figure 3 The difference between the maximum and minimum grayscale values ​​(in the middle section) is called diff. The adaptive threshold T can be calculated using the following formula:

[0089] T = (T max -T min ) / (diff max -diff min )*(diff-diff min )+T min ;

[0090] Among them, T max T min diff max diff min All parameters are configurable, and the final calculated adaptive threshold needs to be limited to T. min ~T max between.

[0091] Furthermore, this embodiment uses the neighborhood difference (diff) as an indicator to characterize the uniformity of local data, that is, to distinguish whether the target pixel is in a flat region or a detail region. In fact, other indicators with the same characteristics, such as variance and information entropy, can also be used to replace the diff value in calculating the adaptive threshold. Moreover, the adaptive threshold calculation formula is not limited to the above method. It can be calculated directly using T = K * diff, or it can be calculated using other complex polynomial formulas, or even by combining multiple indicators such as diff and variance to calculate the adaptive threshold.

[0092] This embodiment calculates a reasonable threshold for each direction based on the local environment and grayscale variation characteristics of the target pixel, serving as the criterion for subsequent anomaly detection. This adaptive threshold determination method not only improves detection accuracy but also enhances the algorithm's adaptability to different images and scenes.

[0093] In an exemplary embodiment, after determining that the target pixel is abnormal based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and the target neighboring pixels, the method further includes: if the target pixel is determined to be abnormal, calculating the target grayscale value of the target pixel based on the coordinate values ​​of the target neighboring pixels; and adjusting the target pixel using the target grayscale value.

[0094] Optionally, in this embodiment, the target grayscale value refers to a value calculated based on the grayscale information of its neighboring normal pixels after a target pixel is determined to be an anomaly, and used to replace the original grayscale value of the anomaly. The calculation of the target grayscale value aims to eliminate the impact of anomalies on image quality while maintaining the integrity and authenticity of image details as much as possible. In bad pixel detection, once a target pixel is marked as an anomaly, the calculation and application of the target grayscale value becomes a crucial step in image correction. Through reasonable calculation, the grayscale value of the anomaly can be adjusted to a value closer to the grayscale value of the surrounding normal pixels, thereby visually and numerically smoothing the anomaly and reducing visual abruptness and data distortion in the image.

[0095] Optionally, in image processing, once a pixel is detected (e.g., ... Figure 4 If P33 is a bad point, then a mean filtering operation is performed in the direction of the minimum gradient at that point to replace it. For example, if... Figure 4 As shown, given that the minimum gradient direction is horizontal, when P33 is a bad pixel, the new grayscale value of that pixel is calculated according to the formula. Calculate the gradient; otherwise, do nothing. If the direction of the minimum gradient is another direction, follow the same principle as above.

[0096] This method makes full use of the information of the minimum gradient direction, which can more accurately estimate the true gray value of bad pixels, thereby achieving the purpose of smoothing the image and improving image quality.

[0097] For example, in one specific embodiment, suppose the target pixel P is located at coordinates (200, 300) and has been identified as an outlier in the 45° direction. Neighboring pixels refer to pixels that are within the pixel window of the target pixel P and are located in the 45° direction (i.e., the top left and bottom right corners). To calculate the target grayscale value of the target pixel P, the following steps are used:

[0098] S1. Within the pixel window, select the neighboring pixel corresponding to the 45° direction. Assume the coordinates of the top-left neighboring pixel are (199, 299) with a grayscale value of 120; the coordinates of the bottom-right neighboring pixel are (201, 301) with a grayscale value of 125.

[0099] S2, based on the gray values ​​of neighboring pixels in the 45° direction, the target gray value of the target pixel P can be calculated using simple averaging, weighted averaging, or more complex algorithms (such as median filtering, edge-preserving algorithms, etc.). In this embodiment, simple weighted averaging can be used for calculation.

[0100] S3, once the target grayscale value is calculated, it is used to replace the original grayscale value of the target pixel P, thus completing the correction of the outlier. In practice, the grayscale value may need to be rounded or limited according to the specific requirements of image processing to ensure the rationality and consistency of the data.

[0101] It should be noted that in practical applications, to improve the accuracy and reliability of the correction, it is advisable to utilize information from neighboring pixels in multiple directions within the pixel window, rather than being limited to just two points in the target direction. For example, the grayscale values ​​of all neighboring pixels within the window can be weighted and averaged, with the weights set based on the distance between the pixel and the target point or the gradient value in the direction.

[0102] When processing dynamic images or video streams, the calculation of the target grayscale value can incorporate time-series information, using dynamic thresholding or time-series-based grayscale prediction methods. This better addresses variations in the image, improving correction effectiveness and stability.

[0103] In some cases, a single anomaly detection and correction may not be sufficient to completely eliminate all outliers in an image. An iterative process can be designed where, after a correction is completed, the image is re-detected for anomalies until a specific stopping condition is met (e.g., the number of outliers does not change significantly between two consecutive detections).

[0104] This embodiment calculates the target grayscale value based on the coordinates of neighboring pixels and corrects outliers, which not only helps improve image quality but also enhances the overall performance of the image processing system and the user experience.

[0105] The image processing method in this application embodiment will be explained below with reference to an optional example. In this optional example, the image processing method is a scheme for detecting bad pixels in infrared images. Figure 5 This is a flowchart illustrating the detection of dead pixels in an infrared image in this optional example, as follows: Figure 5 As shown, the procedure for detecting dead pixels in infrared images may include the following steps:

[0106] Step S502: Select a pixel P(100, 100) in the infrared image (image size 640x480 pixels) as the target pixel to be processed. Assume that the gray value of point P is an abnormally low value of 0, while the gray values ​​of the surrounding pixels fluctuate between 20 and 50.

[0107] Step S504: Calculate the gradient values ​​of point P in four directions (0°, 45°, 90°, 135°). The specific calculation formula is as described in the above embodiment and will not be repeated here. Assume that the gradient values ​​obtained from the above calculations are: G0° = 50, G45° = 45, G90° = 48, G135° = 46. Therefore, the direction with the smallest gradient is the 45° direction.

[0108] Step S506: Based on the minimum gradient direction of 45°, check whether point P is the minimum or maximum value in the local region along this direction, and whether the absolute value of the grayscale difference between point P and its neighboring pixels exceeds a preset threshold T. Assuming the preset threshold T is 30, the absolute values ​​of the grayscale differences between point P and its neighbors P(99, 99) (grayscale value 40) and P(101, 101) (grayscale value 45) are 40 and 45 respectively, both exceeding the preset threshold. Therefore, point P is considered a potential bad pixel.

[0109] Step S508 further confirms whether point P is truly abnormal, requiring an assessment of the grayscale difference between point P and its neighboring points. If the grayscale value of point P differs significantly from the grayscale values ​​of most neighboring points, and this difference is particularly pronounced in the direction of minimum gradient, then we confirm point P as a bad point.

[0110] Step S510: Once point P is determined to be a bad pixel, a replacement operation is performed along the direction of minimum gradient (here, 45°). Specifically, the correct gray value of point P is estimated using the gray values ​​of normal pixels in the neighborhood of point P. Since point P is abnormally low, the average gray value of the pixels in the neighborhood is selected as the new gray value of point P. Assuming the gray values ​​of the neighboring points P(99, 99) and P(101, 101) in the 45° direction are 40 and 45 respectively, the new gray value of point P is 42.5.

[0111] In step S512, finally, the newly calculated grayscale value is used to replace the original grayscale value of point P to complete the image correction. For P(100, 100), its grayscale value is updated from 0 to 42.5, thereby eliminating the visual abruptness and improving the overall quality and detail of the image.

[0112] By implementing the above steps in detail, using gradient direction information, bad pixel judgment logic, and gray values ​​of neighboring points in the direction, bad pixels in the image can be accurately located and corrected. This is especially suitable for processing infrared images containing rich details, so as to improve image quality and visual continuity.

[0113] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0114] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0115] According to another aspect of the embodiments of this application, an image processing apparatus is also provided, which can be used to implement the image processing methods provided in the above embodiments, and will not be repeated hereafter. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0116] Figure 6 This is a structural block diagram of an optional image processing apparatus according to an embodiment of this application, such as... Figure 6 As shown, the image processing apparatus includes:

[0117] The first determining module 62 is used to determine multiple gradient values ​​of a target pixel in an image in multiple directions, wherein the target pixel is any pixel in the image, the direction is a direction defined on the coordinate axis of the image, and the gradient value is used to represent the grayscale change rate of the target pixel in the direction.

[0118] The second determining module 64 is used to determine the target direction from the multiple directions using the multiple gradient values;

[0119] The first judgment module 66 is used to judge the target pixel as abnormal based on the gray value of the target pixel in the target direction and the gray value difference between the target pixel and the target neighboring pixels, wherein the target neighboring pixels are the pixels adjacent to the target pixel in the target direction.

[0120] The embodiments provided in this application, by calculating gradient values ​​in multiple directions, provide a more comprehensive understanding of the grayscale changes around the target pixel. Furthermore, by using multiple gradient values ​​to determine the target direction from multiple directions, and by using the grayscale value in the target direction and the grayscale difference between the target and its neighboring pixels for anomaly detection, pixel anomalies can be more accurately identified under different lighting conditions or complex scenes. Therefore, this solves the problem of inaccurate anomaly detection in related technologies, achieving the effect of accurately detecting abnormal pixels in images.

[0121] In an exemplary embodiment, the first determining module includes: a first determining unit, configured to determine the gradient value of the target pixel in each direction by means of the following method, thereby obtaining a plurality of gradient values: calculating the absolute difference of grayscale values ​​between each of the N pixel pairs to obtain N absolute difference values, wherein the N pixel pairs are all pixel pairs selected along the direction, each pixel pair includes two adjacent pixels, and N is a natural number greater than or equal to 1; performing a weighted summation of the N absolute difference values ​​to obtain a sum value; and calculating the ratio between the sum value and N to obtain the gradient value.

[0122] In an exemplary embodiment, the second determining module includes: a second determining unit, configured to determine a target gradient value from a plurality of gradient values, wherein the target gradient value satisfies a first threshold; and a third determining unit, configured to determine the direction corresponding to the target gradient value as the target direction.

[0123] In an exemplary embodiment, the first judgment module includes: a first comparison unit, configured to compare the grayscale value of the target pixel in the target direction with a maximum or minimum value in the target direction to obtain a first comparison result, wherein the maximum value represents the maximum grayscale value of the target pixel, and the minimum value represents the minimum grayscale value of the target pixel; a second comparison unit, configured to compare the absolute value of the grayscale difference with a second threshold to obtain a second comparison result; and a first judgment unit, configured to make an anomaly judgment on the target pixel based on the first comparison result and the second comparison result.

[0124] In an exemplary embodiment, the above-described apparatus further includes a third determining module, configured to determine that the target pixel is abnormal after performing an anomaly judgment on the target pixel based on the first comparison result and the second comparison result, provided that the grayscale value of the target pixel in the target direction is determined to be the maximum or minimum value from the first comparison result, and the absolute value of the grayscale difference is determined to be greater than the second threshold from the second comparison result.

[0125] In an exemplary embodiment, the above-described apparatus further includes a first setting module, configured to set a pixel window based on the coordinates of the target pixel before comparing the absolute value of the grayscale difference with a second threshold to obtain a second comparison result, wherein the pixel window includes a plurality of neighboring pixels adjacent to the target pixel in a plurality of directions; a fourth determining module, configured to determine thresholds in the plurality of directions in the pixel window, wherein the thresholds are used to represent the grayscale variation range of the pixels in the image in the direction; and a fifth determining module, configured to determine the second threshold corresponding to the target direction from the plurality of thresholds.

[0126] In an exemplary embodiment, the fourth determining module includes: a fourth determining unit, configured to determine the threshold for each direction by: determining the neighboring pixels corresponding to the direction from the pixel window; determining the maximum and minimum grayscale values ​​of the neighboring pixels; and calculating the threshold using the maximum value, the minimum value, and a preset threshold range.

[0127] In one exemplary embodiment, the apparatus further includes: a first calculation module, configured to, after determining an anomaly of the target pixel based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and the target neighboring pixels, calculate the target grayscale value of the target pixel based on the coordinate values ​​of the target neighboring pixels if the target pixel is determined to be abnormal; and a first adjustment module, configured to adjust the target pixel using the target grayscale value.

[0128] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.

[0129] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein the program executes the steps in any of the above method embodiments when it is run.

[0130] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, ROMs, RAMs, portable hard drives, magnetic disks, or optical disks.

[0131] According to another aspect of the embodiments of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor is configured to perform the steps of any of the method embodiments described above via the computer program. In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0132] Specific examples in this embodiment can be found in the examples described in the above embodiments and exemplary implementations, and will not be repeated here.

[0133] According to another aspect of the embodiments of this application, a computer program product is also provided, the computer program product including a computer program / instructions, the computer program / instructions comprising a process for performing a flow. Figure 7 The program code for the method shown is provided. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit 701, it performs various functions provided in the embodiments of this application. The sequence numbers of the embodiments of this application above are merely for description and do not represent the superiority or inferiority of the embodiments.

[0134] Figure 7 A schematic block diagram of a computer system architecture for implementing embodiments of the present application is shown. Figure 7 As shown, the computer system 700 includes a Central Processing Unit (CPU) 701, which performs various appropriate actions and processes based on programs stored in ROM 702 or loaded into RAM 703 from storage section 708. Random access memory 703 also stores various programs and data required for system operation. The CPU 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.

[0135] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal display (LCD), and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card (NIC), modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the input / output interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed into the storage section 708 as needed.

[0136] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711. When the computer program is executed by central processing unit 701, it performs various functions defined in the system of this application.

[0137] It should be noted that, Figure 7 The computer system 700 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0138] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.

[0139] The above are merely preferred embodiments of this application and are not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.

Claims

1. An image processing method, characterized in that, include: Determine multiple gradient values ​​of a target pixel in an image in multiple directions, wherein the target pixel is any pixel in the image, the direction is a direction defined on the coordinate axis of the image, and the gradient value is used to represent the gray-level change rate of the target pixel in the direction; The target direction is determined from the multiple directions using the multiple gradient values; Based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and the target neighboring pixels, the target pixel is judged to be abnormal. The target neighboring pixels are the pixels adjacent to the target pixel in the target direction.

2. The method according to claim 1, characterized in that, Determine multiple gradient values ​​of a target pixel in an image in multiple directions, including: For each direction, the gradient value of the target pixel in that direction is determined in the following manner, resulting in multiple gradient values: Calculate the absolute difference of grayscale values ​​between each of the N pixel pairs to obtain N absolute difference values, wherein the N pixel pairs are all selected along the direction, and each pixel pair includes two adjacent pixels, and N is a natural number greater than or equal to 1; sum the N absolute difference values ​​by weight to obtain a sum value; calculate the ratio between the sum value and N to obtain the gradient value.

3. The method according to claim 1, characterized in that, Determining a target direction from a plurality of directions using a plurality of said gradient values ​​includes: A target gradient value is determined from a plurality of said gradient values, wherein the target gradient value satisfies a first threshold; The direction corresponding to the target gradient value is determined as the target direction.

4. The method according to claim 1, characterized in that, Based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and its neighboring pixels, anomaly detection is performed on the target pixel, including: The grayscale value of the target pixel in the target direction is compared with the maximum or minimum value in the target direction to obtain a first comparison result, wherein the maximum value is used to represent the maximum grayscale value of the target pixel, and the minimum value is used to represent the minimum grayscale value of the target pixel; The absolute value of the grayscale difference is compared with a second threshold to obtain a second comparison result; Anomaly detection is performed on the target pixel based on the first comparison result and the second comparison result.

5. The method according to claim 4, characterized in that, After performing anomaly detection on the target pixel based on the first comparison result and the second comparison result, the method further includes: If the grayscale value of the target pixel in the target direction is determined to be the maximum or minimum value from the first comparison result, and the absolute value of the grayscale difference is determined to be greater than the second threshold from the second comparison result, the target pixel is determined to be abnormal.

6. The method according to claim 4, characterized in that, Before comparing the absolute value of the grayscale difference with a second threshold to obtain a second comparison result, the method further includes: A pixel window is set based on the coordinates of the target pixel, wherein the pixel window includes a plurality of neighboring pixels that are adjacent to the target pixel in a plurality of directions; In the pixel window, thresholds in multiple directions are determined, wherein the thresholds are used to represent the range of grayscale variation of pixels in the image in the directions; The second threshold corresponding to the target direction is determined from a plurality of the thresholds.

7. The method according to claim 6, characterized in that, Determining thresholds in multiple directions within the pixel window includes: For each of the directions, the threshold is determined as follows: The neighboring pixels corresponding to the direction are determined from the pixel window; the maximum and minimum gray values ​​of the neighboring pixels are determined; and the threshold is calculated using the maximum value, the minimum value, and a preset threshold range.

8. The method according to claim 1, characterized in that, Based on the grayscale value of the target pixel in the target direction and the grayscale difference between the target pixel and its neighboring pixels, after performing anomaly detection on the target pixel, the method further includes: If the target pixel is determined to be abnormal, the target grayscale value of the target pixel is calculated based on the coordinate values ​​of the target's neighboring pixels. The target pixel is adjusted using the target grayscale value.

9. An image processing apparatus, characterized in that, include: The first determining module is used to determine multiple gradient values ​​of a target pixel in an image in multiple directions, wherein the target pixel is any pixel in the image, the direction is a direction defined on the coordinate axis of the image, and the gradient value is used to represent the grayscale change rate of the target pixel in the direction. The second determining module is used to determine the target direction from the multiple directions using the multiple gradient values; The first judgment module is used to judge the target pixel as abnormal based on the gray value of the target pixel in the target direction and the gray value difference between the target pixel and the target neighboring pixels, wherein the target neighboring pixels are the pixels adjacent to the target pixel in the target direction.

10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 8.

12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Defective pixel detecting and correcting method based on minimal mid-value gradient filtering

    CN104463891A

  • Gradient minimization infrared image edge preserving denoising method

    CN109584174A

  • Automatic detection method, correction method and system for newly added abnormal points

    CN110149486A

  • Dead pixel correction method and device, terminal equipment and storage medium

    CN116017182A

  • Pixel dead pixel correction method and device, electronic equipment and storage medium

    CN116887060A