HSI files overview#
This page provides general information about how HSI files are structured and what basic operations are necessary to use them.
Memory layout and interleave#
The memory layout of HSI files is important because of memory locality. A bad match between the use case and memory layout can lead to a worst case quadratic increase in the number of cache misses. As a consequence, it is important to be able to identify which layout is most suitable in a given situation and how to transform between them.
The ENVI format uses the concept of interleave to describe the three possible 3d array layout types. Named BSQ, BIL, and BIP, the type names can lead to unnecessary confusion about what is really a simple concept. The diagram below demonstrates how each format is laid out in memory.
Fig. 1 This diagram illustrates how the three interleave types dictate the in-memory layout of HSI files. The top box describes the order in which each axis is laid out in memory. Elements in “0” are consecutive.#
Each format can be visualised in two dimensions using color to represent the band axis. This visualisation might give a more intuitive sense of what format is needed for a given situation.0

Fig. 2 A BSQ example file. It is like a stack of grayscale images for each band.#

Fig. 3 A BIP example file. This is how a regular RGB image is usually stored. The data for each pixel is consecutive.#

Fig. 4 A BIL example file. Each horizontal line is consecutive in memory for a given band.#
Interleave conversion#
Converting between the formats is simple but can get confusing. The diagram below illustrates how one transforms from each of the formats to any other.
Fig. 5 The figure is a reference for determining how to permute axes from one format to another.#