Main Content

enviinfo

Read metadata from ENVI header file

Description

example

info = enviinfo(file) reads the metadata from ENVI (Environment for Visualizing Images) header file.

Note

This function requires the Image Processing Toolbox™ Hyperspectral Imaging Library. You can install the Image Processing Toolbox Hyperspectral Imaging Library from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Read an ENVI header file into the workspace.

info = enviinfo('paviaU.hdr');

Create a hypercube object using the Filename of the ENVI header file.

hcube = hypercube(info.Filename)
hcube = 
  hypercube with properties:

      DataCube: [610×340×103 double]
    Wavelength: [103×1 double]
      Metadata: [1×1 struct]

Read an ENVI header file into the workspace.

info = enviinfo('indian_pines');

Read from the ENVI binary data file by using the metadata from the ENVI header file.

data = multibandread('indian_pines.dat',...
    [info.Height info.Width info.Bands],...
    info.DataType,info.HeaderOffset,info.Interleave,info.ByteOrder);

Input Arguments

collapse all

Name of ENVI header file, specified as a string scalar or character vector. An ENVI header file must have the extension .hdr. If you do not specify a file extension, then the function looks for a file with the specified name and the .hdr file extension.

Data Types: char | string

Output Arguments

collapse all

Information about ENVI data and metadata, returned as a structure array containing at least these fields. If the ENVI header file contains additional fields, then the structure array contains those additional fields as well.

FieldDescription
HeightHeight of the image or number of rows in the image, returned as a positive integer.
WidthWidth of the image or number of columns in the image, returned as a positive integer.
BandsNumber of spectral bands, returned as a positive integer.
DataType

Data type of data in the ENVI file, returned as any of these values:

  • "single"

  • "double"

  • "uint8"

  • "uint16"

  • "int16"

  • "uint32"

  • "int32"

  • "uint64"

  • "int64"

Interleave

Data interleave, returned as any one of these values:

  • "bsq" — Band-sequential

  • "bil" — Band-interleaved-by-line

  • "bip" — Band-interleaved-by-pixel

HeaderOffsetZero-based location of the first element in the image file, returned as a positive integer. The header offset represents the number of bytes from the beginning of the image file to the start of the image data.
ByteOrderEndianness of the data, returned as the string "ieee-le" for little endian or "ieee-be" for big endian.

Introduced in R2020a