ENVIBandMaxSubsetRaster::Hydrate

Use the Hydrate static function method to create the object from its dehydrated form. The dehydrated form consists of a hash containing the object’s properties and values. The Hydrate and Dehydrate methods let you store the object state in memory and restore it later.

Representing an object as a hash is necessary for running ENVI analytics with the ENVI Task Engine.

See the ENVIHydrate function if you are creating a general IDL routine that will restore multiple object types.

For additional information, see What are Hydrate and Dehydrate routines used for?

Example

; Start the application

e = ENVI()

 

; Open an input file

File = Filepath('AVIRISReflectanceSubset.dat', $

SUBDIR=['data', 'hyperspectral'], $

ROOT_DIR=e.Root_Dir)

Raster = e.OpenRaster(File)

 

; Define three ROIs, each containing 9 pixels of a common

; material.

nSpectra = 9d

roi1 = EnviRoi(NAME='Green Field')

pixelAddr1 = [[77,182],[78,182],[79,182], $

             [77,183],[78,183],[79,183], $

             [77,184],[78,184],[79,184]]

roi1.AddPixels, pixelAddr1, SPATIALREF=raster.SpatialRef

 

roi2 = EnviRoi(NAME='Soil')

pixelAddr2 = [[386,285],[387,285],[388,285], $

             [386,286],[387,286],[388,286], $

             [386,287],[387,287],[388,287]]

roi2.AddPixels, pixelAddr2, SPATIALREF=raster.SpatialRef

 

roi3 = EnviRoi(NAME='Ground')

pixelAddr3 = [[296,326],[297,326],[298,326], $

             [296,327],[297,327],[298,327], $

             [296,328],[297,328],[298,328]]

roi3.AddPixels, pixelAddr3, SPATIALREF=raster.SpatialRef

 

; Retrieve the spectra from the ROIs and use their mean as

; target and background to the BandMaxSubsetRaster.

spectra1 = raster.GetData(ROI=roi1)

mean1 = Total(spectra1,1) / nSpectra

 

spectra2 = raster.Getdata(ROI=roi2)

mean2 = Total(spectra2,1) / nSpectra

 

spectra3 = raster.GetData(ROI=roi3)

mean3 = Total(spectra3,1) / nSpectra

 

targetSpec = [[mean1], [mean2]]

backgroundSpec = mean3

thresh = 0.387

 

; Create a spectral subset of those bands whose BandMax

; significance values are not less than 0.387.

Subset = ENVIBandMaxSubsetRaster(raster, targetSpec, $

  backgroundSpec, THRESHOLD=thresh)

 

; Retrieve the dehydrated hash

dehydratedForm = Subset.Dehydrate()

Subset.close

 

; Restore the object

newImage = ENVIBandMaxSubsetRaster.Hydrate(dehydratedForm)

Print, newImage, /IMPLIED_PRINT

Syntax

Result = ENVIBandMaxSubsetRaster.Hydrate(DehydratedForm, ERROR=value)

Return Value

The result is a reference to a new object instance of this virtual raster class.

Arguments

DehydratedForm

Key

Description

factory

Required. A string value of SubsetRaster indicating what object type the hash represents.

background

Required. An array that specifies the background spectra. Example:

[[0.0859, 0.0808, 0.0826, 0.0804, 0.0762, 0.0739, 0.0739], [0.1343, 0.1357, 0.1354, 0.1335, 0.1297, 0.1276, 0.1245]]

input_raster

Required. The input ENVIRaster for use in ENVI processing. Example:

"input_raster": {
   "url": "/usr/local/INSTALL_DIR/envi/data/hyperspectral/AVIRISReflectanceSubset.dat",
   "factory": "URLRaster"
}

name

A string that identifies the raster.

number_bands

Optional. The number of significant bands for the BandMax subset raster. If this value and threshold are undefined, BandMax spectrally subsets the raster using the calculated threshold. Example:

56

target

Required. An array that specifies the target spectra. Example:

[[0.3918, 0.3954, 0.3983, 0.4005, 0.4024, 0.4054, 0.4044], [0.2138, 0.2707, 0.2599, 0.2271, 0.2172, 0.2107, 0.2129], [0.1479, 0.1509, 0.1494, 0.1488, 0.1468, 0.1429, 0.1448]]

threshold

Optional. Specify a floating-point value ranging from 0.0 to 1.0. This value represents the threshold for the minimum significance value that determines which bands are in the output raster of this task. The default threshold value is calculated to select 25% of the input bands, but never less than six bands. If this value and number_bands are undefined, the default threshold value is used for output raster. Example:

0.387

Keywords

ERROR

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

Version History

ENVI 6.1

Introduced

See Also

ENVIBandMaxSubsetRaster, ENVIBandMaxSubsetRaster::Dehydrate, ENVIHydratable, ENVIHydrate