spectralpython/spectral

Classes in imshow is showing solid colour

Russjas opened this issue · 2 comments

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.

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.

Thanks, good suggestions, will give it a try