X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Jan 2017 02:56 AM by  anon
SVM Classification: ROI selection
 10 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
10 Jan 2017 02:56 AM
    Hello i am trying to execute a SVM classification using the ENVI_SVM_DOIT function. ENVI_SVM_DOIT needs ROI_IDS. Cheecking in the help i found that ENVI_GET_ROI_IDS allows to obtain the ROI_IDS. ENVI_GET_ROI_IDS needs the FID (the file ID). I suppose the ID of the ROI.xml file used for the classification. But i did not found any way to obtain a file ID from a roi.xml file. Any suggestion? Thank you for your feedback.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    10 Jan 2017 05:37 AM
    The FID is for the image file that you are trying to classify. There are no FIDs for ROIs. You can use ENVI_RESTORE_ROIS to open your ROI file but I believe you will need to pass a classic ROI file rather than a new ROI xml file.

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Jan 2017 06:03 AM
    So, using the FID of the file i need to classify, it works correctly? thank you

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Jan 2017 09:05 AM
    This is my code: pro idl_svmClassification COMPILE_OPT IDL2 e = ENVI(/HEADLESS) output_svm=output_class_file output_svmrule=output_class_rule root_path = mydir inputms = my_ms_file msi_file = Filepath(inputsms, ROOT_DIR=root_path) msi_raster = e.OpenRaster(msi_file) R_FID = ENVIRasterToFID(msi_raster) ENVI_FILE_QUERY, R_FID, DIMS=dims File_ROI = Filepath('RoiSetClass_v2.xml', Root_Dir = roifile_directory) FileROI = e.OpenRoi(File_ROI) ROIids = ENVI_GET_ROI_IDS(FID=R_FID) ENVI_DOIT, 'ENVI_SVM_DOIT', $ DIMS = dims, FID = R_FID, KERNEL_TYPE = 2, KERNEL_GAMMA = 0.2, $ OUT_NAME=output_svm, ROI_IDS = ROIids, RULE_OUT_NAME = output_svmrule end When i ask to print ROIids i obtain -1. I do not understand how use the ENVI_GET_ROI_IDS in my example. Thank you for any suggestion.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    10 Jan 2017 11:28 AM
    I do not think you can pass or get ROI IDs from an XML ROI. You would first need to convert the XML ROI to a Classic ROI to pass to the ENVI_SVM_DOIT, which is a classic routine. You could use ENVIRaster::ExportROIs.

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Jan 2017 02:15 AM
    I tryed with roi.roi file, but it did not work. The explanation of ENVI_GET_ROI_IDS specifies that: ROI_NAMES (optional) Use this keyword to specify a named variable that contains a string array of ROI names for each ROI ID. The default name includes the ROI name, ROI color, and number of points. Set the keyword SHORT_NAME or LONG_NAME to modify the default ROI_NAMES. So, i added the definition of a roi_names variable. I tried with both string array definition below: roi_names=[['Vegetation1'], ['Vegetation2'], ['Water'], ['Ground1'], ['Sand1'], ['Sand2'], ['Built1'], ['Built2'], ['Built3'], ['NaN'], ['Ground2'], ['Ground3']] roi_names=['Vegetation1', 'Vegetation2', 'Water', 'Ground1', 'Sand1', 'Sand2', 'Built1', 'Built2', 'Built3', 'NaN', 'Ground2', 'Ground3'] using this ENVI_GET_ROI_IDS code: ROIids = ENVI_GET_ROI_IDS(FID=R_FID, ROI_NAMES=roi_names, /SHORT_NAME) but it still not working. I did a "print, ROI_IDS" before the ENVI_SVM_DOIT linecode and it still response -1. I do not have any more solutions.

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Jan 2017 04:45 AM
    Finally my code works: COMPILE_OPT IDL2 envi msi_file = Filepath(inputRasterPath, ROOT_DIR=root_path) envi_open_file, filename, R_FID=foo, /INVISIBLE, /NO_REALIZE ENVI_FILE_QUERY, foo, DIMS=dims envi_restore_rois, 'myfileroi.roi' roi_ids = envi_get_roi_ids(fid=foo) ENVI_DOIT, 'ENVI_SVM_DOIT', $ DIMS = dims, FID = foo, KERNEL_TYPE = 2, KERNEL_GAMMA = 0.2, $ OUT_NAME=output_svm, ROI_IDS = roi_ids, POS=[0,1,2,3,4,5], RULE_FID=20, RULE_OUT_NAME = output_svmrule Thank you for your help. I have un other question about Roi statistics management: I need to calculate the mean of raster DN values included inside each features of a ROI, and if the DN mean is less then a value i need to delete the corresponding feature. Any suggestion about this problem?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    11 Jan 2017 01:50 PM
    Can you restore your classic ROI file in ENVI Classic? Perhaps it is not being converted correctly from ENVI. Did you use the ENVI ROI tool to Export to Classic ROI?

    Deleted User



    New Member


    Posts:
    New Member


    --
    12 Jan 2017 01:45 AM
    I have to to do this in batch mode

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    12 Jan 2017 05:55 AM
    It is only to test if your ROIs are valid and can be viewed on the image.

    Deleted User



    New Member


    Posts:
    New Member


    --
    12 Jan 2017 06:04 AM
    My ROIs are valid
    You are not authorized to post a reply.