Disclosure of Invention
The invention aims to provide an infrared image restoration method, an infrared image restoration device, an infrared image restoration apparatus and a computer-readable storage medium, so as to realize the functions of quickly detecting blind pixel points in an original infrared image and restoring the blind pixel points.
In order to solve the technical problem, the invention provides an infrared image restoration method, which comprises the following steps:
acquiring an original infrared image, and calculating the average value of pixel difference values of each pixel and adjacent pixels in the original infrared image to obtain a first matrix;
carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points;
and repairing the pixel value of the blind pixel point by using the pixel average value of the neighborhood pixel corresponding to the blind pixel point.
Optionally, performing blind primitive point detection on the original infrared image by using the first matrix to obtain blind primitive points, including:
mapping the element values in the first matrix by using the maximum value in the element values of the elements in the first matrix to obtain a second matrix;
constructing an element maximum matrix and a threshold matrix by using the second matrix, and constructing a judgment matrix by using the maximum matrix and the threshold matrix;
determining whether the element value of the element in the second matrix is greater than the element value of a corresponding element in the determination matrix; if so, the pixel corresponding to the element is the dummy point; if not, the pixel corresponding to the element is a normal point.
Optionally, constructing an element maximum matrix and a threshold matrix by using the second matrix includes:
and comparing the element values of the neighborhood elements of each element in the second matrix to obtain a maximum element value, and constructing the maximum element value matrix by using the maximum element value.
Optionally, constructing an element maximum matrix and a threshold matrix by using the second matrix includes:
calculating an element mean value of the element values of the neighborhood elements in the second matrix, and constructing the threshold matrix using the element mean value.
Optionally, constructing a judgment matrix by using the maximum matrix and the threshold matrix, including:
and comparing the element values of the elements in the maximum element value matrix with the element values of the corresponding elements in the threshold value matrix to obtain a larger element value, and constructing the judgment matrix by using the larger element value.
Optionally, before repairing the pixel value of the dummy point by using the pixel average value of the neighboring pixel of the dummy point, the method further includes:
and calculating the pixel mean value by using the pixel values of the neighborhood pixels, and replacing the pixel values of the pixels by using the pixel mean value to obtain a mean value matrix.
Optionally, repairing the pixel value of the dummy point by using the pixel average value of the neighboring pixel of the dummy point includes:
replacing the pixel values of the blind pixels with the element values of the elements in the mean matrix corresponding to the blind pixel points.
The present invention also provides an infrared image restoration device, including:
the first matrix construction module is used for acquiring an original infrared image, and calculating a pixel difference value average value of a pixel and a neighborhood pixel in the original infrared image to obtain a first matrix;
the blind element point detection module is used for detecting the blind element points in the original infrared image by using the first matrix to obtain the blind element points;
and the repairing module is used for repairing the pixel value of the blind pixel point by using the pixel average value of the neighborhood pixel corresponding to the blind pixel point.
The invention also provides an infrared image restoration device, comprising a memory and a processor, wherein:
the memory is used for storing a computer program;
the processor is used for executing the computer program to realize the infrared image restoration method.
The present invention also provides a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the infrared image restoration method described above.
Therefore, the method obtains the original infrared image, calculates the pixel difference value average value of each pixel and the adjacent pixel in the original infrared image, and obtains the first matrix. And carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points. And repairing the pixel value of the blind pixel point by using the pixel mean value of the neighborhood pixel corresponding to the blind pixel point. The method does not need to carry out non-uniformity correction on the original infrared image, and the calculation process is simple, so that the algorithm complexity is reduced, the calculation amount is reduced, and the detection speed of the blind element points in the original infrared image and the repair speed of the blind element points in the original infrared image are accelerated. The method can also effectively reduce the error detection rate of the blind pixel points under the condition of poor image quality such as image cracking and the like.
In addition, the invention also provides an infrared image restoration device, equipment and a computer readable storage medium, and the infrared image restoration device, the equipment and the computer readable storage medium also have the beneficial effects.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The first embodiment is as follows:
referring to fig. 1, fig. 1 is a flowchart illustrating an infrared image restoration method according to an embodiment of the present invention. The method comprises the following steps:
s101: and acquiring an original infrared image, and calculating the pixel difference value average value of each pixel and the adjacent pixel in the original infrared image to obtain a first matrix.
Specifically, an infrared detector may be used to obtain an original infrared image, which is an image without any correction or processing. In the embodiment, the original infrared image does not need to be subjected to non-uniformity correction, so that the algorithm complexity is reduced, and the calculation amount is reduced. In this embodiment, the pixel value may represent an infrared irradiation intensity value.
In this embodiment, each pixel in the original infrared image needs to be subjected to the calculation of the pixel difference average value, and this embodiment does not limit the order of the pixels for calculating the difference average value, for example, the calculation may be performed in the order from small to large in the number of rows, and the calculation may be performed in the order from small to large in the number of columns in the same row. The specific number of the neighborhood pixels is not limited in this embodiment, for example, four pixels above, below, to the left, and to the right of the central pixel may be selected as the neighborhood pixels; or eight pixels surrounding the central pixel may be selected as neighborhood pixels of the central pixel. If the central pixel is located at the edge position of the original infrared image, the number of the neighboring pixels is reduced, and the method for calculating the pixel difference average value of the central pixel located at the edge position is not limited in this embodiment, for example, the pixel difference average value may be calculated only with the existing neighboring pixels.
Preferably, the present embodiment selects eight pixels surrounding the central pixel as the neighborhood pixels, and utilizes
And (3) calculating the pixel with the coordinate of (i, j), namely the average value of the pixel difference values of the ith row and the jth column in the original infrared image and the adjacent pixels, and constructing a first matrix. Wherein, F is a first matrix, F (I, j) is an element value of an element with a coordinate (I, j) in the first matrix, and I (I, j) is a pixel value of a pixel with a coordinate (I, j) in the original infrared image.
S102: and carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points.
In this embodiment, the order of performing blind pixel detection on each pixel in the original infrared image by using the first matrix is not limited, and for example, blind pixel detection may be performed on each pixel in sequence; or firstly detecting the region with higher probability of the blind pixel point. Referring to fig. 2, fig. 2 is a flowchart of another infrared image restoration method according to an embodiment of the present invention, including:
s201: and mapping the element values in the first matrix by using the maximum value in the element values of the elements in the first matrix to obtain a second matrix.
Specifically, the element values of each element in the first matrix are compared to obtain the maximum value, and it is preferable in this embodiment to use
F1(i,j)=[F(i,j)*1023]/Max
Mapping the first matrix, mapping element values of elements in the first matrix to 0-1023, and constructing a second matrix; wherein, F1Is a second matrix, F1(i, j) is the element value of the element with coordinate (i, j) in the second matrix, and Max is the maximum value. And after the second matrix is obtained, constructing an element maximum matrix and a threshold matrix by using the second matrix.
S202: and comparing the element values of the neighborhood elements of all the elements in the second matrix to obtain the maximum element value, and constructing a maximum element value matrix by using the maximum element value.
The specific number of neighborhood elements is not limited in this embodiment, for example, four elements above, below, to the left, and to the right of the central element may be selected as neighborhood elements; or eight elements surrounding the center element may be selected as neighborhood elements of the center element. The present embodiment selects the neighborhood elements that are preferable, that is, eight elements surrounding the center element are selected as the center element.
By using
Comparing the element values of the neighborhood elements of all the elements in the second matrix to obtain a maximum element value, and constructing a maximum element value matrix; where MaxN is the maximum matrix, and MaxN (i, j) is the element value of the element with coordinate (i, j) in the maximum matrix.
S203: and calculating the element mean value of the element values of the neighborhood elements in the second matrix, and constructing a threshold matrix by using the element mean value.
By using
Calculating the element mean value of the element values of the neighborhood elements in the second matrix, and constructing an element mean value matrix; the AVG is an element mean matrix, and the AVG (i, j) is an element value of an element with a coordinate (i, j) in the element mean matrix.
And multiplying the element mean matrix and the comparison coefficient to obtain a threshold matrix. The magnitude of the comparison coefficient is not limited in this embodiment. Test tests show that the detection effect is better when the comparison coefficient is 4, so that the threshold matrix is preferably 4 × AVG in the embodiment.
The execution sequence of steps S202 and S203 is not limited in this embodiment. For example, step S202 may be performed first, and then step S203 may be performed; or the step S203 may be executed first, and the step S202 is executed; or the step S202 and the step S203 are executed simultaneously. It is sufficient that the steps S202 and S203 are executed before the step S204. In order to increase the speed of detecting the blind spot and reduce the time required for detection, it is preferable that the steps S202 and S203 are performed simultaneously.
S204: and comparing the element values of the elements in the maximum element value matrix with the element values of the corresponding elements in the threshold value matrix to obtain a larger element value, and constructing a judgment matrix by using the larger element value.
In this embodiment, the elements in the maximum element value matrix correspond to the elements in the threshold value matrix, that is, the coordinates of the elements in the maximum element value matrix are the same as the coordinates of the elements in the threshold value matrix. Similarly, the correspondence between the pixels and the elements in the original infrared image is that the coordinates of the pixels are the same as the coordinates of the elements.
The maximum matrix and the threshold matrix are used to construct the judgment matrix, and in this embodiment, the maximum matrix and the threshold matrix may be used
Maxim(i,j)=max[MaxN(i,j),4*AVG(i,j)]
Constructing a judgment matrix; wherein, Maxim is a judgment matrix, and Maxim (i, j) is an element value with a coordinate of (i, j) in the judgment matrix;
s205: and judging whether the element value of the element in the second matrix is larger than the element value of the corresponding element in the judgment matrix.
In particular, the values of the elements of the second matrix are determined and the values of the corresponding elements of the matrix are determinedAnd judging whether the pixel in the original infrared image corresponding to the element is a blind pixel or not according to the value of the element. When the element values of the elements in the second matrix are larger, i.e. when F1If (i, j) > Maxim, it indicates that the pixel value of the pixel corresponding to the element is outside the normal range, that is, the pixel is a blind pixel, then step S206 is performed, that is, the pixel corresponding to the element is determined to be a blind pixel; when the element value of an element in the second matrix is smaller than the element value of the corresponding element in the decision matrix, i.e. when F1If the value of the pixel corresponding to the element is less than or equal to Maxim, the pixel value of the pixel corresponding to the element is in the normal range, that is, the pixel is a normal point, then step S207 is entered, that is, the pixel corresponding to the element is determined to be a normal point.
S103: and repairing the pixel value of the blind pixel point by using the pixel mean value of the neighborhood pixel corresponding to the blind pixel point.
After the blind pixel point is detected, the pixel value of the blind pixel point needs to be repaired, and then the original infrared image needs to be repaired. The present embodiment is not limited to the method for repairing the pixel value of the blind primitive point, and for example, the pixel value of a certain neighborhood pixel of the blind primitive point may be used to replace the pixel value of the blind primitive point. In order to improve the restoration effect and make the restored infrared image more realistic, in this embodiment, it is preferable to calculate a pixel mean value of a neighborhood pixel corresponding to the blind pixel point, and replace the pixel value of the blind pixel point with the pixel mean value. In this embodiment, the repair sequence when repairing the pixel values of the blind pixel points is not limited, for example, the pixel mean value of all the blind pixel points may be calculated first, and then the blind pixel points are repaired at the same time; or firstly calculating the pixel mean value of one blind element point, and after the blind element point is repaired, repairing the next blind element point until all the blind element points are repaired.
By applying the infrared image restoration method provided by the embodiment of the invention, the original infrared image is obtained, and the pixel difference value average value of each pixel and the adjacent pixel in the original infrared image is calculated to obtain the first matrix. And carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points. And repairing the pixel value of the blind pixel point by using the pixel mean value of the neighborhood pixel corresponding to the blind pixel point. The method does not need to carry out non-uniformity correction on the original infrared image, and the calculation process is simple, so that the algorithm complexity is reduced, the calculation amount is reduced, and the detection speed of the blind element points in the original infrared image and the repair speed of the blind element points in the original infrared image are accelerated. The method can also effectively reduce the error detection rate of the blind pixel points under the condition of poor image quality such as image cracking and the like.
Example two:
based on the first embodiment, in order to accelerate the infrared image restoration speed, before restoring the pixel values of the blind pixel points, the pixel mean value may be calculated by using the pixel values of the neighboring pixels, and a mean value matrix may be constructed. When the pixel values of the blind pixel points are repaired, the pixel values can be directly replaced by using the corresponding element values in the mean value matrix. Referring to fig. 3, fig. 3 is a flowchart of another infrared image restoration method according to an embodiment of the present invention, including:
s101: and acquiring an original infrared image, and calculating the pixel difference value average value of each pixel and the adjacent pixel in the original infrared image to obtain a first matrix.
This step is described in detail in the first embodiment, and reference may be made to the first embodiment, which is not described herein again.
S102: and carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points.
This step is described in detail in the first embodiment, and reference may be made to the first embodiment, which is not described herein again.
S301: and calculating a pixel mean value by using the pixel values of the neighborhood pixels, and replacing the pixel values of the pixels by using the pixel mean value to obtain a mean value matrix.
By using
And calculating the pixel mean value of the neighborhood pixels and constructing a pixel mean value matrix. Where, MidN is the mean matrix, and MidN (i, j) is the element value of the element with coordinate (i, j) in the mean matrix.
S302: and replacing the pixel value of the blind pixel point by the element value of the element corresponding to the blind pixel point in the mean value matrix.
After detecting the blind pixel point, replacing the pixel value of the blind pixel point with the element value of the element corresponding to the blind pixel point in the mean matrix, i.e. using
And repairing the pixel value of the dummy point. Wherein IO is the repaired infrared image, and IO (i, j) is the pixel value of the pixel with the coordinate (i, j) in the repaired infrared image.
Preferably, in order to reduce the time required for infrared image restoration, in this embodiment, the step S301 may be executed simultaneously with the step S101; or simultaneously with the step S102.
By applying the infrared image restoration method provided by the embodiment of the invention, the pixel mean value is calculated by using the pixel values of the neighborhood pixels, and the pixel mean value is used for replacing the pixel values of the pixels to obtain a mean value matrix; and replacing the pixel value of the blind pixel point by the element value of the element corresponding to the blind pixel point in the mean value matrix. The method can directly replace the pixel value of the blind pixel point by the element value of the corresponding element in the mean value matrix when the pixel value of the blind pixel point is repaired, thereby reducing the time required by the repairing process and further reducing the time required by the whole infrared image repairing process.
In the following, the infrared image restoration apparatus, the device, and the computer-readable storage medium according to the embodiments of the present invention are introduced, and the infrared image restoration apparatus, the device, and the computer-readable storage medium described below may be referred to in correspondence with the infrared image restoration method described above.
Example three:
referring to fig. 4, fig. 4 is a schematic structural diagram of an infrared image restoration apparatus according to an embodiment of the present invention, including:
the first matrix building module 100 is configured to obtain an original infrared image, and calculate a pixel difference average value between a pixel in the original infrared image and a neighboring pixel to obtain a first matrix;
the blind pixel point detection module 200 is configured to perform blind pixel point detection on the original infrared image by using a first matrix to obtain a blind pixel point;
the repairing module 300 repairs the pixel value of the blind pixel point by using the pixel mean value of the neighborhood pixel corresponding to the blind pixel point.
By applying the infrared image restoration device provided by the embodiment of the invention, the original infrared image is obtained, and the pixel difference value average value of each pixel and the adjacent pixel in the original infrared image is calculated to obtain the first matrix. And carrying out blind element point detection on the original infrared image by using the first matrix to obtain blind element points. And repairing the pixel value of the blind pixel point by using the pixel mean value of the neighborhood pixel corresponding to the blind pixel point. The device does not need to carry out non-uniformity correction on the original infrared image, and the calculation process is simple, so that the algorithm complexity is reduced, the calculation amount is reduced, and the detection speed of the blind element points in the original infrared image and the repair speed of the blind element points in the original infrared image are accelerated. The device can also effectively reduce the false detection rate of the blind pixel points under the condition of poor image quality such as image cracking and the like.
Optionally, the blind pixel detection module 200 includes:
the second matrix construction unit is used for mapping the element values in the first matrix by using the maximum value in the element values of the elements in the first matrix to obtain a second matrix;
the matrix construction unit is used for constructing an element maximum matrix and a threshold matrix by using the second matrix and constructing a judgment matrix by using the maximum matrix and the threshold matrix;
the judging unit is used for judging whether the element value of the element in the second matrix is larger than the element value of the corresponding element in the judging matrix; if yes, the pixel corresponding to the element is a blind pixel; and if not, the pixel corresponding to the element is the normal point.
Optionally, the matrix building unit includes:
and the maximum element value matrix constructing subunit is used for comparing the element values of the neighborhood elements of each element in the second matrix to obtain a maximum element value, and constructing a maximum element value matrix by using the maximum element value.
Optionally, the matrix building unit includes:
and the threshold matrix constructing subunit is used for calculating the element mean value of the element values of the neighborhood elements in the second matrix and constructing the threshold matrix by using the element mean value.
Optionally, the matrix building unit includes:
and the judgment matrix constructing subunit is used for comparing the element values of the elements in the maximum element value matrix with the element values of the corresponding elements in the threshold value matrix to obtain a larger element value, and constructing the judgment matrix by using the larger element value.
Optionally, the method further includes:
and the mean matrix construction module is used for calculating a pixel mean value by using the pixel values of the neighborhood pixels and replacing the pixel values of the pixels by using the pixel mean value to obtain a mean matrix.
Optionally, the repair module 300 includes:
and the pixel value replacing unit is used for replacing the pixel value of the blind pixel by using the element value of the element corresponding to the blind pixel in the mean value matrix.
Example four:
referring to fig. 5, fig. 5 is a schematic structural diagram of an infrared image restoration device according to an embodiment of the present invention, where the infrared image restoration device includes a memory and a processor, where:
a memory 10 for storing a computer program;
a processor 20 for executing a computer program to implement the infrared image restoration method as described above.
Example five:
the invention further provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps of the infrared image restoration method described above.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed in the embodiments correspond to the method disclosed in the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relationships such as first and second, etc., are intended only to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The method, apparatus, device and computer readable storage medium for infrared image restoration provided by the present invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.