Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in the MSAM #64

Closed
Pruthvi3796 opened this issue Apr 11, 2017 · 6 comments
Closed

Problem in the MSAM #64

Pruthvi3796 opened this issue Apr 11, 2017 · 6 comments

Comments

@Pruthvi3796
Copy link

I am want to do the msam like below.

from spectral import *
import gdal
d=ev.load_ENVI_spec_lib("D:\data\speclib.hdr")
img=gdal.Open("D:\data\sub_66")
M=img.ReadAsArray()
M=np.swapaxes(M,0,2)
n1=d[0]
n2=d[1]
n1=np.transpose(n1)
n1=n1[:425]
wavelength=n2['wavelength']
wavelength=np.float64(wavelength)
class1=msam(M,n1)

But it gives error:
AssertionError: Matrix dimensions are not aligned.
where M=>(210 row,275 column,425 band) shape and n1=(425 bandreflectance,16 spectra)

@Pruthvi3796
Copy link
Author

Also clear that the classification through msam is possible?How?

@tboggs
Copy link
Member

tboggs commented Apr 13, 2017

The last dimension of M and n1 must be the same but they are not in your case. The data arg should have shape (n_rows, n_cols, n_bands) and members should have shape (n_spectra, n_bands).

@Pruthvi3796
Copy link
Author

Pruthvi3796 commented Apr 14, 2017

Thanks for reply.I corrected it.But how to do classification using msam?Please Provide example if possible.

@tboggs
Copy link
Member

tboggs commented Apr 14, 2017

SAM and MSAM do not do classification. They perform spectral unmixing. The returned array indicates the fractional abundance of each endmember for each pixel in the data argument.

@Pruthvi3796
Copy link
Author

Pruthvi3796 commented Apr 15, 2017 via email

@tboggs
Copy link
Member

tboggs commented Apr 15, 2017

That's for organizational purposes. Those two algorithms don't select a class. They give an estimate of how much of each class is present in a pixel. If you really want to use them for classification, you can pick the class with the highest abundance or use the abundance vectors in a subsequent classifier.

@tboggs tboggs closed this as completed Apr 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants