It is often helpful to generate a random sampling of points from a classification result, or from ROIs. Such samplings can be valuable in supporting classification accuracy assessments and field truthing expeditions.

ENVI offers three types of random samplings:

  • Stratified Random: This technique, also called proportional or quota random sampling, involves dividing the population (the entire classification image or all of the ROIs) into homogeneous subgroups (the individual classes or ROIs) then taking a simple random sample in each subgroup. Two types of Stratified Random sampling are available: proportionate and disproportionate. Proportionate sampling produces sample sizes that are directly related to the size of the classes (that is, the larger the class, the more samples will be drawn from it). Disproportionate sampling allows you to explicitly define each sample size.
  • Equalized Random: This technique also divides the population into homogeneous subgroups (as in Stratified Random) but ensures that each class’s (or ROI’s) sample size is exactly the same. That is, the sample size remains fixed regardless of class size.
  • Random: Random sampling does not divide the population into subgroups but instead draws a random sampling from the entire (heterogeneous) population. For large sample sizes, the distribution of classes (or ROIs) in the sample will approximate a Stratified Random sampling, but classes with small sizes may be missed altogether in the random sample.

Generate Random Sample Routines


  1. From the Toolbox, select Classification > Post Classification > Generate Random Sample Using Ground Truth Image or Using Ground Truth ROIs.
  2. The input file dialog appears.

  3. Select either the Classification Image from which to draw the sample, or (for ROI sampling) the image associated with the ROIs. If sampling from a Classification Image, perform any optional spatial subsetting, then click OK. The class distributions are computed and the Generate Random Sample from Ground Truth dialog appears.

    Note: When sampling from a large Classification Image, it may take several seconds to compute the class distributions, and a status reporting dialog will be displayed.

  4. Select the ground truth classes or ROIs to include in the sampling.
  5. Click OK. The Generate Random Sample Input Parameters dialog appears.
  6. Select the sampling type from the drop-down list. See the following sections for more information.

Proportionate Stratified Random Sampling


  1. Set the Stratification type radio button to proportionate.
  2. Enter the Minimum Sample Size in percent or pixels by clicking the toggle button. Entering a value for one will automatically update the value for the other, making it easy to see the relationship between the percentage sample size and the pixel sample size. The minimum size is one, to ensure that at least one pixel is included from the smallest class (or ROI).
  3. To view the proportionate class sample sizes for the current Minimum Sample Size Setting, click view class sample sizes. The Proportionate Sample Sizes dialog must be closed before the Generate Random Sample Input Parameters dialog becomes active again.

The total sample size displays to the left of the view class sample sizes button and will update dynamically as new settings are entered.

Disproportionate Stratified Random Sampling


  1. Set the Stratification type radio button to disproportionate.
  2. To define the sample sizes, click set class sample sizes. The Disproportionate Sample Sizes dialog appears.
  3. Select a class (or ROI) in the list at the top of the dialog. The class (or ROI) will show up in the field at the bottom left of the dialog under the Edit Sample Size for Selected Class label.
  4. In the white box next to the class (or ROI) name at the bottom right of the dialog, enter a sample size in pixels. To set the sample size to a percent of the total class (or ROI) size, enter the percentage value (for example, 15%) then press Enter. The sample size in pixels will automatically be calculated.
  5. Click OK.

The total sample size displays to the right of the set ROI sample sizes button.

Equalized Random Sampling


Set the Sample Size in pixels. The minimum value is one and the maximum value is equal to the smallest class size (or ROI) in the population.

The total sample size displays beneath the Sample Size parameter and updates automatically when a new sample size is entered.

Random Sampling


  1. Set the Sample Size in pixels or percent by clicking the toggle button. Entering a value for one will automatically update the value for the other, making it easy to see the relationship between the percentage sample size and the pixel sample size.
  2. The total sample size displays beneath the Sample Size parameter and updates automatically when a new sample size is entered.
  3. Select output to a Single ROI or Multiple ROIs.
  4. The output ROIs containing the random samplings will automatically be saved in the ENVI session’s memory. If you also wish to save the ROIs to a file, enter a filename.
  5. Click OK. If producing a Random sampling and some of the classes (or ROIs) are not included in the resulting sample, ENVI displays a warning message.