algorithms/asa.py
def _merge_adjacent_segments(mask):
    """
    Merges all segments in `mask` which are touching.
    """
    mask_ids = [id for id in np.unique(mask) if id != 0]
    for id in mask_ids:
        myfidxs, mysidxs = np.where(mask == id)
        for other in mask_ids:  # Ugh, brute force O(N^2) algorithm.. gross..
            if id == other:
                continue
            else:
                other_fidxs, other_sidxs = np.where(mask == other)
                if _segments_are_adjacent((myfidxs, mysidxs), (other_fidxs, other_sidxs)):
                    mask[other_fidxs, other_sidxs] = id
def _merge_adjacent_segments(mask):
    mask_ids = [id for id in np.unique(mask) if id != 0]
    for id in mask_ids:
        myfidxs, mysidxs = np.where(mask == id)
        for other in mask_ids:  # Ugh, brute force O(N^2) algorithm.. gross..
            if id == other:
                continue
            else:
                other_fidxs, other_sidxs = np.where(mask == other)
                if _segments_are_adjacent((myfidxs, mysidxs), (other_fidxs, other_sidxs)):
                    mask[other_fidxs, other_sidxs] = id
def _merge_adjacent_segments ( mask ) : mask_ids = [ id for id in np . unique ( mask ) if id != 0 ] for id in mask_ids : myfidxs , mysidxs = np . where ( mask == id ) for other in mask_ids : # Ugh, brute force O(N^2) algorithm.. gross.. if id == other : continue else : other_fidxs , other_sidxs = np . where ( mask == other ) if _segments_are_adjacent ( ( myfidxs , mysidxs ) , ( other_fidxs , other_sidxs ) ) : mask [ other_fidxs , other_sidxs ] = id
Merges all segments in `mask` which are touching.
Merges all segments in mask which are touching .