Preprocessing

Warning

The processing methods are currently only supported in the Python extension. Some or all of these will be supported in the C library at some point in the future.

The SDK provides a number of built-in pre-processing methods. These generally work as pipeline elements, i.e., they return new hsi.HSImage objects with deferred execution.

Reflectance transformation

import hsi
from hsi.preprocessing import make_reference, reflectance_calibration

img = hsi.open("path/to/file.hdr")
dark = hsi.open("path/to/dark_file.hdr")

white_ref = make_reference(img[:100, :, :])
dark_ref = make_reference(dark)

reflectance = reflectance_calibration(img, white_ref, dark_ref)

Normalization (SNV)

import hsi
from hsi.preprocessing import snv

img = hsi.open("path/to/file.hdr")

normalized = snv(img, dtype=hsi.float32)

Savitzky-Golay filter

import hsi
from hsi.preprocessing import savgol_filter

img = hsi.open("path/to/file.hdr")

filtered = savgol_filter(img, window_length=10, polyorder=2, dtype=hsi.float32)