viqa.utils.find_largest_region¶
- viqa.utils.find_largest_region(img, iterations=5, region_type='cubic')[source]¶
Find the largest region in a binary image.
The function finds the largest region in a binary region by calculating the exact euclidean distance transform. The center and radius of the largest region are returned, as well as the region itself based on the given region type.
- Parameters:
img (np.ndarray) – Binary image
iterations (int, optional) – Number of iterations for dilation and erosion. Default is 5.
region_type ({'cubic', 'spherical', 'full', 'original'}, optional) –
Type of region to be found. Default is ‘cubic’. If ‘original’ the original image is returned. If ‘full’ the full region is returned (eroded twice after cleaning with dilation and erosion). If ‘cubic’ the region is returned as a cube. Alias for ‘cubic’ are ‘cube’ and ‘square’. If ‘spherical’ the region is returned as a sphere. Alias for ‘spherical’ are ‘sphere’ and ‘circle’. If other values are passed, the region is returned after dilation and erosion.
Note
This only influences the returned array, not the calculation of the largest region.
- Returns:
tuple – Coordinates of the largest region
int – Radius of the largest region
np.ndarray – Largest region as masked array