This task creates a new raster where values above a specified threshold are set to 1 and all other values are set to 0. The task uses a predefined thresholding method to create the binary image. Thresholds are calculated for each band in the source raster. Image thresholding is typically done to separate "object" or foreground pixels from background pixels to aid in image processing.
This task automatically runs the following tasks:
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.
Example
e = ENVI()
File = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
Task = ENVITask('BinaryAutomaticThresholdRaster')
Task.INPUT_RASTER = Raster
Task.METHOD = 'Minimum Error'
Task.Execute
e.Data.Add, Task.OUTPUT_RASTER
View = e.GetView()
Layer = View.CreateLayer(Task.OUTPUT_RASTER)
Syntax
Result = ENVITask('BinaryAutomaticThresholdRaster')
Input parameters (Set, Get): INPUT_RASTER, INVERSE, METHOD, OUTPUT_RASTER_URI
Output parameters (Get only): OUTPUT_RASTER
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.
INVERSE (optional)
The default value for this parameter is false, which means that values above the computed threshold are set to 1 and all other values are set to 0. Set this parameter to true to invert the binary values.
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).
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 parameter, or set it to an exclamation symbol (!), ENVI creates a temporary file.
- If you set it to the hash symbol (#), ENVI creates a file in the temporary directory, but this file will not be deleted when ENVI closes.
Output Parameters
OUTPUT_RASTER
This is a reference to the output raster of filetype ENVI.
Methods
Execute
Parameter
ParameterNames
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
Version History
See Also
ENVITask, CalculateRasterThreshold Task, BinaryGTThresholdRaster Task, BinaryLTThresholdRaster Task, DataValuesMaskRaster Task, MaskRaster Task, ROIMaskRaster Task, VectorMaskRaster Task, Masking Support in ENVITasks