Get Teem at SourceForge.net. Fast, secure and Free Open Source software downloads
teem / nrrd

  Advocacy

Here are aspects of the NRRD file format and/or the nrrd library that may inform a decision on how to best store, communicate, and manipulate raster data:
Simplicity: Stark simplicity is the main principle of nrrd. The file format is a human-readable ASCII header followed by the data. The data structure is a thin wrapper around a void*. The nrrd library has simple calls like nrrdLoad() and nrrdSave() which do what you expect. There is no attempt to provide clever layers of abstraction or indirection, only the basic facilities to represent and manipulate raster data. Nrrd is written in plain C. Numerous people have found it very easy to write their own customized C++ wrappers around nrrd.

Functionality: the nrrd library supports about two dozen operations on nrrds, nearly all of which are general with respect to the type and dimension of the nrrd. Operations include: slicing, joining, cropping, padding, projecting, histogramming, histogram equalization, quantizing, axis permuting, color mapping, gamma correction, component-wise arithmetic operations like adding and multiplying, as well as filtered resampling (up and down) with arbitrary seperable kernels.

Detached headers: The ability to have the NRRD header in a seperate file than the data file, and the ability to skip past lines or bytes of another format's ascii or binary header, means that nrrd plays well with other file formats.

Portability: nrrd has been compiled on Windows, Macintosh (OS X), Cygwin, GNU/Linux, Solaris, and Irix (both 32 and 64 bit). Big-versus-Little endianness is explicitly recorded in the NRRD header when necessary, and nrrd can convert between the two as needed. nrrd makes some assumptions about type sizes, which aren't strictly speaking portable, but none these have been a problem on the current set of platforms.

Availability: The nrrd library and associated utilities are available for download in source and binary forms. All this software is distributed under the terms of a weakened LGPL (to facilitate static linking).

Representational power: The Nrrd struct can represent raster data of any type and any dimension. Ten basic C types are supported (from 8-bit integers to 64-bit doubles), as well as a "block" type for representing arbitrary chunks of memory, such as C structs or C++ objects. Key/value pairs of strings can be stored in the Nrrd struct and the NRRD file format, as a simple but effective means of storing general information about the array, such as a URL giving the data source, or DICOM sequence numbers. Various kinds of array-specific information is represented and saved to file, such as sample spacing along each axis, node versus cell centering, char* labels for each axis, and comments. Peripheral information is maintained and generated by nrrd functions. A resampled image will know its new sample spacings as compared to the original. If you quantize floating-point data down to 8, 16, or 32 bits, the Nrrd will remember the original min and max values prior to quantization.

Flexibility in file formats: The data in NRRD files can be raw, ascii, or compressed. The nrrd library can read and write more than just NRRD files. PNG, PPM, and PGM image files can be used to save nrrds of the appropriate type and dimension, and comments in the header losslessly encode all other peripheral information represented by nrrd. For one and two dimensional data, plain text files with no header whatsoever (such as produced by Excel when exporting to plain text) are read and written with the same functions used for all the other formats. VTK datasets defining scalars, vectors and tensors on STRUCTURED_POINTS geometries can also be read and written.