Main Content

enviwrite

Write hyperspectral data to ENVI file format

Since R2020a

Description

example

enviwrite(hcube,filename) writes the hyperspectral data stored in the hypercube object to an ENVI (Environment for Visualizing Images) file format. The function creates an ENVI header file and ENVI binary data file with file extensions .hdr and .dat, respectively. The function writes the wavelength and metadata information to the ENVI header file and the data cube containing the hyperspectral images to the ENVI binary data file.

enviwrite(___,Name,Value) specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax.

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.

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

Examples

collapse all

Read a hyperspectral data into the workspace.

hcube = hypercube('paviaU.hdr');

Extract the twenty most informative bands from the hyperspectral data.

sig = fippi(hcube,5);
newhcube = selectBands(hcube,sig,'NumberOfBands',20);

Write the selected hyperspectral data to the ENVI file format. The binary data file is named newData.dat and the header file is named newData.hdr.

enviwrite(newhcube,'newData');

Input Arguments

collapse all

Input hyperspectral data, specified as a hypercube object. The hypercube object contains the data cube, wavelength, and related metadata information.

Name of the ENVI files, specified as a character vector or string scalar. The function uses the specified value as the name of both the binary data file (.dat) and header file (.hdr).

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: enviwrite(hcube,filename,'Interleave','bip')

Band interleaving method, specified as the comma-separated pair consisting of 'Interleave' and one of these values:

  • 'bsq' — The function uses the band-sequential interleaving method. It writes the entirety of each band before writing the next band. This is the default method.

  • 'bil' — The function uses the band-interleaved-by-line interleaving method. It writes an entire row from each band before writing the next row.

  • 'bip' — The function uses the band-interleaved-by-pixel interleaving method. It writes a pixel from each band before writing the next pixel.

Illustration for Band interleaving

Data Types: char | string

Data type to write to the ENVI binary data file, specified as the comma-separated pair consisting of 'DataType' and a valid data type.

Data Types: char | string

Endianness of binary data file, specified as the comma-separated pair consisting of 'ByteOrder' and 'ieee-le' or 'ieee-be'. Specify the value as 'ieee-le' for little-endian format and 'ieee-be' for big-endian format. By default, the function uses endianness format of your machine.

Data Types: char | string

Number of bytes before the data starts, specified as the comma-separated pair consisting of 'HeaderOffset' and a positive integer. If the header file does not exist, the function writes ASCII null values will be written to fill the space by default.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Version History

Introduced in R2020a