SPAM logo

SPAM logo

SPAM: Software for Practical Analysis of Materials

spam is an open-source python tool for quantitative data analysis for 2D images and 3D volumes for mechanics applications that has developed around x-ray and neutron tomography.
spam provides a registration function as well as local, global and discrete image correlation methods and their associated strain calculation. It also includes utilities varying from computing geometrical quantities such as size, shape and orientation to generating unstructured meshes.

For any questions that the documentation failed to answer, for suggestions or bug reports please join us in our chat room. You can also participate in one of our yearly workshop to meet us in person.

Speckled sandstone surface, as seen by the camera
Deviatoric strain without regularisation Deviatoric strain, regularisation length 30 px Deviatoric strain, regularisation length 60 px: shear bands cross the sample Deviatoric strain, regularisation length 120 px Displacement magnitude without regularisation Displacement magnitude, regularisation length 30 px Displacement magnitude, regularisation length 60 px: blocks separated by the shear bands Displacement magnitude, regularisation length 120 px
Finite-element mesh used by global DIC, deformed by the measured displacements (magnified 40 times) Strain Camera
Mechanical regularisation

Global Digital Image Correlation

Invisible to the eye.
Measured by spam.

Two photographs of a sandstone, taken before and after loading in the true triaxial cell of Laboratoire 3SR, look identical. Global DIC finds the shear bands forming inside.

Mesh
Displacements are solved on a finite-element mesh covering the whole image, not on independent patches.
Mechanical regularisation
Fields that are not mechanically admissible below a length ξ are filtered out (Mendoza et al., 2019). This is what makes such a fine mesh usable: switch it off under the image to see.
Result
The displacement field shows blocks of rock moving almost rigidly; the deviatoric strain shows where the deformation localises between them, into shear bands.

Global DIC · in the field

Correlating a mountain
under a moving sun.

Tsarmine, in the Arolla valley (Swiss Alps), is a destabilised rock glacier, 500 m long, creeping several metres a year. An autonomous drone flew over it every week of summer 2025, but from one flight to the next the sun and the shadows move. So global DIC does not correlate the photographs: it correlates the geometry of the ground, through hillshades of the elevation models.

{# layers, bottom to top: hillshade | measured field left of the handle | GNSS station; the images of the date shown are added by the script below #}
Displacement Hillshade

Autonomous drone
A solar-powered docking station next to the site flew 16 weekly surveys, July to October 2025. Photogrammetry gives orthoimages and elevation models at a few centimetres per pixel; the orthoimages, under the relief, show how much the light changes between flights.
Geometry, not light
Each elevation model is shaded under the same artificial light: only the relief changes between these hillshades. Global DIC tracks them on 78 000 triangles of 1.5 m, mechanically regularised over 6 m, and the elevation models give the vertical component. The longitudinal strain shows where the rock glacier stretches and compresses, the shear strain the margins where it slides past the stable ground.
Checked on the ground
A permanent GNSS station rides on the rock glacier: in 3D, DIC agrees with it within a few centimetres all summer long, on displacements reaching 2 m.

Data: S. Vivero, E. Roubin, E. Andò, G. Ruggiero, S. Bonetti (CHANGE, EPFL · Laboratoire 3SR · EPFL Center for Imaging · Fieldwork SA).

# install the pip module
pip install spam
>>> import tifffile
>>> import spam.DIC
>>> # load your images
>>> im1 = tifffile.imread("im1.tif")
>>> im2 = tifffile.imread("im2.tif")
>>> # and register them
>>> spam.DIC.register(im1, im2)

SPAM won the 2024 edition of an Open Source Software for research prize by the French Ministry of Higher Education and Research.

We are delighted to have received this prize, as it aligns with the values and principles that we hold dear such as open source distribution, documented features and community driven developement.

SPAM wouldn't be what it is today without its thriving community and we can't thank you enough for that.

Check out our yearly workshops

Workshop in Athens (2027) Registrations are open

From Monday the 28th to Friday the 2nd of July 2027, Athens (Greece).

Workshop in Dresden (2025) Registrations are closed

From Sunday the 9th to Thursday the 13th of November 2025, Dresden (Germany).

Cite the paper

Stamati, Andò, Roubin, Cailletaud, Wiebicke, Pinzon, Couture, et al. (2020)
SPAM: Software for Practical Analysis of Materials Journal of Open Source Software