MATLAB Answers

Reading a RAW file from a hyperspectral camera using ENVI information

13 views (last 30 days)
Henk-Jan Ramaker
Henk-Jan Ramaker on 10 Jun 2021
Answered: Subhadeep Koley on 11 Jun 2021
I have captured and stored data that comes from a hyperspectral camera. This results in 2 files:
''example_file.raw''
''example_file.hdr''
I use the function read_envihdr to load ''example_file.hdr'':
example_file.hdr
>> read_envihdr('example_file.hdr')
ans =
struct with fields:
CONTENT: 'ENVI'
file_type: 'ENVI Standard'
sensor_type: 'MONARCH'
wavelength_units: 'nm'
data_type: 12
interleave: 'BSQ'
byte_order: 0
bit_depth: 10
header_offset: 0
wavelength: {10×1 cell}
gain: {10×1 cell}
exposure_time: {10×1 cell}
exposure_type: '{↵radiometric-calibration↵}'
default_bands: {[713]}
lines: 1024
samples: 1280
bands: 10
size: [1024 1280 10]
machine: 'ieee-le'
iscomplex: 0
format: 'uint16'
>>
Now, I don't have much experience reading hyperspectral data. But what I understand so far is that the ENVI standard is more or less required (or at least very handy) to load the *.raw file. Can anybody give me a hint how to proceed further to read the *.raw file now that I have the ENVI standard information available?

Answers (1)

Subhadeep Koley
Subhadeep Koley on 11 Jun 2021
You can use the enviinfo(__) function to read metadata from your ENVI header file (.hdr file), and then you can use multibandread(_) to read the binary .raw file.
% Read ENVI header file
info = enviinfo('example_file.hdr');
% Read the .raw data file
data = multibandread('example_file.raw',[info.Height, info.Width, info.Bands],...
info.DataType, info.HeaderOffset, info.Interleave, info.ByteOrder);
NOTE: The above mentioned fetures (e.g. enviinfo(_)) come under Image Processing Toolbox's Hyperspectral Imaging Library support package, and can be downloaded from here.
For more information on Hyperspectral Imaging Library see the documentation.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!