User Guide

PoreSpy is a collection of functions that are especially useful for analyzing binary images of porous materials, typically produced by X-ray tomography. The functions in this collection are often simple combinations of other standard image analysis functions, so really only offer the convenience of organizing the functions into one place, and sparing you the trouble of working them out.


This package consists of several modules, the purposes of which are given below:

binarization Convert greyscale images to binary
filters Process images based on structural features
generators Make artificial images for testing & illustration
metrics Extract information from images
network_extraction Extract pore network models from images
simulations Performing complex simulations directly on an image
tools Utilities for altering & manipulating images
visualization Quickly and easily visualiz 3D images
io Import and export image data in various formats

Example Usage

>>> import porespy as ps
>>> import matplotlib.pyplot as plt
>>> im = ps.generators.blobs([100, 100])
>>> mip = ps.filters.porosimetry(im)
>>> PcSw = ps.metrics.pore_size_distribution(mip)
>>> fig = plt.plot(*PcSw)

Image Types

PoreSpy is meant to work on single-channel, binary images. Such images are conveniently represented by Numpy arrays, hence all references to an image is equivalent to an array. It is further assumed that the arrays are binarized, meaning 1’s or True values indicating the void space, and 0’s or False values for the solid.


Although scikit-image and scipy.ndimage have a wide assortment of functions, they are not always the fastest implementation. It is often faster to use ImageJ for many things, such as distance transforms and image morphology. The advantage of PoreSpy is the flexibility offered by the Python environment.