A Python package for Laser Speckle Contrast Imaging.
It converts raw laser speckle data (as 2D or 3D NumPy arrays) to laser speckle contrast images (a 2D NumPy array).
Check out the demo notebook at mybinder.org
The code for this package was developed for my thesis on Fingerprint Presentation Attack Detection using Laser Speckle Contrast Imaging:
To work with this package, you need to have you laser speckle images available as 2D or 3D NumPy arrays:
The process of converting the raw laser speckle images to NumPy arrays is out of scope of the PyLSCI, since this process is highly dependent on a particular LSCI setup. So you may need a custom helper module to do that job for you.
For a more detailed documentation, please see the Jupyter Notebook
demo.ipynb
that is provided in this GitHub project.
pip install pylsci
PyLSCI assumes you have your raw laser speckle data available as NumPy arrays.
Depending on your sensor setup, you may need to convert your raw laser speckle data to NumPy arrays.
You would usually have that functionality encapsulated in a custom utils module, as indicated here with my_utils
.
from my_utils import convert_speckle_to_numpy
# spatial laser speckle images are expected to be a 2D NumPy array.
speckle_img = convert_speckle_to_numpy('img/spatial.tif')
# temporal laser specke image series are expected to be 3D NumPy arrays,
# where the first dimension is the temporal domain
speckle_img_sequence = convert_speckle_to_numpy('img/temporal.png', temporal_series=True)
Values for spatial and temporal neighborhoos arguments are optional.
They default to nbh_s=3
and nbh_t=25
.
Note that nbh_s needs to be an odd value, but there is no constraint for nbh_t.
from pylsci import Lsci
lsci = Lsci(nbh_s=5, nbh_t=40)
The spatial contrast calculation requires a single laser speckle image as a NumPy 2D array and returns a single laser speckle contrast image as a 2D NumPy array.
s_lsci = lsci.spatial_contrast(speckle_img)
The temporal and spatio-temporal contrast calculation require a 3D NumPy array (time series of laser speckle images) and will return a single (averaged) laser speckle contrast image as a 2D NumPy array.
# temporal contrast calculation
t_lsci = lsci.temporal_contrast(speckle_img_sequence)
# spatio-temporal contrast calculation
st_lsci = lsci.spatio_temporal_contrast(speckle_img_sequence)
The PyLSCI packages depends on NumPy, which is is used to do all the array related calculations.
Note that the window iterations of the 2D arrays are not (yet) optimized.
The temporal_contrast()
method performs quite well, since NumPy allows to calculate the standard deviation and mean along the temporal axis for the whole array.
This is not the case for the spatial_contrast()
and spatio_temporal_contrast()
methods,
where the implementations rely on inefficient, nested loops.
Please be aware of this as calculating the contrast with the spatial_contrast()
and spatio_temporal_contrast()
methods may take a long time.
To understand the theory and concepts of LSCI, the following papers are recommended: