Giter VIP home page Giter VIP logo

stb-image-resize's Introduction

stb-image-resize

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)"

build

load submodules

submodules:

$ git submodule init
$ git submodule update

install dependencies

build dependencies:

  • build-essential
  • cmake
$ sudo apt-get install build-essential cmake

compilation

$ mkdir build
$ cd build
$ cmake ..
$ make

use

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

structure

  • biakima.h - biakima image scaling
  • bicubic.h - bicubic image scaling
  • biline.h - biline image scaling
  • dependencies.c - API stb
  • gauss.h - prefilter: Gauss
  • gsample.h - gsample image sampler
  • hris.h - HRIS/mean scale: Reverse Interpolate Scale (RIS)
  • ris.h - prefilter: Reverse Interpolate Scale (RIS)
  • stb/ - stb
  • stbresize.c - CLI program.

image scaling

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:
RBGImage


See demo and compare.

stb-image-resize's People

Contributors

zvezdochiot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.