porosity

porosity(im)[source]

Calculates the porosity of an image assuming 1’s are void space and 0’s are solid phase.

All other values are ignored, so this can also return the relative fraction of a phase of interest in multiphase images.

Parameters

im (ndarray) – Image of the void space with 1’s indicating void phase (or True) and 0’s indicating the solid phase (or False).

Returns

porosity – Calculated as the sum of all 1’s divided by the sum of all 1’s and 0’s. Note that the denominator is not the total image size, so putting values of 2 in some voxels, for instance, will remove those voxels from consideration.

Return type

float

See also

phase_fraction, find_outer_region

Notes

This function assumes void is represented by 1 and solid by 0, and all other values are ignored. This is useful, for example, for images of cylindrical cores, where all voxels outside the core are labelled with 2.

Alternatively, images can be processed with find_disconnected_voxels to get an image of only blind pores. This can then be added to the orignal image such that blind pores have a value of 2, thus allowing the calculation of accessible porosity, rather than overall porosity.

Examples

Click here to view online example.