A solution method for image distortion correction model based on bilinear interpolation

In the process of the image generation, because the imaging system itself has differences in terms of nonlinear or cameraman perspective, the generated image will face the geometric distortion. Image distortion in general is also a kind of image degradation, which needs the geometric transform to correct each pixel position of the distorted images, so as to regain the original spatial relationships between pixels and the original grey value relation, and which is also one of important steps of image processing. From the point of view of the digital image processing, the distortion correction is actually a process of image restoration for a degraded image. In image processing, in terms of the image quality improvement and correction technology, namely the image restoration, with the wide expansion of digital image distortion correction processing applied, the processing technology of the image restoration has also become a research hotspot. In view of the image distortion issue, this paper puts forward the image distortion correction algorithm based on two-step and one-dimensional linear gray level interpolation to reduce the computation complexity of the bilinear interpolation method, and divide the distorted image into multiple quadrilaterals, and the area of the quadrilateral is associated with the distortion degree of the image in the given region, and express the region distortion of each quadrilateral with the bilinear model, thus determining parameters of bilinear model according to the position of the quadrilateral vertex in the target image and the distorted image. Experiments show that such algorithm in this paper can meet the requirements of distortion correction of most lenses, which can accurately extract the distorted edge of the image, thus making the corrected image closer to the ideal image.


Introduction
In the process of generation and transmission, it is likely that the image will face distortion, such as color cast, vagueness, geometric distortion and geometric tilt and so on. Image distortion refers to such deformation as extrusion, stretching, migration and distortion etc. of the relative to the reference system (actual location on the ground or topographic map) and such geometrical position of the image pixels is generated during the imaging process of image pixels, thus making the image geometric location, size, shape, orientation and so on change. Distortion widely exists in various kinds of actual engineering application, especially in the remote sensing and remote sensing field. At present, almost all fields involving the application of scanning and imaging need the distortion correction [1]. The distortion correction by digital image technology is mainly used in two areas: one is the correction of medical endoscope image, which aims to measure the size of the lesion area of the image, the other is the machine vision field, which aims to improve its visual positioning accuracy to correctly complete the actions. Geometric distortion includes barrel distortion, pincushion distortion and geometric tilt etc. In fact, it is often necessary to calibrate the image of another intake mode based on a certain image, in order to correct its geometric distortion, which is called geometric distortion correction of image. Current methods adopted to correct the image distortion include two main steps: the spatial transform, rearrange the image pixels in the image plane to restore the original spatial relations; gray level interpolation: endow pixels after spatial transform with relative gray value to restore the grey value of the original location [2,3].
In terms of researches on the image distortion correction, in 1966, the research results of CCD image distortion correction published by Hallert firstly adopt the least square method to realize the data processing [4]. In 1975, Faig considered various factors causing distortion during the CCD imaging, set up relatively sophisticated imaging model and solved by using the nonlinear optimization method [5]. Hideaki firstly proposed the grid template method in 1995 and simulated the mapping relationship between the actual pixels and distorted pixels by using the intersections between straight lines of the template, and thus completing the image distortion correction [6]. Smith proposed the template image and checkerboard template of hexagonal lattice [7]. These methods are all based on a specific template, once the template is sampled, it will not be meaningful unless images taken in the specific environment sampled by such template are corrected. Correction method based on parameters doesn't require the template, and the distortion correction can be implemented only with some specific parameters (such as the focal length, etc.). Miroslav and so on use the maximum entropy of the linear model during the image collection to calculate parameters of the distortion correction model [8]. Devernay creates a multimode model, and also proposes a new correction algorithm through such model, and at present such algorithm has been applied in many fields [9]. In addition, Juho Kannala further studies the imaging principle of all kinds of lens to put forward the distortion correction algorithm which is able to adapt to a variety of lens [10]. Although these algorithms highly improve the distortion correction algorithm in time and space complexity, which makes great contribution for the distortion correction algorithm in the actual application, the image distortion correction algorithms proposed at present still have many problems. For example, when accessing images, the eccentric distortion will occur and the radius mapping will face the radius discontinuity, thus resulting in the image default case. Therefore, with the study on the existing image distortion correction algorithm, the algorithm is improved based on the analysis of these distortion correction algorithms to improve the correction effect and the efficiency of the existing algorithm, thus having certain practical values. This paper firstly aims at the problems prone to geometric distortion in accessing images, through the indepth analysis of specific reasons for the image geometric distortion, studies the principle of image geometric distortion and the geometric distortion correction algorithm. The bilinear interpolation is a kind of common gray level interpolation method with high accuracy and without gray scale discontinuity problem when compared with nearest neighbor interpolation, but its calculation process is complicated with big calculation amount, thus affecting the real-time distortion correction. Therefore, this paper proposes the image distortion and correction algorithm with two-step and one-dimensional linear gray level interpolation to reduce the computing complexity of the bilinear interpolation method, and also realize the image geometric distortion correction. Correction experiments prove the effectiveness of the algorithm in this paper, and show such algorithm has higher recovery efficiency and good processing effect when compared with the traditional correction algorithm.

Causes of image distortion and geometric correction cause analysis of image distortion
In the image access process, because the imaging system itself is influenced by such factors as nonlinear, shooting angle and other factors, the image geometric distortion will occur. Geometric distortion is divided into the system distortion and the non-system distortion. System distortion is regular and can be predicted, and the non-system distortion is random. When making the quantitative analysis of the image, the precise geometric correction will be first implemented in the distorted image so as not to affect the accuracy of quantitative analysis.
Distortion is one imaging system aberration, and the ideal imaging system is not only clear in the imaging, but also satisfies the object image similarity relation. In the case that the system is able to achieve the clear imaging with dissimilar object image, the dissimilar degree is measured by the distortion. Distortion process describes the mapping relationship between the ideal image point position and the actual image point position, namely, (x, y, z) = f (x d , y d , z d ), and the key of the distortion correction lies in determining such mapping relationship. The geometric distortion of images collected by the machine vision system is nonlinear, so such nonlinear transform can be represented by the polynomial transform between coordinates: Correction accuracy is associated with n, the greater n is, the higher the correction accuracy is, but with the increase of n, the amount of correction calculation will increase sharply [11,12].

Geometric distortion correction
First study the address mapping relations under rectangular coordinate system by using the matrix is the image after the distortion. Average distortion is not just simple changes and tilt of the aspect ratio. What we usually encounter is the geometric distortion of the spatial warping type, here we adopt the quadratic polynomial to simulate, and the distortion can be expressed as, , u a a x a y a x a xy a y = + + + + + As well, once the estimation of the parameter (a i , b i ) can be obtained, the distortion function can be known, and the corrected spatial warping mapping can be achieved by the above polynomial transform [13].
(2) and (3) are the binary quadratic equation with 6 parameters. Once six pairs of corresponding points can be respectively taken from the distorted image and the corrected image, the estimation of the parameter (a i , b i ) can be achieved by the solution of equations. In theory, the more pairs of the corresponding points are taken, the more accurate the estimation of the parameter (a i , b i ) can be achieved is. Preset m is the corresponding point, so it can be expressed by the vector as: Its coefficient is The following Fig. 1 and Fig. 2 are images with distortion.

Bilinear spatial transform and interpolation method
For one image f with the image pixel coordinates of (x, y), after the geometric distortion, an image g is generated with the image pixel coordinates of (x′, y′), and such transform can be expressed as.
x r x y y s x y Here, r(x, y) and s(x, y) are the spatial transform, which generates the geometric distortion image s(x′, y′). For example, if r(x, y) = x / 2, s(x, y) = y / 2, the distorted image is simply the size contraction of f (x, y) by half on two spatial directions.
If r(x, y) and s(x, y) are known in the analytic study, in theory the reverse transform can be used to restore f (x, y) from the distorted image g (x′, y′). However, in practice, it is impossible to formulate the analytic function r(x, y) and s(x, y) set, and these analytic functions describe the geometric distortion in the whole image plane. The most commonly used way to overcome this difficulty is to express the pixel spatial relocation by the control point method, and these points are the subset of pixels, and their positions in the input (distorted) and output (corrected) image are accurately known. As long as you can find their corresponding relationship, and realize the correction for each pixel, finally the whole image can be corrected. The 4 vertices are corresponding points of junction. Assume that the geometric deformation of the quadrilateral area is modeled in bilinear equation, namely: From formula (7), we can infer: , .
x c x c y c xy c y c x c y c xy c Because there are total eight known points, and these equations can solve eight coefficients of c i , i = 1, 2,…8. These coefficients form the geometric distortion model used to transform all pixels in the quadrilateral area, and such quadrilateral is defined by the derived coefficient. Usually enough points are needed to generate the quadrilateral set of the whole image with each quadrilateral having its own set of coefficients [14].
Bilinear interpolation method realizes the linear interpolation in two directions by using four adjacent pixel grays of points to be solved. The following derived calculation formula has the pixel gray value to be solved.
For (x, y+v), we get For (x +1, y+v), we get For (x +u, y+v), we get This f (x +u, y+v) value stands for the gray value of (x, y) of the corrected image.
This method is more complex with large amount of calculation, but there is no gray discontinuity defect [15].

Two-step & one-dimensional linear gray level
interpolation method Assume the quadrilateral mapped in the distorted image by number i rectangle area I i (x i , y i ) of the lattice target surface as D i (x di , y di ), so the distortion model for such region is: .
Based on vertex coordinates (x i , y i )(i = 1∼4) of the rectangular area in the lattice target surface, and vertex coordinates (x di , y di )(i = 1∼4) of the quadrilateral region in the corresponding distorted image, the coefficient of distortion model can be determined from the form (10) and form (11). x y x y a x x y x y a x x y x y a x x y x y a x x y x y b y x y x y b y x y x y b y x y x y b y

Fig. 3. Bilinear interpolation scheme
After the geometric correction towards the distorted image by the distortion model, the gray value of each pixel of the output image needs to be determined again.
Here we adopt the backward mapping method to determine the gray value of the output image. The socalled backward mapping refers to the successive mapping of the output pixel into the distorted image collected in the visual system, and the corresponding gray level is determined by realizing the bilinear interpolation within 4×4 neighborhood around the mapping point. The specific principle is as follows.
Assume (x 1 , y 1 ), (x 2 , y 1 ), (x 1 , y 2 ), (x 2 , y 2 ) are the four points adjacent to the interpolating point (x, y), in which x 1 ≤ x ≤ x 2 , y 1 ≤ y ≤ y 2 , the gray value respectively are g 1 , g 2 , g 3 , g 4 , the bilinear function is defined as, If fixed variable x (or y), the function g(x, y) and variable y(x) forms the linear relationship.
Use the separability of two-dimensional bilinear function, namely the two-dimensional bilinear function can be seen as the product of two one-dimensional linear functions, to realize the two-dimensional bilinear interpolation algorithm by dividing into two-step onedimensional linear interpolation: first achieve the onedimensional linear interpolation along the horizontal direction, and then realize one-dimensional linear interpolation along the vertical direction, namely, 12 2 1 1 From form (13) and (14), we can get, g x y g g g g x g g g g yg In which λx = x -x 1 , λy = y -y 1 , and λx∈[0, 1], λy∈[0, 1].
Form (15) is same with the result of directly achieving two-dimensional bilinear interpolation, but the two-step one-dimensional linear gray interpolation greatly improves the computational efficiency, thus increasing the real-time distortion correction.

Analysis of experimental results
Distortion correction is divided into two steps. The first step is to achieve the geometric transform of the pixel coordinate space towards the original image, and the aim is to make the pixels in the correct position, the second step is to again determine the gray value of the new pixels. Because after the above coordinate transform, some pixels may be squeezed together and sometimes spread out, thus making corrected pixels do not fall on the discrete integer coordinate, so it's necessary to determine the gray value of these pixels. Implement the proposed distortion correction algorithm in Matlab environment programming, after establishing the distortion model, correct the distorted image with such a model. The following Fig. 4 and Fig. 5 show the process to determine the distortion model by using the standard lattice image.
The above Fig.4 and Fig.5 show respectively the collected original image and the results after the distortion correction. In which, Fig.4 (a) and Fig.5 (a) are the collected original distorted images, and the distortion are mainly expressed in the image pixel displacement, thus the distortion and deformation of the objects in the images occur, and such images face the barrel distortion. In the process of image distortion correction, the correction parameters are first obtained. First of all, choose apparent feature points as the control points between distorted image and standard image, and the number is determined by undetermined coefficients. Control points are one-to-one corresponding in the distorted image and standard image. Through the determination of the corresponding relation of these control points, the mapping relationship between distorted image and standard image can be established. The control points are artificially selected, and their coordinates are also read artificially. Secondly, establish the geometrical coordinate correction model based on the measured certain number of control points, because there exist errors, the control points of the distorted image and control points of the standard image belong to a kind of approximate correspondence rather than complete correspondence. Finally, according to the mapping relationship, correct coordinates of each pixel of the distorted image. There are many methods to evaluate the accuracy of calibration. In this paper, the average error and root mean square error are used to compare the correction effect. The statistical results are shown in Tab.1. The average distortion rate error is the residual distortion rate corrected by the algorithm, which reflects the correct degree of image restoration. It can be seen from the table that the errors of the coordinates of the grid points in both horizontal and vertical directions are improved, and this algorithm has a significant decrease in the ratio of the error before the improved algorithm. The root mean square error reflects the difference program between the computed imaging coordinates and the actual imaging coordinates. The more different the difference is, the better the effect of the original image, and the improved algorithm is obviously improved than the traditional algorithm.
In the following Tab. 1, All in all, Fig. 4b and Fig. 5b are the images after the distortion correction, and the images distortion are effectively corrected without emptiness and information leakage, and without color distortion, thus verifying the validity of the proposed algorithm in this paper. And Tab.1 indicate that the algorithm in this paper makes the image restoration more close to the ideal image.

Conclusion
In the process of imaging, the geometrical position of image pixels will face such deformation as extrusion, stretching, migration and distortion etc, make the image geometric location, size, shape, orientation and so on change. The image geometric distortion can be eliminated by geometric correction. Bilinear interpolation method is a kind of common gray level interpolation method when compared with nearest neighbor interpolation, such algorithm is highly précised without gray discontinuity, but its calculation process is complicated with large amount of calculation, which will influence the real-time distortion correction. This paper, based on the separability of the two-dimensional bilinear function, puts forward a kind of two-step and one-dimensional linear gray level interpolation image distortion correction algorithm.