File Formats
Gerbil can read both established file formats as well as a custom format. The custom format has two advantages:
- It is very easy to convert self-captured data into this format
- Gerbil has a memory savings mode to load larger images into memory which only works with this format
Established File Formats
Gerbil uses the versatile GDAL library to read image data. This leads in a comprehensive list of formats covered. Gerbil uses GDAL to read both the raster data as well as associated metadata (wavelength information).
As an alternative, Gerbil can fall-back to reading image files via OpenCV. This means it can also operate on regular R, G, B data.
File formats supported through GDAL and OpenCV include (not limited to):
- ENVI .hdr Labelled Raster
- ESRI .hdr Labelled
- FITS (.fits)¹
- TIFF / BigTIFF / GeoTIFF (.tif)
- ERDAS (.ecw, .img, .lan, .gis, …)¹
- JPEG2000 (.jp2, .j2k)¹
- PNG
- Netpbm
¹GDAL needs to be compiled correspondingly
When opening data stored as a raster file / header file tuple, you need to direct Gerbil to the raster file. It will then read the associated header file automatically. Opening the header file will not work.
If your data is not available in one of the formats understood by GDAL, you may easily convert it to a simple custom compound file format that Gerbil understands. A common example is data from MATLAB. Export the single bands in separate grayscale files and write a descriptor file as explained below. A MATLAB script that does this can be found in Downloads.
Custom File Format
The main concept behind our file format is ease-of-use without duplication of present data. The hyperspectral cube is represented by an array of intensity images, each describing one spectral band. A human-readable descriptor file then provides the meta information necessary to construct the image from these intensity files.
Descriptor File
The software reads images as an array of image files (depicting one filter band each), each grayscale (8 or 16 bit) and in any image format that OpenCV understands. All files have to be of the same spatial size. A descriptor file is needed in the following format:
<number of bands n>
<base directory where files are located>
<filename 1> [<peak wavelength> | <lower wl bound> <upper wl bound>]
<filename 2> ...
...
<filename n> ...
You can either give no wavelength information, or the peak wavelength of the band filter, or the lower and upper bounds of the filter, individually.
Wavelength information is shown in the software and used to compute the RGB depiction.
Example
Following is the descriptor file used for an image from the CAVE multispectral database.
31 photo_and_face_ms/ photo_and_face_ms_01.png 400 photo_and_face_ms_02.png 410 photo_and_face_ms_03.png 420 photo_and_face_ms_04.png 430 photo_and_face_ms_05.png 440 photo_and_face_ms_06.png 450 photo_and_face_ms_07.png 460 photo_and_face_ms_08.png 470 photo_and_face_ms_09.png 480 photo_and_face_ms_10.png 490 photo_and_face_ms_11.png 500 photo_and_face_ms_12.png 510 photo_and_face_ms_13.png 520 photo_and_face_ms_14.png 530 photo_and_face_ms_15.png 540 photo_and_face_ms_16.png 550 photo_and_face_ms_17.png 560 photo_and_face_ms_18.png 570 photo_and_face_ms_19.png 580 photo_and_face_ms_20.png 590 photo_and_face_ms_21.png 600 photo_and_face_ms_22.png 610 photo_and_face_ms_23.png 620 photo_and_face_ms_24.png 630 photo_and_face_ms_25.png 640 photo_and_face_ms_26.png 650 photo_and_face_ms_27.png 660 photo_and_face_ms_28.png 670 photo_and_face_ms_29.png 680 photo_and_face_ms_30.png 690 photo_and_face_ms_31.png 700