How to combine the statistics of ROIs from different images to use in image classification
Note: These instructions are relevant for ENVI Classic.
ROIs (Regions of Interest) are commonly used to select image pixels that can be used as training data for image classification. ROI's, however, are not actual data but pointers to data in an image. Therefore, they are tied to the spatial locations of the selected pixels defining the ROI. In some instances, a user might want to use the statistics from ROIs collected from different images for training data. For example, if you have only a few pixels selected in one image to represent 'spring wheat' and a few pixels in an image of a different area that also represent 'spring wheat', you might want to combine the statistics of these two ROIs to create a single training data set to use in a classification.
This Help Article describes a methodology of how you could get the proper statistics from two ROIs taken from different images to use in a classification.
In order to combine the statistics from ROIs taken from different images, we will make an 'image' from our ROI pixel values. This will only work if your ROIs from the different images have the same number of spectral bands. (for example, two Landsat images each with 6 bands).
Display one image in a window and overlay its ROI. From the ROI Tools dialog, go to File ->Output ROIs to ASCII. Select the file from which it is associated, and select the ROI. Go to Edit Output ASCII Form... All that needs to be checked are the 'Band Values' since you will not need any of the associated image location information. Output this to an ASCII text file. Do the same for the second image. Now you should have two text files that have the pixel values from their associated ROI and it look similar to this:
; ROI name: Region #1
; ROI rgb value: {255, 0, 0}
; ROI npts: 410
; B1 B2 B3 B4 B5 B6
95 47 47 155 84 32
88 44 41 161 74 25
Now, combine these two text files using a spreadsheet or a text editor. Import each text file so that all you have are the column data:
B1 B2 B3 B4 B5 B6
95 47 47 155 84 32
88 44 41 161 74 25
Then copy and paste the values from one of the text files to the other, so you have nbands number of columns and nrows number of pixels from both text files. Save this as a text file.
Then in ENVI, go to File ->Open External File ->Generic Formats->ASCII. Select the new combined pixel text file. In the Input ASCII File dialog, set the interleave to BIP, the data type to the proper data type of the original images, and number of bands to the same number of bands in your images. Output this file. Now, in ENVI, you should have a 1 sample x npixels line x nbands floating point image. For example, for the Landsat scene the resulting 'image' was 1 x 1212 (number of pixels in my two ROIs) x 6 (number of bands in the Landsat scene).
Now all of the pixels of interest from both ROIs are in a single 'image'. From this, bring up the ROI tool and draw an ROI around all of the pixels in this image (make sure you get all the samples and lines). From this, calculate the statistics from this whole-image ROI. Export the statistics to an ENVI statistics file and use this statistics file to perform the classification. For example:
- From the ROI tool, go to Options ->Calculate Covariance with stats
- Select the Stats button to get the statistics from the ROI. Make sure this contains the covariance matrix for your ROI.
- From the ROI Statistics results go to File ->Save ROI Results to ENVI stats file.
Now the ENVI statistics file contains the calculated statistics and covariance of all the pixels from the two ROIs.
Then go to Spectral ->Mapping Methods->Endmember Collection. Select one of the images to be classified. In the Endmember Collection Dialog, select Algorithm ->. Then select Import ->From Stats File and select the computed statistics file, then select Apply. You are brought to the Maximum Likelihood Parameters dialog. Here, enter the desired parameters and output the result.
Review on 12/31/2013 MM