This is a great question. I'm not sure if you are doing this in the ENVI application or with the API, but I can give some suggestions either way. If you are using the API, you can use the ENVIROI::PixelCount method to determine the total number of pixels inside the entire ROI that makes up your area of interest. Then determine the number of pixels inside each class, and divide by the total # of pixels to get the percentage for each class.
Another option is to create an array of the class statistics reported with respect to the total area of the raster, for example:
IDL> classStats = [5.987, 1.425, 2.408, 4.472]
Then use the following code to calculate the statistics with respect to the masked area only:
IDL> classStatsMasked = 100D / TOTAL(classStats, /double) * classStats
IDL> Print, classStatsMasked
Result:
18.736, 4.46, 7.53, 14.00
If you are using the ENVI application (as you outlined earlier, by right-clicking on each class and computing statistics), the statistics dialog reports the number of background or "unclassified" pixels, which should correspond to your masked pixels, for example:
Class Summary Pixel Count Percent
__________________________________
Unclassified 100000 68
Class 1 6000 13
Class 2 3000 7
Class 3....etc.
Subtract the "unclassified" or "background pixel" count from the total number of pixels in the entire raster. This will give you the number of pixels inside your ROI. Then divide the number of pixels in each class by this amount to get the percentage for each class.
I hope this helps.
|