Module Expr Str Import alias identifier ImportFrom alias identifier ImportFrom alias alias alias FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareNotEq AttributeLoad NameLoad attr Num body Raise Call NameLoad Str If UnaryOpNot Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr TupleLoad Num Num body Raise Call NameLoad Str Return Call NameLoad NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr Num Num FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Global identifier If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Assign SubscriptStore NameLoad Index UnaryOpInvert NameLoad NameLoad Assign NameStore Call AttributeLoad BinOpBitAnd Call AttributeLoad NameLoad attr Num BinOpPow Num Num attr NameLoad Assign NameStore BinOpBitAnd NameLoad BinOpBitOr Call AttributeLoad NameLoad attr ListComp CompareNotEq SubscriptLoad Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Index Num SubscriptLoad Call AttributeLoad NameLoad attr Call NameLoad BinOpBitAnd NameLoad UnaryOpInvert BinOpPow Num Num NameLoad Index Num comprehension NameStore Call NameLoad Num Call AttributeLoad NameLoad attr ListComp CompareLt Call AttributeLoad NameLoad attr Call NameLoad NameLoad Num comprehension NameStore Call NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr ListComp BinOpSub Num Call AttributeLoad NameLoad attr Call NameLoad NameLoad comprehension NameStore Call NameLoad Num Assign NameStore Call NameLoad NameLoad NameLoad Assign TupleStore NameStore NameStore SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Num SubscriptLoad AttributeLoad NameLoad attr Index Num Slice Num SubscriptLoad AttributeLoad NameLoad attr Index Num Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr TupleLoad NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot CompareIs NameLoad NameLoad body Assign SubscriptStore NameLoad Index UnaryOpInvert NameLoad SubscriptLoad NameLoad Index UnaryOpInvert NameLoad If NameLoad body Return TupleLoad NameLoad NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr ListLoad ListLoad BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num ListLoad BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num ListLoad BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num BinOpBitAnd NameLoad BinOpPow Num Num NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If BoolOpOr CompareLt SubscriptLoad AttributeLoad NameLoad attr Index Num Num CompareLt SubscriptLoad AttributeLoad NameLoad attr Index Num Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice Num BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice Num BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Slice Num BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Slice BinOpMult SubscriptLoad NameLoad ExtSlice Slice Slice BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Slice Num BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice Num BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice BinOpPow Num Num AugAssignAdd SubscriptStore NameLoad ExtSlice Slice Num Slice Num BinOpMult SubscriptLoad NameLoad ExtSlice Slice Num Slice Num BinOpPow Num Num orelse Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Index NameLoad Return NameLoad decorator_list
N/A N/A 
Algorithms for computing the skeleton of a binary image
 N/A numpy np scipy ndimage ndi _skeletonize_cy _fast_skeletonize _skeletonize_loop _table_lookup_index skeletonize N/A N/A image N/A N/A N/A Return the skeleton of a binary image.

    Thinning is used to reduce each connected component in a binary image
    to a single-pixel wide skeleton.

    Parameters
    ----------
    image : numpy.ndarray
        A binary image containing the objects to be skeletonized. '1'
        represents foreground, and '0' represents background. It
        also accepts arrays of boolean values where True is foreground.

    Returns
    -------
    skeleton : ndarray
        A matrix containing the thinned image.

    See also
    --------
    medial_axis

    Notes
    -----
    The algorithm [1]_ works by making successive passes of the image,
    removing pixels on object borders. This continues until no
    more pixels can be removed.  The image is correlated with a
    mask that assigns each pixel a number in the range [0...255]
    corresponding to each possible pattern of its 8 neighbouring
    pixels. A look up table is then used to assign the pixels a
    value of 0, 1, 2 or 3, which are selectively removed during
    the iterations.

    Note that this algorithm will give different results than a
    medial axis transform, which is also often referred to as
    "skeletonization".

    References
    ----------
    .. [1] A fast parallel algorithm for thinning digital patterns,
           T. Y. Zhang and C. Y. Suen, Communications of the ACM,
           March 1984, Volume 27, Number 3.


    Examples
    --------
    >>> X, Y = np.ogrid[0:9, 0:9]
    >>> ellipse = (1./3 * (X - 4)**2 + (Y - 4)**2 < 3**2).astype(np.uint8)
    >>> ellipse
    array([[0, 0, 0, 1, 1, 1, 0, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 1, 1, 0, 0],
           [0, 0, 0, 1, 1, 1, 0, 0, 0]], dtype=uint8)
    >>> skel = skeletonize(ellipse)
    >>> skel.astype(np.uint8)
    array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

     N/A image N/A N/A image astype N/A np uint8 N/A N/A N/A image ndim 2 N/A N/A N/A ValueError Skeletonize requires a 2D array N/A N/A N/A N/A np all N/A N/A np in1d N/A image flat N/A 0 1 N/A N/A N/A ValueError Image contains values other than 0 and 1 N/A N/A _fast_skeletonize image N/A N/A _eight_connect N/A N/A ndi generate_binary_structure 2 2 medial_axis N/A N/A image mask return_distance N/A None False N/A N/A 
    Compute the medial axis transform of a binary image

    Parameters
    ----------
    image : binary ndarray, shape (M, N)
        The image of the shape to be skeletonized.
    mask : binary ndarray, shape (M, N), optional
        If a mask is given, only those elements in `image` with a true
        value in `mask` are used for computing the medial axis.
    return_distance : bool, optional
        If true, the distance transform is returned as well as the skeleton.

    Returns
    -------
    out : ndarray of bools
        Medial axis transform of the image
    dist : ndarray of ints, optional
        Distance transform of the image (only returned if `return_distance`
        is True)

    See also
    --------
    skeletonize

    Notes
    -----
    This algorithm computes the medial axis transform of an image
    as the ridges of its distance transform.

    The different steps of the algorithm are as follows
     * A lookup table is used, that assigns 0 or 1 to each configuration of
       the 3x3 binary square, whether the central pixel should be removed
       or kept. We want a point to be removed if it has more than one neighbor
       and if removing it does not change the number of connected components.

     * The distance transform to the background is computed, as well as
       the cornerness of the pixel.

     * The foreground (value of 1) points are ordered by
       the distance transform, then the cornerness.

     * A cython function is called to reduce the image to its skeleton. It
       processes pixels in the order determined at the previous step, and
       removes or maintains a pixel according to the lookup table. Because
       of the ordering, it is possible to process all pixels in only one
       pass.

    Examples
    --------
    >>> square = np.zeros((7, 7), dtype=np.uint8)
    >>> square[1:-1, 2:-2] = 1
    >>> square
    array([[0, 0, 0, 0, 0, 0, 0],
           [0, 0, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 0, 0],
           [0, 0, 1, 1, 1, 0, 0],
           [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
    >>> medial_axis(square).astype(np.uint8)
    array([[0, 0, 0, 0, 0, 0, 0],
           [0, 0, 1, 0, 1, 0, 0],
           [0, 0, 0, 1, 0, 0, 0],
           [0, 0, 0, 1, 0, 0, 0],
           [0, 0, 0, 1, 0, 0, 0],
           [0, 0, 1, 0, 1, 0, 0],
           [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)

     N/A _eight_connect N/A N/A mask None N/A N/A masked_image N/A N/A image astype N/A np bool N/A N/A masked_image N/A N/A N/A N/A image astype bool copy N/A N/A masked_image N/A N/A mask False N/A center_is_foreground N/A N/A N/A N/A N/A np arange 512 N/A 2 4 astype bool N/A table N/A center_is_foreground N/A N/A N/A np array N/A N/A N/A N/A N/A ndi label N/A _pattern_of index _eight_connect N/A 1 N/A N/A N/A ndi label N/A _pattern_of N/A index N/A N/A 2 4 _eight_connect N/A 1 N/A index N/A range 512 N/A N/A np array N/A N/A N/A N/A np sum N/A _pattern_of index 3 N/A index N/A range 512 N/A distance N/A N/A ndi distance_transform_edt masked_image N/A return_distance N/A N/A store_distance N/A N/A distance copy N/A cornerness_table N/A N/A np array N/A N/A 9 N/A N/A np sum N/A _pattern_of index N/A index N/A range 512 N/A corner_score N/A _table_lookup masked_image cornerness_table N/A N/A i j N/A N/A np mgrid N/A N/A 0 N/A N/A image shape N/A 0 N/A 0 N/A N/A image shape N/A 1 N/A result N/A N/A masked_image copy N/A distance N/A distance N/A result N/A i N/A N/A np ascontiguousarray N/A i N/A result dtype N/A np intp N/A j N/A N/A np ascontiguousarray N/A j N/A result dtype N/A np intp N/A result N/A N/A np ascontiguousarray result N/A np uint8 N/A generator N/A N/A N/A np random RandomState 0 N/A tiebreaker N/A N/A generator permutation N/A N/A np arange N/A N/A masked_image sum N/A order N/A N/A np lexsort N/A tiebreaker N/A corner_score N/A masked_image distance N/A order N/A N/A np ascontiguousarray order dtype N/A np int32 N/A table N/A N/A np ascontiguousarray table dtype N/A np uint8 N/A N/A _skeletonize_loop result i j order table N/A result N/A N/A result astype bool N/A N/A N/A mask None N/A N/A N/A result N/A N/A mask N/A image N/A N/A mask N/A return_distance N/A N/A N/A result store_distance N/A N/A result N/A _pattern_of N/A N/A index N/A N/A N/A 
    Return the pattern represented by an index value
    Byte decomposition of index
     N/A N/A N/A np array N/A N/A N/A index N/A 2 0 N/A index N/A 2 1 N/A index N/A 2 2 N/A N/A index N/A 2 3 N/A index N/A 2 4 N/A index N/A 2 5 N/A N/A index N/A 2 6 N/A index N/A 2 7 N/A index N/A 2 8 bool N/A _table_lookup N/A N/A image table N/A N/A N/A 
    Perform a morphological transform on an image, directed by its
    neighbors

    Parameters
    ----------
    image : ndarray
        A binary image
    table : ndarray
        A 512-element table giving the transform of each pixel given
        the values of that pixel and its 8-connected neighbors.
    border_value : bool
        The value of pixels beyond the border of the image.

    Returns
    -------
    result : ndarray of same shape as `image`
        Transformed image

    Notes
    -----
    The pixels are numbered like this::


      0 1 2
      3 4 5
      6 7 8

    The index at a pixel is the sum of 2**<pixel-number> for pixels
    that evaluate to true.
     N/A N/A N/A N/A N/A image shape N/A 0 3 N/A N/A N/A image shape N/A 1 3 N/A N/A image N/A N/A image astype bool N/A indexer N/A N/A np zeros N/A image shape int N/A N/A indexer N/A N/A 1 N/A 1 N/A N/A image N/A N/A -1 N/A -1 N/A 2 0 N/A N/A indexer N/A N/A 1 N/A N/A N/A image N/A N/A -1 N/A N/A 2 1 N/A N/A indexer N/A N/A 1 N/A -1 N/A N/A image N/A N/A -1 N/A 1 N/A 2 2 N/A N/A indexer N/A N/A N/A 1 N/A N/A image N/A N/A N/A -1 N/A 2 3 N/A N/A indexer N/A N/A N/A N/A N/A image N/A N/A N/A N/A 2 4 N/A N/A indexer N/A N/A N/A -1 N/A N/A image N/A N/A N/A 1 N/A 2 5 N/A N/A indexer N/A N/A -1 N/A 1 N/A N/A image N/A N/A 1 N/A -1 N/A 2 6 N/A N/A indexer N/A N/A -1 N/A N/A N/A image N/A N/A 1 N/A N/A 2 7 N/A N/A indexer N/A N/A -1 N/A -1 N/A N/A image N/A N/A 1 N/A 1 N/A 2 8 N/A N/A indexer N/A _table_lookup_index N/A N/A np ascontiguousarray image N/A np uint8 N/A image N/A table N/A indexer N/A image N/A