1

I am trying to classify the hyperspectral image using the spectral angle mapper classifier.for that i did like below.

from spectral import *
import gdal
d=ev.load_ENVI_spec_lib("D:\data\speclib.hdr")
img=gdal.Open("E:\data\subset74559_1maize")
img1=envi.open("E:\data\subset74559_1maize.hdr")
band1= img1.bands.centers
band1=np.array(band1)
band1=np.floor(band1)
b1=band1[0:194]
b2=band1[212:280]
b3=band1[316:425]
band1=np.hstack((b1,b2,b3))
M=img.ReadAsArray()
n1=d[1]
n2=d[0]
nt=np.transpose(n2)
wl=n1['wavelength']
wl=np.float64(wl)
wel=[i for i,item in enumerate(wl) if item in band1]
n2=nt[wel]
n2=np.transpose(n2)
M1=M[0:194,:,:]
M2=M[212:280,:,:]
M3=M[316:425,:,:]
M=np.vstack((M1,M2,M3))
M=np.moveaxis(M,0,2)
#spectral_angle is imported from spectral package.
**cla=spectral_angles(M,n2)
clmap=np.argmin(cla,2)
classes=(clmap+1)
v=spy.imshow(classes=(clmap+1))**

But it gives misclassified image means it classified entire image in given end member spectra even if it the end member spectra is not present.Means it does not show unclassified parts.Also i don't know how to set threshold.

  • @Ibrahim-Please give me solution if you have an idea. – Earth Patel Apr 22 '17 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.