- chunked_func(func, overlap=None, divs=2, cores=None, im_arg=['input', 'image', 'im'], strel_arg=['strel', 'structure', 'footprint'], **kwargs)#
Performs the specfied operation “chunk-wise” in parallel using
This can be used to save memory by doing one chunk at a time (
cores=1) or to increase computation speed by spreading the work across multiple cores (e.g.
This function can be used with any operation that applies a structuring element of some sort, since this implies that the operation is local and can be chunked.
func (function handle) – The function which should be applied to each chunk, such as
overlap (scalar or list of scalars, optional) – The amount of overlap to include when dividing up the image. This value will almost always be the size (i.e. raduis) of the structuring element. If not specified then the amount of overlap is inferred from the size of the structuring element, in which case the
strel_argmust be specified.
divs (scalar or list of scalars (default = [2, 2, 2])) – The number of chunks to divide the image into in each direction. The default is 2 chunks in each direction, resulting in a quartering of the image and 8 total chunks (in 3D). A scalar is interpreted as applying to all directions, while a list of scalars is interpreted as applying to each individual direction.
cores (scalar) – The number of cores which should be used. By default, all cores will be used, or as many are needed for the given number of chunks, which ever is smaller.
im_arg (str) – The keyword used by
funcfor the image to be operated on. By default this function will look for
imwhich are commonly used by scipy.ndimage and skimage.
strel_arg (str) – The keyword used by
funcfor the structuring element to apply. This is only needed if
overlapis not specified. By default this function will look for
footprintwhich are commonly used by scipy.ndimage and skimage.
kwargs – All other arguments are passed to
funcas keyword arguments. Note that PoreSpy will fetch the image from this list of keywords using the value provided to
result – An image the same size as the input image, with the specified filter applied as though done on a single large image. There should be no difference.
- Return type:
This function divides the image into the specified number of chunks, but also applies a padding to each chunk to create an overlap with neighboring chunks. This way the operation does not have any edge artifacts. The amount of padding is usually equal to the radius of the structuring element but some functions do not use one, such as the distance transform and Gaussian blur. In these cases the user can specify
Click here to view online example.