porespy.tools.align_image_with_openpnm#

porespy.tools.align_image_with_openpnm(im)#

Permute image axes so they align with OpenPNM pore.coords when the image is loaded into ParaView (or any tool whose TIFF reader treats numpy axis 0 as the z-stack).

OpenPNM treats pore.coords as (x, y, z), but the centroids that PoreSpy hands to OpenPNM are in numpy index order (axis0, axis1, axis2). A TIFF-style reader interprets axis 0 as z, axis 1 as y, axis 2 as x, so swapping axes 0 and 2 (or 0 and 1 in 2D) makes the image’s voxel order match OpenPNM’s coordinate order.

Note that this function is not needed when writing the image with porespy.io.to_vtk — pyevtk preserves numpy axis order, so ParaView already lines the network up with the image.

Parameters:

im (ndarray) – The 2D or 3D image to be aligned. Can be the Boolean image of the pore space or any other image of interest.

Returns:

image – A copy of im with axes swapped so it overlays correctly with the OpenPNM network in ParaView when saved via TIFF.

Return type:

ndarray

Examples

Click here to view online example.