spectralpython / spectral

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

ImageView.__str__ fails when viewing class labels without image data #27

Closed tboggs closed 9 years ago

tboggs commented 9 years ago

ImageView.__str__ prints the bands element of the RGB metadata; however, this metadata element is not present if class labels are being viewed without an associated image data array. For example:

>>> v = spy.imshow(classes=gt)
>>> v
/home/thomas/src/spectral/spectral/graphics/spypylab.pyc in __str__(self)
   1117         meta = self.data_rgb_meta
   1118         s = 'ImageView object:\n'
-> 1119         s += '  {0:<20}:  {1}\n'.format("Display bands", meta['bands'])
   1120         if self.interpolation == None:
   1121             interp = "<default>"

KeyError: u'bands'