File Exchange

image thumbnail

read_envihdr

version 1.0.0.0 (3.19 KB) by Jaroslaw Tuszynski
Robust reader of ENVI header files.

11 Downloads

Updated 04 Oct 2012

View License

INFO = READ_ENVIHDR('HDR_FILE') reads the ASCII ENVI-generated image header file and returns all the information in a structure of parameters. Usefull in combination with MATLAB multibandread function capable of reading ENVI binary files.

The file is a result of frustration with other ENVI header readers found on MATLAB File Exchange, which I could never get to work properly.

Output:
* Info - struct with fields provided in the ENVI file. ENVI header format requires the following fields (if other fields are provided then they will also be included.
* samples - number of samples in the image (columns)
* lines - number of lines in the image (rows)
* bands - number of bands in the image. If all 3 dimensions are provided than info.size will be created holding [info.lines info.samples info.bands]
* data_type - data type of the image stored as an integer in 1-15 range. If provided than info.format will be created holding string with Matlab's type name.
* interleave - file band interleave type; either bip, bsq, or bil are possible
* byte_order - byte order (0 is little endian [least significant byte first], 1 is big endian [most significant byte first]). If provided than info.machine will be created holding either 'ieee-le' or 'ieee-be' string.

Example 1:
>> info = read_envihdr('my_envi_image.hdr')
info =
description: [1x101 char]
samples: 658
lines: 749
bands: 3
size: [749 658 3]
header_offset: 0
file_type: 'ENVI Standard'
data_type: 4
format : 'single'
interleave: 'bsq'
sensor_type: 'Unknown'
byte_order: 0
map_info: [1x1 struct]
projection_info: [1x102 char]
wavelength_units: 'Unknown'
pixel_size: [1x1 struct]
band_names: [1x154 char]
Example 2:
>> info = read_envihdr('my_envi_image.hsi');
>> Z = multibandread('my_envi_image.hsi', info.size, [info.format '=>double'], info.header_offset, info.interleave, info.machine);

Comments and Ratings (3)

Sean Kennedy

Works very well for me. Thank you for publishing this!

At last one ENVI reader which is working!

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.


Learn About Live Editor