X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 20 Apr 2019 09:26 AM by  Thomas Van Der Weide
Using ROIs from multiple images in classification
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Thomas Van Der Weide



New Member


Posts:1
New Member


--
15 Apr 2019 04:51 PM
    I'm working with hundreds of images from a time-series capture and have ROIs from multiple images that I would like to compile into a training dataset for SVM classification. The images were all taken with the same sensor at the same time of day, however I'm having trouble figuring out how to use all of the ROIs to train a SVM classifier. Is there a way to do this in ENVI IDL?

    I've tried: outExamples = ENVIExtractExamplesFromRaster(bandStack, rois); but this gets over-written with every new bandStack raster.

    I also tried: StatTask.INPUT_RASTER = raster StatTask.INPUT_ROI = rois StatTask.Execute; but it also gets over-written with every new raster.

    Alternatively, I manually calculated the class statistics (min, std., mean, max) from all the images. Is there a way to enter this data manually into a structure that can be used in the classifier? I've also tried to find a way to use an ASCII ROI statistics file in the classifier to no avail. How can ROIs from multiple images be used to train a classifier?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    16 Apr 2019 10:05 AM
    I don't think it works out of the box using the ExtractExamplesFromRaster task. ExtractExamplesFromRaster can only process one raster and its associated ROIs.

    You may be able to combine your samples through some additional IDL code. If you want to give it a try, here is the pseudo code:

    1) For each raster and its associated ROIs, use ExtractExamplesFromRaster to exact examples.

    2) Get properties from all examples and merge them. The properties are EXAMPLES, CLASS_VALUES, CLASS_NAMES and ATTRIBUTE_NAMES. When merging, make sure that the CLASS_NAMES and ATTRIBUTE_NAMES from all examples are the same. If not, more code logic is required for merging.

    3) Create a single new examples object using the merged values:
    properties = Dictionary()
    properties['EXAMPLES'] = myExamples
    properties['CLASS_VALUES'] = myClassValues
    properties['CLASS_NAMES'] = myClassNames
    properties['ATTRIBUTE_NAMES'] = myAttributeNames
    properties['DESCRIPTION'] = myDescription

    4) Shuffle and split the examples

    5) Define and train the classifier

    Thomas Van Der Weide



    New Member


    Posts:1
    New Member


    --
    20 Apr 2019 09:26 AM
    Thank you for the detailed reply, but I'm still having trouble getting the code to work. First, I noticed the ExtractExamplesFromRaster variable also has a ['DESCRIPTION'] key, should this be included?

    For step 2 when you say to merge the examples, you mean to concatenate the arrays right? I believe I've correctly implemented the code logic for merging arrays, but even when I try to write a dictionary to use in the classifier with a single image I cannot get the Keys correct.

     
    Returns the error
    % Keys must be valid IDL variable names.

    It's confusing that
    [CODE] properties.HASKEY() properties.keys()

    returns an error in the script so it won't compile, but when used in the console: properties.keys() returns 5 lines with the "keys". How do I fix the % Keys must be valid IDL variable names error?
    You are not authorized to post a reply.