X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 19 Dec 2017 05:57 AM by  MariM
Having trouble getting signatures from a .sli to use with ENVISpectralAngleMapper
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Stefan



New Member


Posts:2
New Member


--
14 Dec 2017 03:13 AM
    Hi,
    I want to use ENVISpectralAngleMapperClassification to classify as set of files using my own spectral library ("library.sli").
    However, ENVISAM requires training data as a Task.MEAN-array. I am having trouble constructing this array from the files in my library.

    I am using ENVIGetSpectrumFromLibrary and I can select the entries I want (signatures = [0,1,2]) and then loop:

    list = LIST()

    for i=0, signatures.LENGTH-1l do begin
    LibTask.spectrum_name=speclib.SPECTRA_NAMES[i]
    LibTask.Execute
    list.add,MEAN(LibTask.spectrum)
    print, 'Added ', speclib.SPECTRA_NAMES[i],' to output array'
    endfor

    mean_list = liste.toarray(dimension=1)

    SAM.MEAN = mean_list

    My questions:
    1) I get this error: Operands of matrix multiply have incompatible dimensions: TMEAN, <FLOAT Array[105, 4]>.
    I have 105 bands and data type = 4.

    2) I also tried specifying class names, and then I got an error saying it "requires the same number of classes". I had three signatures (CLASS_NAMES) and three MEAN-entries in my array.



    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    15 Dec 2017 10:45 AM
    The mean needs to be an array in the format of nbands (of the input file) x nclasses (the spectra you pass to it). Also the spectra will need to be resampled to match that of the image. You can use the following task for that:
    http://www.harrisgeospati...plespectrumtask.html

    You don't need to calculate the mean of a spectrum since each data point in a spectrum is the 'mean' for each wavelength, assuming you only have one spectrum for each input class. If you had a group of pixels (ROI or vector), then you would need to calculate the mean on those pixels, which would be the mean spectrum for that class.

    Stefan



    New Member


    Posts:2
    New Member


    --
    18 Dec 2017 12:53 AM
    Thank you for your reply!
    The spectral library is actually extracted from the same file, so they have the same number of bands, and they are, as you point out, already averaged in the .sli-file.

    How can I construct the array properly? What do I have to feed it? I have fed my spectras to a list and converted it to an array, as you see in the first post.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    18 Dec 2017 05:54 AM
    In you initial post you say you have 105 bands and 3 classes (105 element spectra) you want to use to classify. Your array should be 105x3. It looks like you are using MEAN on the extracted spectra here:
    list.add,MEAN(LibTask.spectrum)
    but the spectrum itself is the mean for reach band. So you simply need to extract from your spectral library into a list, or array of 105x3.
    What is the result of printing the 'MEAN_list'?

    Stefan



    New Member


    Posts:2
    New Member


    --
    19 Dec 2017 01:52 AM
    I fixed it!

    I had to TRANSPOSE(mean_list), and now everything is working.

    I also removed, as you pointed out, the MEAN-function from the list.

    Thank you for your help!

    Do you know if there is a normalizing / continuum removal function in IDL?

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    19 Dec 2017 05:57 AM
    You are not authorized to post a reply.