In [1]:
from get_hsi_data import get_data


/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

Extract the HSI Data


In [2]:
img = get_data()


-- Indian Pines dataset found locally --
-- Completed --

Visualize the Data


In [6]:
import spectral as sppy
import matplotlib.pyplot as plt
%matplotlib inline
view = sppy.imshow(img['original'], (29, 19, 9),
                   figsize=(10,10))

print view


ImageView object:
  Display bands       :  (29, 19, 9)
  Interpolation       :  <default>
  RGB data limits     :
    R: [2054.0, 6317.0]
    G: [2560.0, 7307.0]
    B: [2792.0, 7928.0]


In [9]:
# view class map
import matplotlib.pyplot as plt
%matplotlib inline
class_view = sppy.imshow(classes=img['groundtruth'])



In [10]:
# overlay
import matplotlib.pyplot as plt
%matplotlib inline
view_overlap = sppy.imshow(data=img['original'],
                           bands=(29,19,9),
                           classes=img['groundtruth'],
                           figsize=(10,10))
view_overlap.set_display_mode('overlay')
view_overlap.class_alpha = 0.8



In [5]:
# interactive class labeling
import matplotlib.pyplot as plt
%matplotlib qt
import numpy as np


empty_gt = np.zeros(np.shape(img['groundtruth']))
view_interactive = sppy.imshow(data=img['original'],
                                  bands=(29,19,9),
                                  classes=empty_gt)

In [11]:
# view hsi cube
%matplotlib qt
hsi_cube = sppy.view_cube(data=img['original'],
                          bands=(29,19,9))


/usr/local/lib/python2.7/dist-packages/spectral/graphics/graphics.py:786: UserWarning: 
There is no current wx.App object - creating one now.
  UserWarning)
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/spectral/graphics/hypercube.pyc in on_paint(self, event)
    341 
    342         if not self.gl_initialized:
--> 343             self.initgl()
    344             self.gl_initialized = True
    345             self.print_help()

/usr/local/lib/python2.7/dist-packages/spectral/graphics/hypercube.pyc in initgl(self)
    313         import OpenGL.GL as gl
    314         import OpenGL.GLU as glu
--> 315         self.load_textures()
    316         gl.glEnable(gl.GL_TEXTURE_2D)
    317         gl.glClearColor(*self.clear_color)

/usr/local/lib/python2.7/dist-packages/spectral/graphics/hypercube.pyc in load_textures(self)
    278         texSizes = [(b, a), (b, c), (a, c), (b, c), (a, c), (b, a)]
    279         for i in range(len(images)):
--> 280             img = images[i].tostring("raw", "RGBX", 0, -1)
    281             (dim_x, dim_y) = images[i].size
    282             texImages.append(img)

/usr/local/lib/python2.7/dist-packages/PIL/Image.pyc in tostring(self, *args, **kw)
    697     def tostring(self, *args, **kw):
    698         raise Exception("tostring() has been removed. " +
--> 699                         "Please call tobytes() instead.")
    700 
    701     def tobitmap(self, name="image"):

Exception: tostring() has been removed. Please call tobytes() instead.

In [ ]: