You are here: Appendix A - Technical Notes > Notes on BBB Files

## Notes on BBB Files

A BBB image consists of two files, a binary file containing only the raw sample values of the image and a text file describing the image properties. The raw data may be organized in one of three layouts: "band-interleaved by pixel" (BIP), "band-interleaved by line" (BIL), and "band sequential" (BIL). The three formats are collectively referred to as the BBB file format.

Because BBB files only contain raw data with an easily editable header format, they are often used as a "least common denominator" interchange format. However, there is no set standard for the keywords that may be contained in the header. This document describes the header format that the MrSID SDK supports, via the LTIBBBImageReader and LTIBBBImageWriter classes.

###### Filenames

The LTIBBBImageReader class supports four filename extensions: .bip, .bil, .bsq, and .bbb. The first three imply the layout is BIP, BIL, or BIP respectively; the .bbb extension implies the default layout, which is BIP.

The header file for a BBB image has the same name as the image, but with a .hdr extension.

###### Header Syntax

The header file is a simple text file containing keywords and their associated value, one keyword/value(s) set per line.

All keywords and values are case-insensitive.

Blank lines are ignored. Leading and trailing whitespace is ignored.

A line that begins with a '#' character, possibly preceded by whitespace, indicates a comment line. Comment lines are ignored.

###### Supported Keywords (Reader)

The keywords and their allowed values, as supported by the LTIBBBImageReader, are as follows:

BANDGAPBYTES

Not currently supported – value is ignored

BANDROWBYTES

Not currently supported – value is ignored)

BANDS

Same as NBANDS

BYTE_ORDER

Endianness interpretation of data

Allowed values:

> - MOTOROLA, M, BIG, BIGENDIAN
> - INTEL, I, LITTLE, LITTLEENDIAN
> - NA

Default: host endianness

The value NA (not applicable) may only be used if the number of bands is 1

BYTEORDER

Same as BYTE_ORDER

COLORSPACE

The colorspace of the image

Allowed values:

> - GREY, GRAY, GREYSCALE, GRAYSCALE
> - RGB
> - CMYK
> - MULTISPECTRAL

Default: GRAY for 1-banded images, RGB for 3-banded images, otherwise MULTISPECTRAL

COLS

Same as NCOLS

DATATYPE

The data type of the samples

Allowed values: U8, U16, F32

Default: U8

DYNAMICRANGELEVEL

The midpoint of the range of the data

Allowed values: a single floating-point value (applies to all bands)

Default: (none – value is determined by LTIImage)

DYNAMICRANGEMAX

The maximum dynamic range

Allowed values: a single floating-point value (applies to all bands)

Default: (none – value is determined by LTIImage)

DYNAMICRANGEMIN

The minimum dynamic range

Allowed values: a single floating-point value (applies to all bands)

Default: (none – value is determined by LTIImage)

DYNAMICRANGEWINDOW

The size of the range of the data

Allowed values: a single floating-point value (applies to all bands)

Default: (none – value is determined by LTIImage)

E_SQUARED

Sphere eccentricity squared, for georeferencing

Allowed values: (floating-point)

Default: (none)

INTERLEAVING

Same as LAYOUT

LAYOUT

The data layout; use of this keyword overrides the layout implied by the filename extension

Allowed values: BIP, BIL, BSQ, or NA

Default: BIP

The value NA (not applicable) may only be used if the number of bands is 1

MAP_UNITS

Measurement unit for georeferencing

Allowed values: (string)

Default: (none)

NBANDS

The number of bands in the image

Allowed values: 1-65535

Default: (none – this keyword is required)

NBITS

Number of bits used per sample

Allowed values: 1 to (total number of bits per sample)

Default: the total number of bits per sample

NCOLS

Width of image, in pixels

Allowed values: 1 to 2^31

Default: (none – this keyword is required)

NROWS

Height of image, in pixels

Allowed values: 1 to 2^31

Default: (none – this keyword is required)

PIXEL_HEIGHT

Same as YDIM

PIXEL_WIDTH

Same as XDIM

PROJECTION_NAME

Name of projection system, for georeferencing

Allowed values: (string)

Default: (none)

PROJECTION_PARAMETERS

Numeric projection parameters, for georeferencing

Allowed values: (1 to 15 floating point values)

Default: (none)

PROJECTION_ZONE

Projection zone number, for georeferencing

Allowed values: (int32)

Default: (none)

RADIUS

Sphere radius, for georeferencing

Allowed values: (floating point)

Default: (none)

ROWS

Same as NROWS

SEMI_MAJOR_AXIS

Semimajor axis, for georeferencing

Allowed values: (floating point)

Default: (none)

SEMI_MINOR_AXIS

Semiminor axis, for georeferencing

Allowed values: (floating point)

Default: (none)

SKIPBYTES

Number of bytes at top of image file to skip

Allowed values: 0 to (image size in bytes)

Default: 0

This can be used for raw formats which contain a fixed number of "header" bytes at the top of the data file

SPHEROID_NAME

Name of projection system, for georeferencing

Allowed values: (string)

Default: (none)

TOTALROWBYTES

Not currently supported – value is ignored

UL_X_COORDINATE

Same as ULXMAP

UL_Y_COORDINATE

Same as ULYMAP

ULXMAP

Upperleft x-position, for georeferencing

Allowed values: (any floating point value)

Default: (none – value is determined by LTIImage)

ULYMAP

Upperleft y-position, for georeferencing

Allowed values: (any floating point value)

Default: (none – value is determined by LTIImage)

WORDLENGTH

Number of bytes per sample

Allowed values: 1 or 2

Default: 1, unless overridden by DATATYPE

XDIM

Size of pixel in x-direction, for georeferencing

Allowed values: (any floating point value)

Default: (none – value is determined by LTIImage)

YDIM

Size of pixel in y-direction, for georeferencing

Allowed values: (any floating point value)

Default: (none – value is determined by LTIImage)

This is expected to be a positive value

###### Additional Notes

- These keywords are required: NBANDS, NCOLS, NROWS. All other keywords have default values.
- If dynamic range is used, either both DYNAMICRANGEMIN and DYNAMICRANGEMAX must be set or both DYNAMICRANGEWINDOW and DYNAMICRANGELEVEL must be set.

###### Supported Keywords (Writer)

The LTIBBBImageWriter class only writes a subset of the above keywords to the header file. The keywords used are:

BYTEORDER

Determined by constructor

COLORSPACELAYOUT

Only set if image colorspace is

CMYK

Set to BIP, BIL, or BSQ as per constructor argument

NROWS

Height of scene being written

NCOLS

Width of scene being written

NBANDS

Number of bands in image

NBITS

Bits of precision of image samples

ULXMAP

Determined by scene/image

ULYMAP

Determined by scene/image

XDIM

Determined by scene/image

YDIM

Determined by scene/image

###### Example

This BBB header files describes a 640x480 color image, using 16 bits per sample.

    NROWS 480

    NCOLS 640

    NBANDS 3

    DATATYPE U16

###### Extensions

Note that some of the header syntax supported by the MrSID SDK may not be supported by other vendors' BIP/BIL/BSQ implementations. In particular, the following features and keywords may be somewhat specific to LizardTech:

- interpretation of .bbb extension as meaning layout of BIP
- support for comment lines
- the COLORSPACE keyword
- the DYNAMICRANGEMIN, DYNAMICRANGEMAX, DYNAMICRANGEWINDOW, and DYNAMICRANGELEVEL keywords