pumapy.segmentation

pumapy.segmentation.ccl

Functions to relying on Connected Component Labeling (CCL)

pumapy.segmentation.ccl.fill_closed_pores(workspace, solid_cutoff, fill_value, return_pores=False)[source]

Identify the porespace and fill closed porosity

Parameters
  • workspace (pumapy.Workspace) – domain

  • solid_cutoff ((int, int)) – specify the solid range to discard from pores identification

  • fill_value (int) – value to fill closed porosity with

  • return_pores (bool) – specifies whether to return identified pores

Returns

filled workspace with IDs set as: 0 for void, 1 for solid, fill_value for added filler material. In addition, if return_pores==True, then it also returns the porespace marked as: 0 solid, 1 largest pore (likely open porosity), >1 other pores

Return type

pumapy.Workspace

Example

>>> import pumapy as puma
>>> ws = puma.generate_random_spheres((100, 100, 100), diameter=20, porosity=0.8, allow_intersect=True, segmented=False)
>>> puma.render_volume(ws[:ws.matrix.shape[0] // 2])
>>> ws.binarize_range((1, 250))
>>> puma.render_volume(ws[:ws.matrix.shape[0] // 2])
>>> filled_ws, pores = puma.fill_closed_pores(ws, (1, 1), fill_value=2, return_pores=True)
>>> puma.render_volume(pores, cutoff=(0, pores.max()), cmap='jet')
pumapy.segmentation.ccl.identify_porespace(workspace, solid_cutoff, connectivity=None)[source]

Identify the porespace

Parameters
  • workspace (pumapy.Workspace) – domain

  • solid_cutoff ((int, int)) – specify the solid range to discard from pores identification

  • connectivity – Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor

(None automatically gives full connectivity of input.ndim, which for 3D domain is 3, for 2D is 2) :type connectivity: int or None :return: porespace marked as: 0 solid, 1 largest pore (likely open porosity), >1 other pores :rtype: np.ndarray

Example

>>> import pumapy as puma
>>> ws = puma.generate_sphere((100, 100, 100), (50, 50, 50), 40, segmented=False)
>>> ws.binarize_range((1, 253))
>>> puma.render_volume(ws[:ws.matrix.shape[0] // 2], cutoff=(0, 255))
>>> pores = puma.identify_porespace(ws, (1, 1))
>>> puma.render_volume(pores[:pores.shape[0] // 2], cutoff=(0, pores.max()))
pumapy.segmentation.ccl.remove_rbms(workspace, void_id, direction)[source]

Rigid Body Movements (RBMs) removal in segmented domain

Parameters
  • workspace (pumapy.Workspace) – domain

  • void_id (int) – specify the void ID to discard from RBMs identification

  • direction (str) – Cartesian direction that has to be connected, options: ‘x’, ‘y’, ‘z’

Returns

workspace without the possible RBMs determined by not being connected from side to side

Return type

pumapy.Workspace

Example

>>> import pumapy as puma
>>> workspace = puma.import_3Dtiff(puma.path_to_example_file("100_fiberform.tif"))
>>> new_ws = puma.remove_rbms(workspace, void_cutoff=(0, 103), direction='y')
>>> puma.render_volume(workspace, (104, 255), solid_color=(1,1,1))
>>> puma.render_volume(new_ws, (1, new_ws.max()), solid_color=(1,1,1))