ms_camera_model package
Submodules
ms_camera_model.data_comparison module
Multispectral Camera Model - Data Comparison
Description: Classes and their methods used for comparing real MS data with modeled data
Author: Tomas Vacek
ms_camera_model.errors module
Multispectral Camera Model - Custom Errors
Description: Custom error definitions to improve readability and make debugging easier
Author: Tomas Vacek
- exception ms_camera_model.errors.ImageDataIncompatible[source]
Bases:
ExceptionImage Data isn’t incompatible
- exception ms_camera_model.errors.IncompatibleBandChoice[source]
Bases:
ExceptionChosen bands are not compatible with this method
ms_camera_model.filter_sensor module
Multispectral Camera Model - Filters and Sensors
Description: Dataclasses and their methods for filters and sensors
Author: Tomas Vacek
- class ms_camera_model.filter_sensor.FilterSensorUnit(filter_spec, sensor_spec)[source]
Bases:
objectCombination of filter and sensor
- Parameters:
filter_spec (FilterSpecs)
sensor_spec (SensorSpecs)
- calculate_combined_attenuation()[source]
Calculate combined attenuation of filter and sensor based on their transmission and qe (quantum efficiency) curve
- Return type:
None
- combined_attenuation: ndarray
- filter_spec: FilterSpecs
- classmethod from_excel(filename_filter, filename_sensor)[source]
Load filter transmission and sensor spectral sensitivity from Excel file
- Parameters:
filename_filter (str) – Filename or path to the filter xlsx file
filename_sensor (str) – Filename or path to the sensor xlsx file
- Return type:
- interpolate_to_hs_data(hs_band_centers)[source]
Interpolate the provided filter and sensor data to hyperspectral data
- Parameters:
hs_band_centers (list[float] | None)
- Return type:
- sensor_spec: SensorSpecs
- class ms_camera_model.filter_sensor.FilterSpecs(filter_transmission, name='Generic', supplier='Generic', band_center=0, band_width=0)[source]
Bases:
objectFilter specification
- Parameters:
filter_transmission (ndarray)
name (str)
supplier (str)
band_center (int)
band_width (int)
- band_center: int = 0
- band_width: int = 0
- filter_transmission: ndarray
- name: str = 'Generic'
- supplier: str = 'Generic'
- class ms_camera_model.filter_sensor.SensorSpecs(sensor_qe_curve, name='Generic', supplier='Generic', sensor_type='CMOS')[source]
Bases:
objectSensor specification
- Parameters:
sensor_qe_curve (ndarray)
name (str)
supplier (str)
sensor_type (str)
- name: str = 'Generic'
- sensor_qe_curve: ndarray
- sensor_type: str = 'CMOS'
- supplier: str = 'Generic'
ms_camera_model.image_data module
Multispectral Camera Model - Image Data
Description: Dataclasses and their methods for image data
Author: Tomas Vacek
- class ms_camera_model.image_data.HyperspectralImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
ImageDataHyperspectral Image Data - imported from hyperspectral data file
- Method import_hs_img:
Import hyperspectral cube into img_data, band_centers and nbands
- Parameters:
img_data (ndarray)
band_centers (list[float] | None)
nbands (int | None)
- classmethod import_hs_img(filepath)[source]
Import hyperspectral cube as ImageData class instance
- Parameters:
filepath (str) – path to the hyperspectral image file
- Raises:
NoImageData – when spectral fails to load the image
- Return type:
- class ms_camera_model.image_data.ImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
objectImage Data class
- Parameters:
img_data (ndarray) – np.ndarray of image data with shape (rows, cols, bands)
band_centers (list[float] | None) – list of floats storing the center of each band in the img_data array
nbands (int | None) – number of bands in the img_data array
- Method __add__:
add two ImageData classes
- Method imshow:
view the img_data as an RGB interpretation of selected bands or as a brightness plot
- Method vector_normalize:
use vector normalization on the img_data
- Method mean_spectrum_area:
calculate mean spectrum for a select area
- Method plot_area_spectrum:
visualize the mean spectrum of an area
- Method register_images:
register img_data of another ImageData class instance against this instance
- band_centers: list[float] | None = None
- img_data: ndarray
- imshow(bands=None)[source]
View image as an RGB interpretation of selected bands or as a brightness plot
- Parameters:
bands (list[int] | None) – list of band numbers, if the list is not provided, brightness plot will be used instead
- Raises:
IncompatibleBandChoice – if ‘bands’ is not [], len(bands) != 3 or the number is out-of-bounds
- Return type:
None
- static mean_spectrum_area(img, corner_coords)[source]
Calculate mean over spectral bands for select area
- Parameters:
img (ndarray) – image data
corner_coords (list[int]) – coordinates of corners of the area in format [ulx, uly, lrx, lry]
- Return type:
ndarray
- nbands: int | None = None
- plot_area_spectrum(coordinates)[source]
Plot spectrum of pixels
- Parameters:
coordinates (list[int]) – list[ulx, uly, lrx, lry] - ulx means upper left x, lry means lower right y, etc.
- Return type:
None
- register_bands(other, band_mask_paths_ref=None, band_mask_paths_src=None)[source]
Register img_data of another ImageData class instance against this instance
- Parameters:
other (ImageData | int) – ImageData class instance that is being registered against this one
band_mask_paths_ref (list[str | None] | None) – list of mask file paths for reference images
band_mask_paths_src (list[str | None] | None) – list of mask file paths for source images
- Raises:
ImageDataIncompatible – if the number of bands differs in self and other
- Return type:
ImageData | None
- class ms_camera_model.image_data.MultispectralImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
ImageDataMultispectral Image Data - loaded from real MS camera
- Method import_altum_pt_ms_imgs:
method for import of images from MicaSense Altum-PT camera
- Method import_ms_imgs:
method for import of generic multispectral images
- Method check_filepaths:
method which checks that filepaths are a non-empty list and are strings
- Parameters:
img_data (ndarray)
band_centers (list[float] | None)
nbands (int | None)
- static check_filepaths(filepaths)[source]
Check that provided list of filepaths is usable
- Parameters:
filepaths (list[str]) – list of filepaths
- Raises:
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
None
- classmethod import_altum_pt_ms_imgs(filepaths, panel_calibration, panel_location)[source]
Import and pre-process Altum PT images
- Parameters:
filepaths (list[str]) – list of filepaths to the multispectral images, their order determines order in the final array
panel_calibration (dict[str, float]) – panel_calibration data of used MicaSense CRP
panel_location (list[list[int]]) – panel_location information format [[ulx, uly, lrx, lry], [ulx, …]]
- Raises:
NoProvidedArea – when the provided area of the CRP is None or empty
Exception – when the length of filepaths and panel_locations doesn’t match
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
- classmethod import_ms_imgs(filepaths)[source]
Import multispectral images as a np.ndarray
- Parameters:
filepaths (list[str]) – list of filepaths to the multispectral images, their order determines order in the final array
- Raises:
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
ms_camera_model.model module
Multispectral Camera Model - Simulation Model
Description: Simulated model of a multispectral camera. Takes in hyperspectral data and colour filter specs. Outputs multispectral data
Author: Tomas Vacek
- class ms_camera_model.model.MultispectralCameraModel(hs_data, filter_sensor_units)[source]
Bases:
objectMultispectral camera model
- Parameters:
hs_data (HyperspectralImageData) – HyperspectralImageData class instance
filter_sensor_units (list[FilterSensorUnit]) – list of FilterSensorUnit class instances
out_data – simulated multispectral image data as ImageData class instance
- corrected_filter_sensor_units: list[FilterSensorUnit]
- filter_sensor_units: list[FilterSensorUnit]
- hs_data: HyperspectralImageData
Module contents
Multispectral Camera Model - Simulation Model
Simulated model of a multispectral camera. Takes in hyperspectral data and colour filter specs. Outputs multispectral data
- class ms_camera_model.FilterSensorUnit(filter_spec, sensor_spec)[source]
Bases:
objectCombination of filter and sensor
- Parameters:
filter_spec (FilterSpecs)
sensor_spec (SensorSpecs)
- calculate_combined_attenuation()[source]
Calculate combined attenuation of filter and sensor based on their transmission and qe (quantum efficiency) curve
- Return type:
None
- combined_attenuation: ndarray
- filter_spec: FilterSpecs
- classmethod from_excel(filename_filter, filename_sensor)[source]
Load filter transmission and sensor spectral sensitivity from Excel file
- Parameters:
filename_filter (str) – Filename or path to the filter xlsx file
filename_sensor (str) – Filename or path to the sensor xlsx file
- Return type:
- interpolate_to_hs_data(hs_band_centers)[source]
Interpolate the provided filter and sensor data to hyperspectral data
- Parameters:
hs_band_centers (list[float] | None)
- Return type:
- sensor_spec: SensorSpecs
- class ms_camera_model.FilterSpecs(filter_transmission, name='Generic', supplier='Generic', band_center=0, band_width=0)[source]
Bases:
objectFilter specification
- Parameters:
filter_transmission (ndarray)
name (str)
supplier (str)
band_center (int)
band_width (int)
- band_center: int = 0
- band_width: int = 0
- filter_transmission: ndarray
- name: str = 'Generic'
- supplier: str = 'Generic'
- class ms_camera_model.HyperspectralImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
ImageDataHyperspectral Image Data - imported from hyperspectral data file
- Method import_hs_img:
Import hyperspectral cube into img_data, band_centers and nbands
- Parameters:
img_data (ndarray)
band_centers (list[float] | None)
nbands (int | None)
- classmethod import_hs_img(filepath)[source]
Import hyperspectral cube as ImageData class instance
- Parameters:
filepath (str) – path to the hyperspectral image file
- Raises:
NoImageData – when spectral fails to load the image
- Return type:
- class ms_camera_model.ImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
objectImage Data class
- Parameters:
img_data (ndarray) – np.ndarray of image data with shape (rows, cols, bands)
band_centers (list[float] | None) – list of floats storing the center of each band in the img_data array
nbands (int | None) – number of bands in the img_data array
- Method __add__:
add two ImageData classes
- Method imshow:
view the img_data as an RGB interpretation of selected bands or as a brightness plot
- Method vector_normalize:
use vector normalization on the img_data
- Method mean_spectrum_area:
calculate mean spectrum for a select area
- Method plot_area_spectrum:
visualize the mean spectrum of an area
- Method register_images:
register img_data of another ImageData class instance against this instance
- band_centers: list[float] | None = None
- img_data: ndarray
- imshow(bands=None)[source]
View image as an RGB interpretation of selected bands or as a brightness plot
- Parameters:
bands (list[int] | None) – list of band numbers, if the list is not provided, brightness plot will be used instead
- Raises:
IncompatibleBandChoice – if ‘bands’ is not [], len(bands) != 3 or the number is out-of-bounds
- Return type:
None
- static mean_spectrum_area(img, corner_coords)[source]
Calculate mean over spectral bands for select area
- Parameters:
img (ndarray) – image data
corner_coords (list[int]) – coordinates of corners of the area in format [ulx, uly, lrx, lry]
- Return type:
ndarray
- nbands: int | None = None
- plot_area_spectrum(coordinates)[source]
Plot spectrum of pixels
- Parameters:
coordinates (list[int]) – list[ulx, uly, lrx, lry] - ulx means upper left x, lry means lower right y, etc.
- Return type:
None
- register_bands(other, band_mask_paths_ref=None, band_mask_paths_src=None)[source]
Register img_data of another ImageData class instance against this instance
- Parameters:
other (ImageData | int) – ImageData class instance that is being registered against this one
band_mask_paths_ref (list[str | None] | None) – list of mask file paths for reference images
band_mask_paths_src (list[str | None] | None) – list of mask file paths for source images
- Raises:
ImageDataIncompatible – if the number of bands differs in self and other
- Return type:
ImageData | None
- class ms_camera_model.MultispectralCameraModel(hs_data, filter_sensor_units)[source]
Bases:
objectMultispectral camera model
- Parameters:
hs_data (HyperspectralImageData) – HyperspectralImageData class instance
filter_sensor_units (list[FilterSensorUnit]) – list of FilterSensorUnit class instances
out_data – simulated multispectral image data as ImageData class instance
- corrected_filter_sensor_units: list[FilterSensorUnit]
- filter_sensor_units: list[FilterSensorUnit]
- hs_data: HyperspectralImageData
- class ms_camera_model.MultispectralImageData(img_data, band_centers=None, nbands=None)[source]
Bases:
ImageDataMultispectral Image Data - loaded from real MS camera
- Method import_altum_pt_ms_imgs:
method for import of images from MicaSense Altum-PT camera
- Method import_ms_imgs:
method for import of generic multispectral images
- Method check_filepaths:
method which checks that filepaths are a non-empty list and are strings
- Parameters:
img_data (ndarray)
band_centers (list[float] | None)
nbands (int | None)
- static check_filepaths(filepaths)[source]
Check that provided list of filepaths is usable
- Parameters:
filepaths (list[str]) – list of filepaths
- Raises:
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
None
- classmethod import_altum_pt_ms_imgs(filepaths, panel_calibration, panel_location)[source]
Import and pre-process Altum PT images
- Parameters:
filepaths (list[str]) – list of filepaths to the multispectral images, their order determines order in the final array
panel_calibration (dict[str, float]) – panel_calibration data of used MicaSense CRP
panel_location (list[list[int]]) – panel_location information format [[ulx, uly, lrx, lry], [ulx, …]]
- Raises:
NoProvidedArea – when the provided area of the CRP is None or empty
Exception – when the length of filepaths and panel_locations doesn’t match
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
- classmethod import_ms_imgs(filepaths)[source]
Import multispectral images as a np.ndarray
- Parameters:
filepaths (list[str]) – list of filepaths to the multispectral images, their order determines order in the final array
- Raises:
TypeError – when provided paths aren’t in list
TypeError – when provided paths aren’t strings
NoProvidedFilepaths – when there are no provided filepaths
- Return type:
- class ms_camera_model.SensorSpecs(sensor_qe_curve, name='Generic', supplier='Generic', sensor_type='CMOS')[source]
Bases:
objectSensor specification
- Parameters:
sensor_qe_curve (ndarray)
name (str)
supplier (str)
sensor_type (str)
- name: str = 'Generic'
- sensor_qe_curve: ndarray
- sensor_type: str = 'CMOS'
- supplier: str = 'Generic'