This task separates an image into regions, which are groups of contiguous pixels that share the same value. It consecutively labels all of the regions with a unique index. This task typically accepts classification images or binary masks as input.
The following diagram shows how distinct regions (with a pixel value of 1) are assigned different labels. The colors are meant for illustration only, to show the different labels assigned to each region.
Example
This example identifies water pixels in a multispectral image and labels each region separately. It uses a color slice classification to color the individual regions.
e = ENVI()
File = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
SubsetTask = ENVITask('SubsetRaster')
SubsetTask.INPUT_RASTER = Raster
SubsetTask.SUB_RECT = [256,253,1023,941]
SubsetTask.Execute
MathTask = ENVITask('PixelwiseBandMathRaster')
MathTask.INPUT_RASTER = SubsetTask.OUTPUT_RASTER
MathTask.EXPRESSION = 'b3 le 180'
MathTask.Execute
FilterTask = ENVITask('BinaryMorphologicalFilter')
FilterTask.INPUT_RASTER = MathTask.OUTPUT_RASTER
FilterTask.METHOD = 'Open'
FilterTask.KERNEL = [[!true,!true,!true], $
[!true,!true,!true], [!true,!true,!true]]
FilterTask.ITERATIONS = 1
FilterTask.Execute
LabelTask = ENVITask('LabelRegions')
LabelTask.INPUT_RASTER = FilterTask.OUTPUT_RASTER
LabelTask.Execute
ColorTask = ENVITask('ColorSliceClassification')
ColorTask.INPUT_RASTER = LabelTask.OUTPUT_RASTER
ColorTask.Execute
DataColl = e.Data
DataColl.Add, ColorTask.OUTPUT_RASTER
View = e.GetView()
Layer = View.CreateLayer(ColorTask.OUTPUT_RASTER)
Syntax
Result = ENVITask('LabelRegions')
Input properties (Set, Get): INPUT_RASTER, OUTPUT_RASTER_URI
Output properties (Get only): OUTPUT_RASTER
Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.
Methods
This task inherits the following methods from ENVITask:
AddParameter
Execute
Parameter
ParameterNames
RemoveParameter
Properties
This task inherits the following properties from ENVITask:
COMMUTE_ON_DOWNSAMPLE
COMMUTE_ON_SUBSET
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
This task also contains the following properties:
INPUT_RASTER (required)
Specify a single-band raster.
OUTPUT_RASTER
This is a reference to the output raster of filetype ENVI.
OUTPUT_RASTER_URI (optional)
Specify a string with the fully qualified filename and path of the associated OUTPUT_RASTER. If you do not specify this property, the associated OUTPUT_RASTER will not be created. To force the creation of a temporary file set the property to an exclamation symbol (!).
Version History
API Version
4.3
See Also
ENVITask