X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 May 2019 05:31 AM by  MariM
How compute class stats over a ROI
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
07 Feb 2017 09:08 AM
    Hi all, I am trying to compute the classes statistics of a classification maps obtained from a masked raster. The masked pixels are No Data. I am interested to compute the percentage of surface classified by each class. The class stats provide a percentage with respect on the total area of the raster, but i need the statistic value only for the not masked area. Here below a briefly description of workflow in ENVI 5.4: Right click on a class Select Compute Class stats Select the masked raster Execute the command Output: a percentage of cover respect the total area of the raster I also tryed to select the masked raster and then use the spatial subsetting tool, selecting the roi (both into xml and ESRI shp formats) used to generate the mask. The dimentions of the subsetted raster did not change. Any suggestion?

    Deleted User



    New Member


    Posts:59
    New Member


    --
    08 Feb 2017 09:34 AM
    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.

    Deleted User



    New Member


    Posts:
    New Member


    --
    09 Feb 2017 04:01 AM
    Thank you. i am using ENVI API so i am going to apply the IDL-based solution. Can i suggest an implementation of an ENVITASK to compute statistics on a particolar ROI? This problem is common (Area of interest, raster with cloud mask, water mask, vegetation mask, unclassified mask, and so on). Best regard, Lorenzo

    Deleted User



    New Member


    Posts:59
    New Member


    --
    09 Feb 2017 07:30 AM
    Good suggestion to have an ENVITask for this purpose. Actually, the next release of ENVI will have a new ROI keyword to the ENVIRaster::GetData method that allows you to extract data and statistics for ROIs.

    Marta Yebra



    New Member


    Posts:1
    New Member


    --
    15 May 2019 08:25 PM
    I guess you refer to ROIStatistics? Can I know which ENVI version has that task included? I am using ENVI 5.3 and I cannot find that task in the catalog of ENVITask

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    16 May 2019 05:31 AM
    You are not authorized to post a reply.