Previous topic

medpy.filter.binary.size_threshold

Next topic

medpy.filter.binary.bounding_box

This Page

medpy.filter.binary.largest_connected_component

medpy.filter.binary.largest_connected_component(img, structure=None)[source]

Select the largest connected binary component in an image.

Treats all zero values in the input image as background and all others as foreground. The return value is an binary array of equal dimensions as the input array with TRUE values where the largest connected component is situated.

Parameters:

img : array_like

An array containing connected objects. Will be cast to type numpy.bool.

structure : array_like

A structuring element that defines the connectivity. Structure must be symmetric. If no structuring element is provided, one is automatically generated with a squared connectivity equal to one.

Returns:

binary_image : ndarray

The supplied binary image with only the largest connected component remaining.