Main Content

enviwrite

Write hyperspectral data to ENVI file format

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.

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 Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

Introduced in R2020a