Infrared image pot cover correction algorithm
Technical Field
The invention belongs to the technical field of infrared image processing, and particularly relates to an infrared image pot cover correction algorithm.
Background
Uncooled infrared detectors are increasingly being used in the military and civil fields with the advantages of low cost and easy miniaturization. However, the direct output image has the problems of low spatial resolution, low contrast, large noise, blurred edge details, large dynamic range, small information amount and the like due to the influence of factors such as self manufacturing process, hardware circuits, external working environment and the like. Because of the optical characteristics of the lens, the light intensity received by the edge area of the image area of the detector is smaller than that received by the center, and the phenomenon that the brightness of the imaging center and the brightness of four corners are inconsistent is caused. The lens itself is a convex lens, and the center is necessarily more sensitive than the periphery due to the convex lens principle. In the structure of the infrared module, the baffle is arranged behind the lens, and the uneven energy distribution caused by the part of the lens is not corrected when the baffle is hit, so that the pot cover effect shown in fig. 1 appears, and the quality of image display is affected.
Therefore, it is necessary to design an infrared image pot cover correction algorithm, which can effectively inhibit pot cover effect.
Disclosure of Invention
In order to solve the problems, the invention provides an infrared image pot cover correction algorithm, which enables an infrared image to output a uniform image on the basis of keeping high real-time performance.
The specific technical scheme is as follows:
an infrared image pot cover correction algorithm, the algorithm comprising the steps of:
s1, acquiring an infrared image containing a pot cover phenomenon, performing gridding treatment, and establishing a grid correction coefficient table corresponding to a grid;
s2, carrying out blocking treatment on the infrared image containing the pot cover phenomenon, calculating grids associated with blocks to which pixel points to be corrected belong, and acquiring grid correction coefficients of corresponding grids from a grid correction coefficient table;
S3, calculating an actual correction coefficient of the pixel point to be corrected through the grid correction coefficient related to the pixel point to be corrected;
S4, multiplying the pixel value of the pixel point to be corrected by the actual correction coefficient to obtain the correction value of the pixel point to be corrected.
Further, the step S1 specifically includes: acquiring an infrared image containing a pot cover phenomenon, dividing the acquired infrared image into (n+1) x (m+1) grids, calculating (n+1) x (m+1) grid correction coefficients, and establishing a grid correction coefficient table corresponding to the grids; where m is the number of correction grids in the column direction and n is the number of correction grids in the row direction.
Further, the grid division method of (n+1) × (m+1) is as follows: the other grids except the first row, the last row, the first column and the last column are the same in size; the first and last rows are each 1/2 of the middle row height, and the first and last columns are 1/2 of the middle column width.
Further, the grid correction coefficientThe calculation method comprises the following steps:
For the average value of all pixels contained in the grid of the ith row and the jth column, the calculation method is as follows:
wherein,
;
Wherein Height is the total number of pixels in the infrared image column direction containing the pot cover phenomenon, width is the total number of pixels in the infrared image row direction containing the pot cover phenomenon,For each pixel number included in the grid column direction,/>The number of pixels included for each grid row direction; src (h, w) is the data of the h row and the w column in the infrared image containing the pot cover phenomenon; max () means taking as output the larger one of the two data contained in brackets; min () denotes taking as output the smaller one of the two data contained in brackets; /(I)For the row start coordinates,/>, of the pixels contained in the ith row and jth column grid in the infrared image actually containing the pot cover phenomenonFor line termination coordinates,/>Column start coordinates,/>For column termination coordinates, num is the total number of pixels contained in each grid.
Further, the step S2 specifically includes:
s21, calculating grid coordinates to which coordinates (h, w) belong according to coordinates (h, w) of pixel points to be corrected in an image src containing a pot cover phenomenon in the whole frame:
wherein, 、/>Respectively representing row coordinate values and column coordinate values of the current pixel point in the whole frame image src containing the pot cover phenomenon, wherein floor () represents data integer;
s22, acquiring coordinates of grids related to pixel points to be corrected; wherein each block of the infrared image partition is associated with four grids, and the coordinates of the four grids are respectively as follows 、/>、、/>;
S23, obtaining grid correction coefficients of four grids related to the pixel point to be corrected by inquiring a grid correction coefficient table, wherein the grid correction coefficients are respectively、/>、/>、/>:
Further, the step S3 specifically includes: calculating the actual correction coefficient of each pixel point to be corrected by using a bilinear interpolation method through grid correction coefficients of four grids related to the pixel:
Wherein x and y are intermediate parameters.
Further, steps S2 to S4 are performed for each pixel to be corrected until correction of all the pixels to be corrected is completed.
Further, the algorithm further comprises: s5, acquiring current image data and current detector working temperature, and calculating a correction adjustment coefficient R of the current image according to the detector working temperature and the image data information; the final correction result is obtained by multiplying the correction adjustment coefficient R by the correction value obtained in step S4.
Further, the algorithm is based on an FPGA platform, real-time infrared data are corrected at two non-uniform points and then written into the DDR, and the DDR is used as a data source to calculate an actual correction coefficient for a CPU; the data source is subtracted 24576 and then added 24576 after multiply-divide calculation; reading actual correction coefficients of the pot cover from the DDR in real time according to the time sequence of the image data, correcting, and performing the following processing on decimal multiplication in calculation: amplifying the decimal to the integer power of 2; the amplified data is rounded for calculation and the result is divided by the magnification.
Further, the data operation function in correction is realized in the DDR memory; by replacing the image data DDR address involved in the calculation, the operation before the calculation of the pot cover correction algorithm is set as: freezing the image before calculation; the Fabric does not use DDR in the calculation process; after the calculation is completed, the image thawing operation is executed, and the DDR is released.
Compared with the prior art, one or more of the technical schemes can achieve at least one of the following beneficial effects:
The infrared module pot cover correction algorithm can ensure that the output image is uniform and the pot cover removal effect is good on the basis of keeping high real-time performance of the infrared image. The invention provides an engineering method of an infrared module pot cover correction algorithm, which is easy for engineering realization.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is an image of the presence of a pot cover effect.
FIG. 2 is a flowchart of the infrared module pot cover correction algorithm of example 1.
Fig. 3 is a grid distribution diagram of image correction in example 1.
Fig. 4 is a diagram showing the grid distribution of the calculation grid correction coefficients of embodiment 1.
Fig. 5 is a schematic diagram of infrared image blocking in example 1.
Fig. 6 shows four grid correction coefficients for the pixel of example 1.
FIG. 7 is a flow chart of the infrared module pot cover correction algorithm engineering of example 1.
Fig. 8 is a comparison graph of the effect of example 1 before and after the pot cover is removed in scene 1, wherein fig. 8a is a graph of the effect of example 1 before the pot cover is removed in scene 1, and fig. 8b is a graph of the effect of example 1 after the pot cover is removed in scene 1.
Fig. 9 is a comparison graph of the effect of embodiment 1 before and after the pot cover is removed in the scene 2, wherein fig. 9a is a graph of the effect of embodiment 2 before the pot cover is removed, and fig. 9b is a graph of the effect of embodiment 2 after the pot cover is removed.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
As shown in fig. 2, the embodiment provides an infrared module pot cover correction algorithm based on an FPGA, and adopts a grid correction method.
S1, performing gridding processing on the acquired infrared image, and establishing a grid correction coefficient table corresponding to the grid.
Acquiring an infrared image containing a pot cover phenomenonDividing the image into (n+1) x (m+1) grids, calculating (n+1) x (m+1) grid correction coefficients, and storing the grid correction coefficients into a grid correction coefficient table; where m is the number of correction grids in the column direction and n is the number of correction grids in the row direction.
As shown in fig. 3 and 4, (n+1) × (m+1) mesh division methods are as follows: the other grids except the first row, the last row, the first column and the last column are the same in size; the height of the first row and the last row is 1/2 of the height of the middle rowThe height of the remaining rows is/>The width of the first and last columns is 1/2 of the width of the middle column, i.e./>The width of the remaining columns is/>。
Wherein Height is the total number of pixels in the column direction of the infrared image containing the phenomenon of the pot cover, and m is the correction grid number in the column direction; width is the total number of pixels in the infrared image row direction including the pot cover phenomenon; n is the correction grid number in the row direction; For each correction grid column direction contains the number of pixels,/> The number of pixels contained in the row direction of each correction grid.
Grid correction coefficientThe calculation method comprises the following steps:
for the average value of all pixels contained in the jth grid of the ith row, the method of calculation is as follows:
wherein,
Wherein Height is the total number of pixels in the infrared image column direction containing the pot cover phenomenon, width is the total number of pixels in the infrared image row direction containing the pot cover phenomenon,For each correction grid column direction contains the number of pixels,/>The number of pixels included for each correction grid row direction; src (h, w) is the data of the h row and the w column in the infrared image containing the pot cover phenomenon; max () means taking as output the larger one of the two data contained in brackets; min () denotes taking as output the smaller one of the two data contained in brackets; /(I)For the row start coordinates,/>, of the pixels contained in the ith row and jth column grid in the infrared image actually containing the pot cover phenomenonFor line termination coordinates,/>Column start coordinates,/>For the column termination coordinates, the total number of pixels contained in the Num grid.
S2, as shown in FIG. 5, performing matrix blocking treatment on the infrared image containing the pot cover phenomenon; each block overlaps the grid. This embodiment takes as an example that each block has an overlapping portion with four grids. As shown in fig. 6, the solid line portion is a grid, and the broken line portion is a block.
Grid coordinates related to pixels contained in each block are calculated, and grid correction coefficients corresponding to each grid are obtained from a grid correction coefficient table.
S21, calculating grid coordinates to which coordinates (h, w) belong according to the coordinates (h, w) of the pixel points to be corrected in the whole frame of image src containing the pot cover phenomenon;
wherein, 、/>Respectively representing row coordinate values and column coordinate values of the current pixel point in the whole frame image src, and representing data by floor ();
s22, obtaining coordinates of four grids related to the current pixel point to be corrected 、、/>、/>;
S23, obtaining grid correction coefficients corresponding to four grids related to the current pixel by querying a grid correction coefficient table, wherein the block to which the pixel point (h, w) to be corrected belongs is a dotted rectangle at the upper left corner, the dotted rectangle is associated with four solid rectangles (namely four related grids), and the grid correction coefficients of the four grids are respectively、/>、/>、。
S3, calculating an actual correction coefficient of the pixel point to be corrected.
Calculating the actual correction coefficient of the pixel point to be corrected by using bilinear interpolation and using the grid correction coefficients of four grids related to the pixel point to be corrected. Wherein x and y are intermediate parameters.
S4, correcting pixels: multiplying the pixel value of the current pixel to be corrected by the actual correction coefficient to obtain a correction value of the pixel to be corrected:
。
and executing steps S2 to S4 on each pixel point to be corrected until the correction of all the pixel points to be corrected is completed.
As an alternative embodiment, the algorithm further comprises: s5, acquiring current image data and current detector working temperature, and calculating a correction adjustment coefficient R of the current image according to the detector working temperature and the image data information; the final correction result is obtained by multiplying the correction adjustment coefficient R by the correction value obtained in step S4.
As a specific implementation mode, the embodiment implements the infrared module pot cover correction algorithm based on the FPGA platform. The infrared complete machine system comprises an infrared detector, an infrared detector driving circuit, an FPGA processing circuit and an interface driving circuit. The infrared detector is used for converting infrared signals into electric signals; the infrared detector driving circuit converts the electric signal output by the infrared detector into an original 14-bit parallel digital signal; the FPGA processing circuit processes the input 14-bit parallel digital signals in real time, and outputs an interface digital video stream input by the interface chip through algorithm processing; interface drive circuit: and converting the FPGA output digital video stream into a CVBS signal. The infrared detector adopts a detector with 640x512 pixels and 12 mu m pixel spacing, and the FPGA adopts SmartFusion series of microsemi company.
As shown in fig. 7, the infrared image pot cover correction algorithm performs the following processing in the engineering implementation process:
1) And after the real-time infrared data are subjected to non-uniform two-point correction, writing the real-time infrared data into the DDR, and taking the DDR as a data source to calculate an actual correction coefficient for the CPU. The data source is subtracted 24576 from the precision problem and then performed.
2) According to the image data time sequence, the actual correction coefficient of the pot cover is read from the DDR in real time and corrected, and the decimal multiplication cannot be directly realized by Verilog.
A. The decimal is first amplified by an integer power of 2, in this case 14 times 2. The result of this amplified fraction is then divided by the amplification factor, which division can be achieved by a right shift method. The current pixel value is multiplied by the actual correction coefficient.
B. in consideration of precision, the data source is subtracted 24576, and then added 24576 after the multiply-divide operation, and the CPU correction coefficients also need to be synchronized.
The processing method improves the operation accuracy and solves the resource problem.
In CPU soft cores
1) The data operation function is moved to the DDR memory for calculation, so that the problem that floating point type data size is huge and the movement operation is likely to be blocked is solved.
2) The operation before the calculation of the pot cover correction algorithm is modified by replacing the DDR address of the image data participating in the calculation, and the original external reference operation is modified as follows: freezing the image before calculation; and adding DDR not used by Fabric in the calculation process; after the calculation is completed, the image thawing operation is executed, and the DDR is released. The corrected image is normal, and the phenomenon of uneven blocking is avoided.
As shown in fig. 8 and 9, according to the comparison images before and after the pot cover algorithm processing is implemented according to different scenes, the details of the corrected images are more obvious, and the pot cover removing effect is good.
It is apparent that the above examples are only examples for clearly illustrating the technical solution of the present invention, and are not limiting of the embodiments of the present invention. Other variations or modifications of the above teachings will be apparent to those of ordinary skill in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the invention are to be included in the protection of the present claims.