porespy.tools#

This module contains a variety of functions for manipulating images in ways that do NOT return a modified version of the original image.

Classes#

Results

A minimal class for use when returning multiple values from a function

Settings

A dataclass for use at the module level to store settings. This class

Functions#

align_image_with_openpnm(im)

Rotates an image to agree with the coordinates used in OpenPNM.

all_to_uniform(im[, scale])

Take an image with some distribution of greyscale values and convert it to

area_of_triangle(p0, p1, p2)

As per Herons formula

ball(r)

bbox_to_slices(bbox)

Given a tuple containing bounding box coordinates, return a tuple of slice

block_size_to_divs(shape, block_size)

Finds the number of blocks in each direction given the size of the blocks

calculate_area_and_volume(img, vertex_index_array[, ...])

center_of_mass(im)

create_mc_template_list([spacing])

Return area and volume lists for the marching cubes templates. Reads the

cube(w)

disk(r)

extend_slice(slices, shape[, pad])

Adjust slice indices to include additional voxles around the slice.

extract_cylinder(im[, r, axis])

Returns a cylindrical section of the image of specified radius.

extract_regions(regions, labels[, trim])

Combine given regions into a single boolean mask

extract_subsection(im, shape)

Extracts the middle section of a image

face_orientation(v0, v1, v2)

Return outward perpendicular vector distance of face along the z axis

find_bbox(im[, order_by])

Finds the lower and upper corner surrounding the foreground in the image

find_outer_region(im[, r])

Find regions of the image that are outside of the solid matrix.

get_block_sizes(im[, block_size_range])

Finds all viable block sizes between lower and upper limits

get_edt()

get_fixtures_path()

Get the path to the test fixtures directory.

get_planes(im[, squeeze])

Extracts three planar images from the volumetric image, one for each

get_skel()

get_slices_grid(im[, divs, block_size, overlap, mode])

Returns slices into an image describing the specified number of sub-arrays.

get_slices_multigrid(im, block_size_range[, overlap, mode])

Creates a set of grids spanning the request block size range

get_slices_random(im[, n, lims, aspect])

Generates a list of slice objects which can be used to obtain cubic subdomains

get_slices_slabs(im[, axis, span, step, mode])

Generates a list of slice objects which can be used to obtain slabs of an image

get_strel()

get_tqdm()

Fetches a version of tqdm function that depends on the environment.

in_hull(points, hull)

Test if a list of coordinates are inside a given convex hull

insert_cylinder(im, xyz0, xyz1, r)

Inserts a cylinder of given radius onto an image

insert_sphere(im, c, r[, v, overwrite])

Inserts a sphere of a specified radius into a given image

isolate_object(region, i[, s])

Given an image containing labels, removes all labels except the specified

jit_extend_slice(slices, shape[, pad])

jit_marching_cubes_area_and_volume(img[, ...])

jit_marching_squares_perimeter_and_area(img[, ...])

make_contiguous(im[, mode])

Take an image with arbitrary greyscale values and adjust them to ensure

marching_cubes_area_and_volume(img[, target_label, ...])

marching_map(path, start)

Use the fast marching method to find distance of each voxel from a starting

mc_templates_generator([override])

Generates a marching cubes template list file, if one is not available

mesh_region(region[, strel, voxel_size])

Creates a tri-mesh of the provided region using the marching cubes

overlay(im1, im2, c)

Overlays im2 onto im1, given voxel coords of center of im2

pad(img)

Assumes pad width=1 and mode is constant = 0

parse_shape(im_or_shape)

Given a list of dimensions or an image finds shape in a clean format

parse_steps(steps, vals[, mask, descending])

Converts given steps into a list of sizes

points_to_spheres(im)

Inserts disks/spheres into an image at locations indicated by non-zero values

ps_ball(r[, smooth])

Creates spherical ball structuring element for morphological operations

ps_disk(r[, smooth])

Creates circular disk structuring element for morphological operations

ps_rect(w, ndim)

Creates rectilinear structuring element with the given size and

ps_round(r, ndim[, smooth])

Creates round structuring element with the given radius and dimensionality

randomize_colors(im[, keep_vals])

Takes a greyscale image and randomly shuffles the greyscale values.

recombine(ims, slices, overlap)

Recombines image blocks back into full image

results_to_df(obj)

A helper function to convert Results objects to pandas DataFrames.

sanitize_filename(filename, ext[, exclude_ext])

Returns a sanitized string in the form of name.extension

show_docstring(func)

Fetches the docstring for a function and returns it in markdown format.

square(w)

tic()

Homemade version of matlab tic and toc function, tic starts or resets

toc([quiet])

Homemade version of matlab tic and toc function, tic starts or resets

unpad(im, pad_width)

Remove padding from a previously padded image given original pad widths

Package Contents#

settings[source]#