When doing digital image processing, we often encounter the problem of decimal pixel coordinate, then we need to interpolate the coordinates according to the value of neighboring pixels. For example: To do a map projection transformation, the target image of a pixel coordinate transformation to the corresponding point in the source image, the corresponding coordinates of the transformation is a decimal, again such as the geometric correction of the image, you will encounter the same problem. See enough of the various mathematical principles, directly on the specific implementation steps. No formula no theory, the following is a common three kinds of digital image interpolation method is introduced.
1. Nearest neighbor interpolation method (Nearest neighbour interpolation)
This is the simplest interpolation method, do not need to calculate, in the neighborhood pixel of the pixel to be asked, the pixels from the nearest neighbor to the pixel grayscale to be assigned to the desired pixel. Set I+u, J+v (i, J is a positive integer, U, v is greater than 0 decimals less than 1, the same below) for the pixel coordinates, the pixel gray value f (i+u, j+v) as shown:
if (I+u, j+v) falls in area A, that is u<0.5, v<0.5, then the upper-left pixel of the gray value of the pixels to be asked for pixels, in the same vein, the B area is assigned to the upper right corner of the pixel gray value, falling in the C zone gives the lower-left pixel gray value, falling in the D area is given to the
Features: The nearest neighbor interpolation method, although the computational amount is small, may cause the interpolation to generate the image gray level discontinuity, may appear in the gray scale change place the apparent sawtooth shape.
2. Bilinear interpolation method (Bilinear interpolation)
The basic idea of bilinear interpolation is based on the gray value of 4 neighboring points of the point (U,v), which is calculated by three linear interpolation, as shown in:
If you use [s] to indicate a maximum integer that does not exceed S, then
S1: from F (u,v), F (u+1,v) for the first horizontal interpolation calculation, to obtain:
S2: The interpolation calculation of the second horizontal direction by F (u,v+1) and F (u+1,v+1) is obtained:
S3: By and doing the third vertical direction interpolation calculation, to obtain:
Essence: 3 linear interpolation in 2 directions based on the gray values of 4 nearest neighbor pixel points
Features: The bilinear interpolation method is more complex than the nearest neighbor point method, the computational amount is large, but there is no gray scale discontinuity, the result is basically satisfactory. It has low-pass filtering property, so that the high-frequency component is damaged, the image contour may be a little blurred.
3, three-time polynomial interpolation (Cubic polynomial interpolation)
For two-dimensional medical image interpolation, it is necessary to consider the effect of the gray value of 16 neighborhood points, as shown in:
The algorithm process is as follows:
S1: Definition of two intermediate variables
S2: Using four-time polynomial interpolation on four horizontal lines to calculate the gray value at a,b,c,d four points
S3: Three polynomial interpolation on the vertical direction of the a,b,c,d four points, calculated
where the function c (x) is defined as follows:
Features: three-time polynomial interpolation method with high precision, but large computational value
Realization of two-dimensional image interpolation algorithm