>  Docs Center  >  ENVI API  >  ENVICalculateRasterThresholdTask
ENVI

ENVICalculateRasterThresholdTask

ENVICalculateRasterThresholdTask

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 ENVIBinaryGTThresholdRasterTask or ENVIBinaryLTThresholdRasterTask 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 ENVIBinaryAutomaticThresholdRasterTask.

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 properties (Set, Get): INPUT_RASTER, METHOD

Output properties (Get only): THRESHOLD

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 the raster to threshold.

METHOD (optional)

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

  • Isodata: This method works iteratively by calculating an initial threshold that is half the dynamic range of the image or layer, effectively dividing the image into "foreground" (above the initial threshold) and "background" (below the initial threshold) pixels. Next, the algorithm separately calculates the sample mean of the foreground and background pixels, using these new sample means to calculate a new threshold value (the average of the sample means). The process repeats using each new, successive threshold value until the resulting threshold value ceases to change (Ridler and Calvard, 1978).
  • Mean: This method takes the mean value of the gray levels as the threshold (Glasbey, 1993).
  • Maximum Entropy: This method considers the thresholding image as two classes of events, with each class characterized by a Probability Density Function (PDF). It then maximizes the sum of the entropy of the two PDFs to converge on a single threshold value (Kapur, Sahoo, and Wong, 1985).
  • Minimum Error: This method approximates the histogram as a bimodal Gaussian distribution and finds a cutoff point. The cost function is based on the Bayes classification rule (Kittler and Illingworth, 1986).
  • Moments: This method considers the grayscale image as a blurred version of an ideal binary image. This method determines the threshold so that the first three moments of the input image are preserved in the output image (Tsai, 1985).
  • Otsu (default): A histogram shape-based method. It is based on discriminate analysis and uses the zero- and the first-order cumulative moments of the histogram for calculating the value of the thresholding level (Otsu, 1979).

THRESHOLD

The output thresholds (one per band).

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, Service Pack 2

Introduced

API Version


3.3

See Also


ENVITask, ENVITask::Parameter, ENVIBinaryGTThresholdRasterTask, ENVIBinaryLTThresholdRasterTask, ENVIBinaryAutomaticThresholdRasterTask



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us