The image is scaled using interpolation:
- bicubic (4x4)
- biakima (6x6)
- biline (2x2)
The image is resampled using:
- gsample (3x3)
Include prefilter:
- Gauss (for downsample)
- "Reverse Interpolate Scale (RIS)"
submodules:
$ git submodule init
$ git submodule update
build dependencies:
- build-essential
- cmake
$ sudo apt-get install build-essential cmake
$ mkdir build
$ cd build
$ cmake ..
$ make
The first and second parameters specify the paths to the image and the result {PNG}. The -H
, -W
and -r
options set the resulting dimensions. If -H
or -W
is given, then -r
is ignored. The -m
option specifies the scaling method {0 - bicubic, 1 - biakima, -1 - biline, -2 - gsample}. The -p
option specifies the "Reverse Interpolate Scale (RIS)" (if equal to 0, then RIS is disabled).
./stbresize -r 4 ${IMAGE_PATH} ${IMAGE_PATH}.out.png
biakima.h
- biakima image scalingbicubic.h
- bicubic image scalingbiline.h
- biline image scalingdependencies.c
- API stbgauss.h
- prefilter: Gaussgsample.h
- gsample image samplerhris.h
- HRIS/mean scale: Reverse Interpolate Scale (RIS)ris.h
- prefilter: Reverse Interpolate Scale (RIS)stb/
- stbstbresize.c
- CLI program.
Use bicubic or biakima interpolation method to scale the image. The principle is: for each pixel in the scaled image, find the nearest 4x4 or 6x6 pixel grid at the corresponding position in the original image, and use this grid to perform interpolation to obtain RGB of this pixel. See bicubic.h
or biakima.h
for details.
Regarding the principle of zooming by the bicubic interpolation method, it is not expanded here, so you can ignore it.
Use the stb image library for processing, you can ignore it.
After reading in the picture, a 3-channel pixel matrix is obtained, that is, the RGB of each pixel is arranged together, each occupying a byte.
The layout of images in memory is shown in the figure:
See demo and compare.