Imagine is a 256-bit image processing engine that serves as the foundation for several of my game, graphics, and computer vision research projects. I began this project in 2009 after scouring the web and being unable to find an image processing library that fit my particular needs. In particular, I was interested in a library that was:
Fast: multi-threaded vectorized CPU implementations plus CUDA GPU implementations
Portable: able to run on PCs and mobile devices without significant updates
Readable: well written and documented code
Accurate: reliable implementation that consistently produces correct results
Usable: the library must support common image file formats
Lightweight: does not contain significant bloat or extraneous features
My primary goal for Imagine was that it be powerful yet also easy to understand. By avoiding unnecessary complexity, I believe that this software is approachable for engineers without extensive image processing experience, and serves as a great learning resource.
Over the past ten years this project has been used in several university courses as a teaching aid and assignment guide. The code is highly commented with descriptive explanations of both the theories and the practical considerations that went into the implementation.
Imagine contains a 256 bit (64 bits per channel) image processing engine that supports a fully customizable set of filters, formats, and types. Types are described by a flexible data format that allows developers to easily create data layouts that are automatically accepted and interpreted by the rest of the engine. A preselected set is provided that includes some of the most common formats, including:
Unsigned integer:
R8, R16, R24, R32
YUV411, YUV422, YUV420, YUV444
R3G3B2, R5G6B5, R5G5B5A1, R4G4B4A4
R8G8B8, R16G16B16, R32G32B32, R8G8B8A8, R16G16B16A16, R32G32B32A32
Signed integer:
R8S, R16S, R32S
R8G8B8S, R16G16B16S, R32G32B32S
Floating point:
R16F, R32F
R32G32F, R16G16B16F, R32G32B32F, R16G16B16A16F, R32G32B32A32F
Special purpose:
D16, D32, D16F, D32F
R10G10B10A2, R10G10B10A2F
Filters are the primary workhorse of Imagine and they are comprised of kernels and operators. Kernels provide a common interface to perform image sampling while operators are responsible for image manipulation tasks. Both of these systems are supported by an array of helpers that manage data conversion, packing, and other tasks required by the engine.
Imagine currently supports the following configurable kernels:
Average
Bicubic
Bilinear
Bokeh
Mitchell-Netravali
Coverage
Gaussian
Catmull-Rom Bicubic
Lanczos
Nearest Neighbor
Cubic Spline
Cubic B-Spline
Imagine currently supports the following operators which in turn rely upon the kernels to sample images. In this manner, a simple blur operator automatically supports gaussian blur, coverage blur, etc.
Arithmetic Adjust
Blit
Blur
Tilt/Shift
Brightness
Clone
Inverse
Precise Mean
Resample/Resize
Sepia Toning
Splat
Barrel Correction
Fourier Transform
Haar Wavelet Transform
Gaussian Pyramid
Sharpen Image
Motion Blur
Radial Blur
Depth of field (requires D16 companion)
Lens Glare and Flare
Contrast
Convert Format
Crop
Desaturate
Flip
Focal Blur
Lomo
Mosaic
Rotate
Convert Space (RGB,YUV,HSV, etc.)
Vignette
Bayer Demosaic
Discrete Cosine Transform
Harris Detector
Detect Edges
Clarify (noise removal)
Ripple and Wave
Anamorphic Flare
Motion Vectors
HDR Bloom
Imagine supports the following image file formats. Also note, adding a new image format to Imagine is easy and (usually) does not require any updates to the rest of the engine.
24 and 32 bit Bitmaps (.bmp)
Portable network graphics (.png)
Joint Photographic Experts Group (.jpeg, .jpg)
Portable Graymaps (.pgm, .ppm)
24 and 32 bit uncompressed Targa (.tga)
Primitive Texture Compression (.ptc)
OpenEXR HDR Images (.exr)
Tagged Image File Format (.tiff, .tif)
Imagine is currently closed source because it is being used under a commercial license by a partner. However, I have made educational versions of the resampler, kernel, and operator code available at the links below.
Single Header Image Resampler (Source code)
Imagine Kernels & Operators (Source code)
Check out a demo of the image resampling logic that ships within the Imagine framework.
This simple utility enables you to resize bitmap images using a number of different sampling kernels. Note this is simply a pre-built executable of Tutorial1.cpp, provided within the
single header image resampler source.
Resampler demo for Windows (22 KB)
For more information about the inner workings of Imagine, check out this blog post.