Code Monkey home page Code Monkey logo

imageinterpolation's Introduction

Image interpolation

This is my own implementation of image interpolation. Used for upscale (and downscale) of images.

I have no initial ambitions to make this the fastest or leanest resource consuming algorithm out there. This project and implementations are made to explore techniques and algorithms to support texture interpolation in my raytracing endeavours as I can not use traditional algorithms or libraries on my own proprietary internal image format. (Plus I need to account for texture wrap and flipping on tiling textures.)

License

CC0

It is not a requirement by the license, but if you do improve the code then any feedback or pull request is very appreciated. Sharing is caring.

Dependencies

Nope. No exotic dependencies to mention.

This library applies to the vanilla images as provided by the standard go library image.

TODO

  • Make sure all calculations are made on alpha and not premultiplied color values.

  • Implement sRGB gamma calculation (not plain gamma 2.2)

Testing

No extensive mathematical testing nor unit tests has been done.

Important
WYSIWYG - literally.

Algorithms

Algorithms are created from scratch based on information found at wikipedia.

All algorithms are working in RGB space.

All interpolation calculations are made in linear RGB space. Gamma of 2.2 is assumed for original image.

(Wikipedia is fantastic source of knowledge, if you use it more than 5 times a year consider what it saves you in time and other expenses for dictionaries, courses, and wasted time searching. Give them a contribution to keep it running and open.)

algorithms
Figure 1. Different interpolation algorithms. Illustration by Cmglee at wikipedia CC BY-SA 4.0.
  • Pixel boxing, used for down scaling an image. An image can be reduced by an integer factor in both width and height dimension. As pixels are evenly averaged during reduction the average color information is preserved. A (small) rounding error going from floating point values to integers is introduced upon consecutive reductions.

Results

Upscale

These algorithms can be used for upscaling an image.

Original image
Figure 2. Original image used for upscale examples. (This image is just a large preview. The actual original image is merely the 5x5 pixels.)

Nearest neighbour

Nearest neighbour interpolation
Figure 3. The original image of 5x5 pixels upscaled to 250x250 pixels using nearest neighbour interpolation.

Bilinear

Bilinear interpolation
Figure 4. The original image of 5x5 pixels upscaled to 250x250 pixels using bilinear interpolation.

Bicubic (using Cubic Hermite spline)

Bicubic interpolation
Figure 5. The original image of 5x5 pixels upscaled to 250x250 pixels using bicubic interpolation (using Cubic Hermite spline).

imageinterpolation's People

Contributors

chran554 avatar

Stargazers

 avatar

Watchers

 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.