imfun.bwmorph¶
- class imfun.bwmorph.RegionND(locs, shape)¶
Basic class for a contiguous region. Can make masks from it
- imfun.bwmorph.adaptive_threshold(arr, n=3, k=0)¶
Adaptive-thresholded binarization for an array.
- Parameters:
- arr: input array
- n: (int) – window half-size
- k: (number) – threshold will be at mean(window)-k
- Returns:
- mask: (array) – 1 where array > threshold, 0 otherwise
- imfun.bwmorph.contiguous_regions(binarr)¶
Given a binary Nd array, return a sorted (by size) list of contiguous regions (True everywhere) Version without recursion. Relies on scipy.ndimage.find_objects
- imfun.bwmorph.distance_regions(r1, r2, fn=<built-in function min>, start=1000000000.0)¶
Operate on pairwise distances between two regions if fn is =min=, smallest distance is returned, if fn is =max=, largest distance is returned
- imfun.bwmorph.distance_regions_centra(r1, r2)¶
Return distance between centroids of the two regions
- imfun.bwmorph.filter_density(mask, rad=3, size=5, fn=<function <lambda> at 0x7fcac6e4cd70>)¶
Density-based filter a binary mask.
Pixel is True if there are more than size pixels within a radius of rad from the pixel
- Parameters:
- mask: binary mask
- rad : neighborhood radius
- size: number of pixels required to be within the neighborhood
- fn : getter function, lambda m,i,j: m[i,j] by default
- Returns:
- filtered mask
- imfun.bwmorph.filter_mask(mask, fn, args=())¶
Split a mask into contiguous regions, filter them by a provided function, and return result as a mask
- imfun.bwmorph.filter_shape_regions(regions, th=2)¶
Filter contiguous regions (clusters) by circularity of shape
- imfun.bwmorph.filter_size_regions(regions, min_size=5)¶
Filter contiguous regions (clusters) by their size
- imfun.bwmorph.glue_adjacent_regions(regions, max_distance=10)¶
Go through a sequence of regions, for each pair of closely-spaced regions, unite the to make a single region. Return the new list
- imfun.bwmorph.locations(shape)¶
locations from a given shape (Cartesian product) as an iterator
- imfun.bwmorph.majority(bimage, th=5, mod=False)¶
Perform majority operation on the input binary image
- imfun.bwmorph.neighbours(loc, shape)¶
Return list of ajacent locations for a n-dimensional location
- Parameters:
- loc: (tuple) – location
- shape: (tuple) – shape of enclosing array
- Returns:
- list of `tuple`s
- imfun.bwmorph.neighbours_2(loc, shape)¶
Return list of adjacent locations
- imfun.bwmorph.neighbours_x(loc, shape)¶
Return list of ajacent locations for a n-dimensional location
- Parameters:
- loc: (tuple) – location
- shape: (tuple) – shape of enclosing array
- Returns:
- list of `tuple`s
- imfun.bwmorph.regions_overlap(r1, r2)¶
Test if two regions overlap
- imfun.bwmorph.unite_2regions(region1, region2)¶
Glue together two regions
- imfun.bwmorph.valid_loc(loc, shape)¶
Test if location not outside bounds