file format not supported by Hyperspectral Imaging Libray
6 views (last 30 days)
Show older comments
The Hyperspectral Imaging Libray does not seem to be working with my .hdr and .bil file. I got error when reading the .hdr file: Input file must be a ENVI header file.
My hyperspectral camera is PHOTON SYSTEMS INSTRUMENTS NVIR camera, it generates .bil and .hdr files. Here is an example .hdr file:
BYTEORDER I
LAYOUT BIL
NROWS 385
NCOLS 500
NBANDS 480
NBITS 12
BANDROWBYTES 1000
TOTALROWBYTES 480000
BANDGAPBYTES 0
CHROMATICCORRECTION True
STARTWAVELENGTH 352.485
ENDWAVELENGTH 898.805
INTEGRATIONTIME 49999
WAVELENGTHS
352.49
353.64
...
WAVELENGTHS_END
Is there any method to read such a .hdr file?
And how can I generate a hycube object using the .bil and .hdr file?
I tried reading the .bil file using multibandread() and construct a structure with meta data, and then use hypercube(image,wavelength,metadata), but I find that it seems to only support 'bsq' interleave, not 'bil' interleave.
Here is my code:
hcubeData = multibandread('/path/to/file.bil',[385 500 480],'ubit12=>uint16',0,'bil','ieee-le');
s = struct;
s.Height = 385;
s.Width = 500;
s.Bands = 480;
s.DataType = 'uint16';
s.Interleave = "bil";
s.ByteOrder = "ieee-le";
wavelength = [352.49 .... 898.81]; % a 1X480 vector
hcube = hypercube(hcubeData,wavelength,s);
In this way, I can generate the hcube, but it is using 'bsq' interleave format instead of 'bil' interleave (i.e., the meta 's' passed to the constructor hypercube didn't work). I traced back the code in the library and find that it's hard-coded to be using 'bsq' interleave.
Any suggestions on how to read my hyperspectral data? If i want to use the library, what shall I do?
Thank you!
0 Comments
Accepted Answer
Manasa Singam
on 22 Feb 2023
Hi Tao Hu,
hypercube expects envi header file to be in form of sample header file specified in this following link: https://www.l3harrisgeospatial.com/docs/enviheaderfiles.html.
hypercube expects "ENVI" characters to be present in first line of header file and have "=" to be the delimiter to seperate the key name and value pairs. hypercube is returning error since the sample header file you mentioned doesn't adhere to these presumptions.
We will look into the sample header file you have provided to check whether we can support it too. As of now, there are no alternatives apart from creating hypercube object with numeric array and wavelength as you have already done.
The data in the file for ENVI image data will be interleaved with bil, bip, and bsq encoding. Interleave will therefore be present in the file and be utilised to read data back, although it is not required for numeric arrays.
We are hard coding because the input numeric array (MxNxC) doesn't require interleave and it is in the form of band by band by channel, which reads as band by sequential.
You can set the "interleave" while writing the data back to the envi file using "enviwrite".
0 Comments
More Answers (0)
See Also
Categories
Find more on Hyperspectral Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!