Git Product home page Git Product logo

imageresampler's Introduction

imageresampler

Exported from http://code.google.com/p/imageresampler. Original author is Rich Geldreich at richgel99 at gmail.com.

imageresampler is a pubic domain (see unlicense.org) C++ class for memory efficient image/bitmap resampling loosely based on a (heavily bugfixed) version of Dale Schumacher's public domain resampler in Graphics Gems 3 (1994). It supports a wide range of filter kernels and windowing functions, clamp/wrap/reflect boundary modes, arbitrary source image phase offsets, floating point pixels with any number of components, and can process images much larger than available memory.

A long time ago, this resampler was written originally in C and 16-bit x86 assembly and was used in a printer driver for a DOS image viewer product. Memory was extremely tight in this environment, which is why this class supports streaming resampling. I've also successfully used this class to generate texture mipmaps in the tool chains of various PC and console game projects. This version is written in fairly portable C++.

Features

  • Can up/downsample completely independently on each axis.
  • Plenty of antialiasing filters: box, tent, bell, b-spline, Mitchell, Lanczos 3/4/6/12, Blackman, Kaiser, Gaussian, etc.
  • Filter kernels can be offset and scaled (shrinking the kernel a bit to sharpen the output is very useful when generating texture mipmaps)
  • Supports clamp, wrap, etc. boundary modes - useful when filtering wrapping textures
  • Chooses the axis resample order that minimizes the total number of ops, like Heckbert's Zoom.
  • Operates on any number of input channels, floating point input/output
  • Minimal memory/streaming operation: you feed it some input scanlines, and it gives you as many output scanlines as it can. Or if you don't care about RAM you can feed it all your input scanlines, then "pull" all the output scanlines.

The source archive includes Visual C++ 2005 and 2008 solutions, and a Codeblocks 10.05 workspace.

Release History

  • v2.21 - June 4, 2012: Added unlicense.org text (instead of just plain public domain), integrated GCC fixes supplied by Peter Nagy [email protected], Anteru at anteru.net, and [email protected], added Codeblocks project (for testing with MinGW and GCC), added VS2008 project files, VS2008 static code analysis pass, added calls to delete at end of test.cpp.
  • v2.20 - Dec. 31, 2008: Released to public domain on Google Code.

Test Executable Instructions

I've included a precompiled Win32 executable under bin/resampler.exe. Example usage:

  resampler source_image.tga dest_image.tga dest_width dest_height

Where dest_width/dest_height is the desired destination image's resolution. The destination format is hard coded to TGA, but the source image may be in any format that Sean Barrett's STB Image module supports: PNG/BMP/TGA/etc.

Additional Links

Support Contact

For any questions or problems with this code please contact Rich Geldreich at richgel99 at gmail.com. Here's my twitter page.

imageresampler's People

Contributors

rwohleb avatar

Stargazers

Ric Li avatar  avatar Ming Xu avatar  avatar  avatar  avatar Iain Ballard avatar Microqq avatar Christian Helmich avatar Scott Lembcke avatar Long Nguyen avatar Alin avatar Patricio Gonzalez Vivo avatar  avatar  avatar Kieran Bingham avatar beru avatar  avatar NiLuJe avatar Denny Cai avatar Aidan Dodds avatar

Watchers

James Cloos avatar

Forkers

huafengchen tpjg

imageresampler's Issues

test.cpp leaks memory

The memory allocated to the resamplers array on line 80 in test.cpp has no 
corresponding call to delete.

80    Resampler* resamplers[max_components]; // memory allocated to this array 
is never deleted                                                                


81    std::vector<float> samples[max_components];                               


82                                                                              


83    resamplers[0] = new Resampler(src_width, src_height, dst_width, 
dst_height, Resampler::BOUNDARY_CLAMP, 0.0f, 1.0f, pFilter, NULL, NULL, 
filter_scale, filter_scale);                                                    

84    samples[0].resize(src_width);                                             


85    for (int i = 1; i < n; i++)                                               


86    {                                                                         


87       resamplers[i] = new Resampler(src_width, src_height, dst_width, 
dst_height, Resampler::BOUNDARY_CLAMP, 0.0f, 1.0f, pFilter, 
resamplers[0]->get_clist_x(), resamplers[0]->get_clist_y(), filter_scale, 
filter_scale);                
88       samples[i].resize(src_width);                                          


89    }

Fixed by adding
for (int = 0; i < n; ++i) { delete resamplers[ i ]; }
before returning from main().

Original issue reported on code.google.com by [email protected] on 5 Sep 2011 at 7:28

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.