grains.segmentation.Segmentation

class grains.segmentation.Segmentation(image_location, save_location=None, interactive_mode=True)[source]

Segmentation of grain-based microstructures

original_image

Matrix representing the initial, unprocessed image.

Type

ndarray

save_location

Directory where the processed images are saved

Type

str

__init__(image_location, save_location=None, interactive_mode=True)[source]

Initialize the class with file paths and with some options

Parameters
  • image_location (str) – Path to the image to be segmented, file extension included.

  • save_location (str, optional) – Path to directory where images will be outputted. If not given, the same directory is used where the input image is loaded from.

  • interactive_mode (bool, optional) – When True, images of each image manipulation step are plotted and details are shown in the console. Default is False.

Returns

None.

Methods

__init__(image_location[, save_location, …])

Initialize the class with file paths and with some options

create_skeleton(boundary_image)

Use thinning on the grain boundary image to obtain a single-pixel wide skeleton.

filter_image(window_size[, image_matrix])

Median filtering on an image.

find_grain_boundaries(segmented_image)

Find the grain boundaries.

initial_segmentation(*args)

Perform the quick shift superpixel segmentation on an image.

merge_clusters(segmented_image[, threshold])

Merge tiny superpixel clusters.

save_array(filename, array)

Save an image as a numpy array.

save_image(filename, array[, is_label_image])

Save an image as a numpy array.

watershed_segmentation(skeleton)

Watershed segmentation of a granular microstructure.