Create Binary Rasters by Automatic Thresholds
Use the Binary Raster by Automatic Threshold tool to create a binary image using a predefined thresholding method. Thresholds are calculated for each band in the source image. Image thresholding is typically done to separate "object" or foreground pixels from background pixels to aid in image processing.
You can write a script to create binary rasters by automatic thresholds using the BinaryAutomaticThresholdRaster task.
Follow these steps:
- From the Toolbox, select Raster Management > Binary Raster by Automatic Threshold.
- Select a single-band or multi-band Input Raster, and perform optional spatial and/or spectral subsetting.
- Select a thresholding method from the Method drop-down list. The choices are:
- 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).
- The Inverse option is set to No by default, which means that values above the computed threshold are set to 1 and all other values are set to 0. Set this option to Yes to invert the values.
-
To write the output to disk, select the File radio button and specify a filename and location. To produce output in memory only, select the Virtual radio button.
- Enable the Preview check box to preview the settings before processing the data. The preview is calculated only on the area in the view and uses the resolution level at which you are viewing the image. To preview a different area in your image, pan and zoom to the area of interest and re-enable the Preview option. Depending on the algorithm being used by the tool, the preview result might be different from the final result of processing on the full extent, full resolution of the input image in the following scenarios: 1) If you zoomed out of the input raster in the view by 50%, or a percentage less than 50%, ENVI uses a downsampled image at the closest resolution level to calculate the preview, or 2) If the entire image is not visible in the view, ENVI uses the subset in the viewable area of the input image to calculate the preview.
- Enable the Display result check box to display the output in the view when processing is complete. Otherwise, if the check box is disabled, the result can be loaded from the Data Manager.
-
To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow next to the OK button
, select Save Parameter Values, then specify the path and filename to save to. Note that some parameter types, such as rasters, vectors, and ROIs, will not be saved with the file. To apply the saved task settings, click the down arrow and select Restore Parameter Values, then select the file where you previously saved your settings.
-
You can run the process in the background on your computer or in the background on an ENVI Server (if available). Click the down arrow
next to the OK button and select one of the following:
- Run Task in the Background: Runs the process on your computer. This method does not use an ENVI Server. The job progress will show in the ENVI Job Console's Background Jobs tab.
- Run Task on envi_server_name. Runs the process on the selected ENVI Server. The job progress will show in the ENVI Job Console's envi_server_name tab.
See ENVI Job Console for details on monitoring ENVI Server jobs and viewing results. See ENVI Servers for details on configuring and using an ENVI Server.
- Click OK.
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.