Efficiency comparison of interpolation algorithms in opencv scaling

In OpenCV, the resize function is a function used to scale an image, which contains parameters dsize (output image size), fx(fy) (scaling factor of width and height), interpolation (interpolation algorithm), etc. Among them, interpolation represents the interpolation method used for image scaling, it is an enumeration type, and the following constants can be obtained:

- INTER_NEAREST:
 nearest neighbor interpolation method, which is the fastest algorithm, but it will cause image mosaic
- INTER_LINEAR:
 bilinear interpolation method, this is the default value, usually this method can get a better effect, its speed Also acceptable
- INTER_CUBIC:
 bicubic interpolation, this method is better than bilinear interpolation, but slower
- INTER_AREA:
 pixel area resampling, this method provides a basic alternative method, which can be used to perform Gaussian blur and other convolution operations on the image

- INTER_LANCZOS4:
Its main feature is to place the sampling points in a larger grid, and then use a polynomial to fit the interpolation function on it, so as to obtain a higher precision processing effect. Lanczos interpolation produces higher quality images, but it takes longer to compute than other methods

For the above unreasonable interpolation algorithms, use images above 1000X1000 to do 1000 tests in a loop, compile the program in release mode and run it (not debug mode), and get their efficiency differences:

INTER_NEAREST: 5.75 milliseconds, 1 times the time

INTER_AREA : 9699.12 milliseconds, 1687 times longer

INTER_CUBIC: 306.98 milliseconds, 53 times longer

INTER_LINEAR: 19.78 milliseconds, 3 times longer

Guess you like

Origin blog.csdn.net/henysugar/article/details/131204539