spectralpython / spectral

Python module for hyperspectral image processing
MIT License
563 stars 138 forks source link

Classes in imshow is showing solid colour #150

Closed Russjas closed 1 year ago

Russjas commented 1 year ago

Is there an upper limit to the number of classes that can be displayed. I have 249 classes but the majority only have 1 or 2 pixels. Classes 40 and 41 are populated throughout the image, but are displaying as the same colour.

tboggs commented 1 year ago

spy only defines about 40 colors in its color palette. Trying to view many more colors than that is problematic because they are increasingly difficult to distinguish. If you know classes 40 and 41 are the ones you really care about, you could create a random color array of shape (249, 3), then set the first entry (background) to [0, 0, 0] and set the 40th and 41st entries to specific colors. Then pass that array as the "colors" keyword to spy.imshow. Or if you really only care about those two classes just set all other colors to [0, 0, 0].

Depending on the size of your image, you might also want to try setting interpolation="nearest" when calling spy.imshow.

Russjas commented 1 year ago

Thanks, good suggestions, will give it a try