HSImage
Hyperspectral Image Interface Library for ENVI-BIL image files
All Classes Functions Variables Typedefs Groups Pages
HSI.dxy
1 ##@defgroup hsipy HSI Python Module
2 # This Python module provides an interface for the use of the C++ library in Python code. The sofware was written using the boost::python framework and allows for fully Pythonic programming to be done using the functions and code in this library.
3 # @{
4 
5 
6 ## @class hsimage
7 #This class provides an interface for unlabeled ENVI-BIL hyperspectral images
8 #
9 #This class provides an interface to an unlabeled hyperspectral image. It requires a header (.hdr) file and an image (.raw) file for basic operation, and two spectrometer files (.txt) for full operation.
10 class hsimage:
11 
12  ## Constructor
13  #Default Constructor to create empty hsimage instance
14  def __init__():
15 
16  ## Constructor
17  # Construction for loading with a header (.hdr) file and an image (.raw) file
18  # @param header_loc: Location of header file
19  # @param image_loc Location of image file
20  # @return hsimage hsimage instance
21  def __init__(header_loc, image_loc):
22 
23  ## Constructor
24  # Constructor for loading with header (.hdr), image (.raw) and spectrometer files (.txt)
25  # @param header_loc: Location of header file
26  # @param image_loc: Location of image file
27  # @param spec_locations: List of strings of spectrometer location files
28  # @return hsimage hsimage instance
29  def __init__(header_loc, image_loc, spec_locations):
30 
31  ## Constructor
32  #
33  # Copy constructor
34  # @param hsimage_instance: Instance to copy from
35  # @return hsimage hsimage instance
36  def __init__(hsimage_instance):
37 
38  ## Load
39  #
40  # Load function
41  # @param header_loc: Location of header file
42  # @param image_loc: Location of image file
43  def load(header_loc,image_loc):
44 
45  ##Load
46  #
47  #Load function
48  #@param header_loc: Location of header file
49  #@param image_loc: Location of image file
50  #@param spec_locations: List of spectrometer file location strings
51  def load(header_loc,image_loc,spec_locations):
52 
53  ##loadSpectrometerData
54  #
55  #Load spectrometer data into existing hsimage instance
56  #@param spec_locations: List of spectrometer file location strings
57  def loadSpectrometerData(spec_locations):
58 
59  ##hasSpecFiles
60  #
61  #Check if instance of hsimage has associated spectrometer files
62  #@return Boolean Returns True if spectrometer file locations stored in header (.hdr) file, otherwise returns False
63  def hasSpecFiles():
64 
65  ##getPixelSpectra
66  #
67  #Get wavelength vector at a single pixel (row,col) location
68  #@param row Row of pixel to retrieve
69  #@param col Column of pixel to retrieve
70  #@return List[float] Returns a wavelength intensity vector of the specified pixel
71  def getPixelSpectra(row,col):
72 
73  ##getWavelengths
74  #
75  #Get wavelengths detected by camera
76  #@return List[float] Returns a list of detected wavelengths
78 
79  ##getAmbientIntensities
80  #
81  #Get ambient intensities at wavelengths given by getWavelengths() if spectrometer data has been loaded into hsimage instance
82  #@return List[float] Returns a list of ambient (spectrometer) intensities at the measured wavelengths
84 
85  ##getPixelTransferFunction
86  #
87  #Get pixel transfer function, or pixel reflectance, at a specific row, col location. Only enabled if spectrometer data has been loaded into hsimage instance
88  #@param row Row of pixel to retrieve
89  #@param col Column of pixel to retrieve
90  #@return List[float]
92 
93  ##getPixelArray
94  #
95  #Get the entire pixel array, in row major order. Array returned is of size (rows*cols, bands)
96  #@return List(uint)
97  def getPixelArray():
98 
99 
100  ##getRange
101  #
102  #Get range of wavelength arrays from a minimum wavelength to a maximum wavelength, inclusive
103  #@param low_wavelength Lower wavelength
104  #@param high_wavelength Higher wavelength
105  #@return List[List[float]] Returns a nested list of wavelength spectra
106  def getRange(low_wavelength, high_wavelength):
107 
108  ##getSet
109  #
110  #Get set of wavelength arrays from list of wavelengths passed into function
111  #@param wavelengths List of wavelengths to return
112  #@return List[List[float]] Returns a nested list of wavelength spectra
113  def getSet(wavelengths):
114 
115  ##getBand
116  #
117  #Returns a numpy array useable with OpenCV of the intensities at every pixel of one wavelength
118  #@param wavelength Wavelength image to return
119  #@return np.array OpenCV compatible numpy array wavelength image
120  def getBand(wavelength):
121 
122  ##getShape
123  #
124  #Returns a tuple of (row,col,bands) that give the size of the underlying hyperspectral data
125  #@return tuple (row,col,bands)
126  def getShape():
127 
128 ## @class classified_hsimage
129 #
130 #This class provides an interface for labeled and classified ENVI-BIL hyperspectral images. It requires either a loaded hsimage instance, an OpenCV image and a list of ("name", [color]) tuples or a full set of hyperspectral image files: header (.hdr), image (.raw) and a label (.lif) file. Using the method with the .lif files is recommended. This method assumes that the spectrometer files have been previously loaded with the hsimage instance and have been saved to the (.hdr) file. This happens automatically if the spectrometer files are loaded with the hsimage instance.
131 class classified_hsimage:
132 
133  ##Constructor
134  #Default constructor to create empty classified_hsimage instance
135  def __init__():
136 
137  ##Constructor
138  #
139  #Constructor for loading with hsimage instance, OpenCV Label image and vector of class name and color tuples
140  #@param img hsimage instance
141  #@param label_img numpy array compatible with OpenCV containing 3-channel colors for the different classes present in the image
142  #@param label_colors list of ("name",[blue,green,red]) tuples associating the class names to the appropriate color in the label_img
143  #@return classified_hsimage classified_hsimage instance
144  def __init__(img,label_img,label_colors):
145 
146  ##Constructor (Recommended)
147  #
148  #Constructor for loading from file system using the image (.raw), header (.hdr) and label (.lif) files. This method assumes that at some previous time the spectrometer files have been loaded in the image and stored in the image .hdr file. If you are unsure that this has happened, load the underlying hsimage into memory and specify the spectrometer file locations. You can can also check to see if the end of the header file has the spectrometer file locations stored at the end of the file.
149  #@param image_file Image (.raw) file
150  #@param header_file Header (.hdr) file
151  #@param label_file Label (.lif) file
152  #@return classified_hsimage classified_hsimage instance
153  def __init__(image_file,header_file,label_file):
154 
155  ##getClassSpectra
156  #
157  #Gets a number of wavelength spectra from a specific class by name
158  #@param class_name Name of class to retrieve
159  #@param num_spectra Number of spectra to return. -1 to return all class spectra
160  #@return List[List[float]] Returns a nested list of wavelength spectra intensities of one class
161  ##hsimage
162  #
163  #Underlying hsimage object that contains the image data that classified_hsimage is built around. Accessible and enables the entire API of hsimage.
164  hsimage = hsimage()
165 
166  def getClassSpectra(class_name,num_spectra):
167 
168  ##getClassTF
169  #
170  #Gets the reflectance (transfer function) spectra from a specific class by name
171  #@param class_name Name of class to retrieve
172  #@param num_spectra Number of spectra to return. -1 to return all class reflectance spectra
173  #@return List[List[float]] Returns a nested list of floats containing the returned reflectance spectra in the requested class
174  def getClassTF(class_name,num_spectra):
175 
176  ##getAvgClassTF
177  #
178  #Gets the mean reflectance spectrum of a specific class. Returns one spectrum.
179  #@param class_name Name of class to retrieve
180  #@return List[float] Returns a list of floats containing the average spectrum of a class
181  def getAvgClassTF(class_name):
182 
183  ##getPixelClass
184  #
185  #Gets the class of a specific (row,col) pixel and returns it as a string
186  #@param row Row of pixel to retrieve
187  #@param col Column of pixel to retrieve
188  #@return String Name of class of retrieved pixel
189  def getPixelClass(row,col):
190 
191  ##setSpectraClass
192  #
193  #Sets the class of one pixel by (row,col) to a new class by name
194  #@param row Row of pixel to change class
195  #@param col Column of pixel to change class
196  #@param class_name New class name for updated pixel
197  def setSpectraClass(row,col,class_name):
198 
199  ##setSpectraClass
200  #
201  #Sets the class of a set of pixels to a new class by name
202  #@param pixel_locs A list of (row,col) tuples for each pixel to update
203  #@param class_name New class name for updated pixel
204  def setSpectraClass(pixel_locs,class_name):
205 
206  ##setImageClass
207  #
208  #Sets the class(es) of the whole image to a new set based on the class_labels input which is an image colored with the class information
209  #@param class_labels OpenCV compatible numpy array where each point is colored with the corresponding class color
210  #@param class_list List of tuples of class name and corresponding color
211  def setImageClass(class_labels,class_list):
212 
213  ##setImageClass
214  #
215  #Sets the class(es) of the
216 
217  ##getImageClass
218  #
219  #Returns the OpenCV compatilble numpy array showing the class labels by color at each pixel of the image.
220  #@return np.array OpenCV compatible numpy array
222 
223 
224 ##@class labelfile
225 #
226 #The LabelFile class is used to open and extract labeled object information from a CSAIL/LabelMe style label file, usually with a .lif extension. This file contains all the information about labeled objects in a specific image, as well as an encoded .png image file containing the RGB image that was used to generate the labeling information. This interface allows you to gather all necessary information from the label file and apply it to classified hyperspectral images.
227 class labelfile:
228 
229  ##Constructor
230  #Default constructor to create empty labelfile instance
231  def __init__():
232 
233  ##Constructor from file
234  #
235  #Constructs a labelfile object from a file on disk and loads it into memory
236  #@param filename Filename of label (.lif) file to read into labelfile object
237  def __init__(filename):
238 
239  ##Load from file
240  #
241  #Loads the contents of a label (.lif) file into an already created labelfile instance.
242  #@param filename Filename of label (.lif) file to read into labelfile instance
243  def load(filename):
244 
245  ##Get RGB Image
246  #
247  #Returns the image of the original scene as an OpenCV compatible numpy array
248  #@return np.array Original Scene Image
249  def getRGBImage():
250 
251  ##Get Label Image
252  #
253  #Returns the image containing class and label information as an OpenCV compatible numpy array
254  #@return np.array Label information image
256 
257  ##Get Overlay Image
258  #
259  #Returns the human-viewing friendly image showing the original scene with the class information overlaid
260  #@return np.array Overlay Image
262 
263  ##Get Class Info
264  #
265  #Returns the vector of class color and name associations
266  #@return List[("name",[red,green,blue])] List of class color associations
268 
269  ##Get Color Info
270  #
271  #Returns the vector of class color and name associations, in reverse order
272  #@return List[([red,green,blue],"name")]
273 ## @}
def getPixelArray
getPixelArray
Definition: HSI.dxy:97
def getWavelengths
getWavelengths
Definition: HSI.dxy:77
def getRange
getRange
Definition: HSI.dxy:106
def getAvgClassTF
getAvgClassTF
Definition: HSI.dxy:181
def loadSpectrometerData
loadSpectrometerData
Definition: HSI.dxy:57
def getImageClass
setImageClass
Definition: HSI.dxy:221
def getPixelClass
getPixelClass
Definition: HSI.dxy:189
def getBand
getBand
Definition: HSI.dxy:120
def getShape
getShape
Definition: HSI.dxy:126
def getClassTF
getClassTF
Definition: HSI.dxy:174
def getOverlayImage
Get Overlay Image.
Definition: HSI.dxy:261
def getClassInfo
Get Class Info.
Definition: HSI.dxy:267
def load
Load.
Definition: HSI.dxy:43
def load
Load from file.
Definition: HSI.dxy:243
def setSpectraClass
setSpectraClass
Definition: HSI.dxy:197
def getLabelImage
Get Label Image.
Definition: HSI.dxy:255
def getPixelSpectra
getPixelSpectra
Definition: HSI.dxy:71
def __init__
Constructor Default constructor to create empty classified_hsimage instance.
Definition: HSI.dxy:135
def getRGBImage
Get RGB Image.
Definition: HSI.dxy:249
def setImageClass
setImageClass
Definition: HSI.dxy:211
def getPixelTransferFunction
getPixelTransferFunction
Definition: HSI.dxy:91
def getSet
getSet
Definition: HSI.dxy:113
def hasSpecFiles
hasSpecFiles
Definition: HSI.dxy:63
def getAmbientIntensities
getAmbientIntensities
Definition: HSI.dxy:83
def __init__
Constructor Default constructor to create empty labelfile instance.
Definition: HSI.dxy:231
def __init__
Constructor Default Constructor to create empty hsimage instance.
Definition: HSI.dxy:14
This class provides an interface for unlabeled ENVI-BIL hyperspectral images.
Definition: HSI.dxy:10