当前位置:网站首页>Image interpolation (nearest neighbor, bilinear)

Image interpolation (nearest neighbor, bilinear)

2022-06-22 07:14:00 A rookie comes to study

( digital image processing )- Image interpolation

Interpolation is an image resampling method , Used for image enlargement , narrow , Rotation and geometric correction , In essence, interpolation is a numerical process that uses known data to estimate unknown positions .

1. Nearest neighbor interpolation algorithm


Will a 2x2 Image src(w_s=2,h_s=2) Zoom in to 3x3 Images dst(w_d=3,h_d=3):
According to the formula :
ratio = The source image / Target image
Horizontal axis scale factor vx=w_src / w_dst=2/3
Longitudinal axis scale factor vy=h_src / h_dst=2/3

The value of the target image dst[x,y]=src[x * vx,y * vh]
x * vx,y * vh It could be a decimal , rounding

 Insert picture description here
Finally, as shown in the figure , Summary is scaling
The advantage of this method is that it is simple , But the downside is that it's too rough , Precision will be lost , Causes discontinuities in the grayscale of the scaled image , There may be obvious zigzags in the changing places .

2. Bilinear interpolation algorithm


Bilinear is to use two straight lines parallel to the coordinate axis to decompose the decimal coordinates into the sum of four adjacent integer coordinates , Weight is distance .
P Points are decimal coordinates ,Q Is the adjacent four integer coordinates

Calculation R1 R2

1. First, according to Q11 = (0,1) and Q21 = (1,1) The pixel values of these two pixels are calculated R1=(x,y1) Pixel value of pixel point
2. And then according to Q12 = (0,0) and Q22 = (1,0) The pixel values of these two pixels are calculated R2=(x,y2) Pixel value of pixel point
 Insert picture description here
Again by R1,R2 Get the results
 Insert picture description here
The concept of weight is used , A lot of improvement

原网站

版权声明
本文为[A rookie comes to study]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202220539161096.html