ctherien / pysptools

Hyperspectral library for Python
Apache License 2.0
50 stars 21 forks source link

Using mask with end member extraction algorithm returns wrong index? #5

Open dennisai opened 6 years ago

dennisai commented 6 years ago

If I use a mask for the end member extraction algorithm (e.g. FIPPI), then it calls the compress method on the HSI cube. I've pasted the source code below.

def _compress(vec, mask):
    n = np.sum(mask)
    cmp = np.ndarray((n, vec.shape[1]), dtype=np.float)
    i = 0
    for j in range(mask.shape[0]):
        if mask[j] == 1:
            cmp[i] = vec[j]
            i += 1
    return cmp

Then if we get the indexes of the endmembers later on, won't be computing the wrong indexes, since the index i will pertain to the compressed array (see code below)?

self.E, self.idx = eea.FIPPI(cM, q=q, maxit=maxit)
self.idx3D = [(i % self.w, i // self.w) for i in self.idx]
ninsbl commented 6 years ago

Same problem here with NFINDR. As a workaround I fetch the indices like this:

E = nfindr.extract(img, endmember_n, maxit=5, normalize=False, ATGP_init=True, mask=mask)
idx = [np.where((img[:,:]==e).all(-1)) for e in E]
ctherien commented 6 years ago

I take note. Thanks

2018-02-01 9:27 GMT-05:00 Stefan Blumentrath notifications@github.com:

Same problem here with NFINDR. As a workaround I fetch the indices like this:

E = nfindr.extract(img, endmember_n, maxit=5, normalize=False, ATGP_init=True, mask=mask) idx = [np.where((img[:,:]==e).all(-1)) for e in E]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ctherien/pysptools/issues/5#issuecomment-362281498, or mute the thread https://github.com/notifications/unsubscribe-auth/AQILNakEzyG2oeck0EU-IhvZIxZ3Hc0Xks5tQcnAgaJpZM4RN9bc .