lib.dpt¶
ConnectedRegion¶
- class supreme.lib.dpt.ConnectedRegion¶
Bases: object
A 4 or 8-connected region is stored in a modified Compressed Sparse Row matrix format.
Since the region is connected, we only have to store one value. Along a single row, connected regions are stored as index pairs, e.g.
—00-000– would be represented as [3, 5, 6, 9]
This class should be queried using the methods in connected_region_handler.
Parameters: shape : tuple
Shape of the region.
Attributes
rowptr list of int rowptr[i] tells us where in colptr the elements of row i are described colptr list of int Always contains 2N elements, where N are the number of connected regions (see description above). Each entry describes the half-open interval (start_position, end_position]. - __init__()¶
- x.__init__(...) initializes x; see x.__class__.__doc__ for signature
supreme.lib.dpt.connected_regions | Return ConnectedRegions that, together, compose the whole image. |
supreme.lib.dpt.decompose | Decompose a two-dimensional signal into pulses. |
supreme.lib.dpt.reconstruct | Reconstruct an image from the given connected regions / pulses. |
connected_regions¶
- supreme.lib.dpt.connected_regions()¶
Return ConnectedRegions that, together, compose the whole image.
Parameters: img : ndarray
Input image.
Returns: labels : ndarray
img, labeled by connectivity.
c : dict
Dictionary of ConnectedRegions, indexed by label value.
decompose¶
- supreme.lib.dpt.decompose()¶
Decompose a two-dimensional signal into pulses.
Parameters: img : 2-D ndarray of ints
Input signal.
Returns: pulses : dict
Dictionary of ConnectedRegion objects, indexed by pulse area.
See also
reconstruct¶
- supreme.lib.dpt.reconstruct()¶
Reconstruct an image from the given connected regions / pulses.
Parameters: regions : dict
Impulses indexed by area. This is the output of decompose.
shape : tuple
Shape of the output image.
min_area, max_area : int
Impulses with areas in [min_area, max_area] are used for the reconstruction.
Returns: out : ndimage
Reconstructed image.
areas : 1d ndarray
Pulses with these areas occur in the image.
area_count : 1d ndarray
For each area in the above list, there are this many impulses.