CalculateRasterThreshold Task

This task calculates a threshold value for each band in a raster. Image thresholding provides a way to create a binary image from a grayscale or multi-band image. This is typically done to separate "object" or foreground pixels from background pixels to aid in image processing.

The threshold calculated from this task can be passed to the BinaryGTThresholdRaster or BinaryLTThresholdRaster tasks in order to create a binary image. The binary image indicates whether each pixel was below or above the calculated threshold value.

To perform all of these steps in one task, use the BinaryAutomaticThresholdRaster task.

Example

; Start the application

e = ENVI()

 

; Open an input file

File = Filepath('qb_boulder_msi', Subdir=['data'], $

  Root_Dir=e.Root_Dir)

Raster = e.OpenRaster(File)


; Get the task from the catalog of ENVITasks

Task = ENVITask('CalculateRasterThreshold')

 

; Define inputs

Task.INPUT_RASTER = Raster

 

; Run the task

Task.Execute

 

; Print the threshold value

Print, Task.THRESHOLD

 

; Create a binary image based on the calculated threshold

BinaryGTTask = ENVITask('BinaryGTThresholdRaster')

BinaryGTTask.INPUT_RASTER = Raster

BinaryGTTask.THRESHOLD = Task.THRESHOLD

BinaryGTTask.Execute

 

; Add the output to the Data Manager

e.Data.Add, BinaryGTTask.OUTPUT_RASTER

 

; Display the result

View = e.GetView()

Layer = View.CreateLayer(BinaryGTTask.OUTPUT_RASTER)

Syntax

Result = ENVITask('CalculateRasterThreshold')

Input parameters (Set, Get): INPUT_RASTER, METHOD

Output parameters (Get only): THRESHOLD

Parameters marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Parameters marked as "Get" are those whose values you can retrieve but not set.

Input Parameters

INPUT_RASTER (required)

Specify the raster to threshold.

METHOD (optional)

Specify one of the following strings indicating the method used to calculate the threshold.

Output Parameters

THRESHOLD

The output thresholds (one per band).

Methods

Execute

Parameter

ParameterNames

Properties

DESCRIPTION

DISPLAY_NAME

NAME

REVISION

TAGS

References:

Glasbey, C. "An Analysis of Histogram-Based Thresholding Algorithms." CVGIP: Graphical Models and Image Processing 55 (1993): 532-537.

Kapur, J., P. Sahoo, and A. Wong. "A New Method for Gray-Level Picture Thresholding Using the Entropy of the Histogram." Graphical Models and Image Processing 29, No. 3 (1985): 273-285.

Kittler, J., and J. Illingworth. "Minimum Error Thresholding." Pattern Recognition 19 (1986): 41-47.

Otsu, N. "A Threshold Selection Method from Gray-Level Histograms." IEEE Transactions on Systems, Man and Cybernetics 9 (1979): 62–66.

Ridler, T., and S. Calvard. "Picture Thresholding Using an Iterative Selection Method." IEEE Transactions on Systems, Man and Cybernetics 8 (1978): 630 - 632.

Tsai, W. "Moment-Preserving Thresholding: a New Approach." Computer Vision, Graphics, and Image Processing 29 (1985): 377-393.

Version History

ENVI 5.5.2

Introduced

See Also

ENVITask, BinaryGTThresholdRaster Task, BinaryLTThresholdRaster Task, BinaryAutomaticThresholdRaster Task, Masking Support in ENVITasks