Hauptinhalt

enviinfo

R2026b

Read metadata from ENVI header file

Description

Add-On Required: This feature requires the Hyperspectral Imaging Library for Image Processing Toolbox add-on.

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

Note

The Hyperspectral Imaging Library for Image Processing Toolbox™ requires desktop MATLAB®, as MATLAB Online™ and MATLAB Mobile™ do not support the library.

example

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 = imhypercube(info.Filename)
hcube = 
  hypercube with properties:

     ImageDims: "[610x340x103 double]"
    Wavelength: [103×1 double]
      Metadata: [1×1 struct]
     BlockSize: [610 340]

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.

You can import valid data from URLs and remote locations, such as cloud services, for easier collaboration and data management. Depending on the location of your file, file can take one of these forms.

Location

Form

Current folder or folder on the MATLAB path

Specify the name of the file in file.

Example: "enviFileHeader.hdr"

File in a folder

If the file is not in the current folder or in a folder on the MATLAB path, then specify the full or relative path name.

Example: "C:\myFolder\enviFileHeader.hdr"

Example: "\imgDir\enviFileHeader.hdr"

Uniform resource locator (URL)

If you specify the file as an internet URL, then file must contain the protocol type, such as http://.

Example: "http://my_hostname/my_path/enviFileHeader.hdr"

Remote location

If the file is stored at a remote location, then file must contain the full path of the file specified as a URL of the form:

scheme_name://path_to_file/my_file.ext

Based on the remote location, scheme_name can be one of the values in this table.

Remote Locationscheme_name
Amazon S3™s3
Windows Azure® Blob Storagewasb, wasbs
HDFS™hdfs

For more information, see Work with Remote Data.

Example: "s3://my_bucket/my_path/enviFileHeader.hdr"

The function downloads each new remote file only once per session to a temporary directory. If you access the same remote data again during the same MATLAB session, the function uses the downloaded file from the temporary directory.

Data Types: char | string

Output Arguments

collapse all

Information about ENVI data and metadata from the header file, returned as a structure array. If the header file contains any of these fields, they must be in the specified format.

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"

  • "int8"

  • "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.

Version History

Introduced in R2020a

expand all