spectralpython / spectral

Python module for hyperspectral image processing
MIT License
571 stars 139 forks source link

Add filter method to SpectralLibrary class #98

Open tboggs opened 4 years ago

tboggs commented 4 years ago

Spectral libraries may have more bands than actually needed or may have bands in a non-monotonic order. This issue is to add a filter method to the SpectralLibrary to enable things like:

kormang commented 4 years ago

I think function like that could be generally useful. Maybe make general purpose functions and call them from spectral library? I would like to help. For start with first point, selecting a subset of bands from library. But would like to know, what exactly did you have in mind? What should this function accept as arguments? What should in return? What side effects should it have inside the class?

tboggs commented 4 years ago

My initial thought was just to have a simple interface for selecting a subset of bands from a SpectralLibrary, based on keywords or specific band indices. For example:

However, the more I've thought about this, I believe it makes sense to have a more general capability so that in addition to selecting/reordering bands from a SpectralLibrary, one could also select/reorder the bands in an associated image. To accomplish that, it is probably best to have the filter-related methods in several classes:

Starting with BandInfo, there should be a method to get a set of band indices, based on either a set of constants ('ascending', 'descending', 'monotonic', etc.) or a callable object that can determine the appropriate order. The return of that method would be the actual band indices (in desired order), which could then be passed to the filter methods of BandInfo, SpectralLibrary, and Image to perform the desired transformation.

Related to this, I've also been toying with the idea of changing the structure of BandInfo so instead of having a fixed set of specific arrays ("centers", "bandwidths", etc.), There could be a single object to manage all the band-specific quantities and then use property decorators to expose the individual attributes.