
    0-Ph[                        d Z ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	lmZmZmZ dd
dZd Zd Z ej        g de          Z ej        g de          ZddZ ej        dd          addddZd Zd Zd ZdS )z9
Algorithms for computing the skeleton of a binary image
    N)ndimage   )check_nD)crop   )_compute_thin_image)_fast_skeletonize_skeletonize_loop_table_lookup_index)methodc                |   |                      t          dd          } |dvrt          d| d          | j        dk    r||d	k    rt	          |           }nd| j        d
k    r|d	k    rt          d          | j        d
k    s| j        dk    r|dk    rt          |           }nt          d| j         d          |S )a	  Compute the skeleton of the input image via thinning.

    Parameters
    ----------
    image : (M, N[, P]) ndarray of bool or int
        The image containing the objects to be skeletonized. Each connected component
        in the image is reduced to a single-pixel wide skeleton. The image is binarized
        prior to thinning; thus, adjacent objects of different intensities are
        considered as one. Zero or ``False`` values represent the background, nonzero
        or ``True`` values -- foreground.
    method : {'zhang', 'lee'}, optional
        Which algorithm to use. Zhang's algorithm [Zha84]_ only works for
        2D images, and is the default for 2D. Lee's algorithm [Lee94]_
        works for 2D or 3D images and is the default for 3D.

    Returns
    -------
    skeleton : (M, N[, P]) ndarray of bool
        The thinned image.

    See Also
    --------
    medial_axis

    References
    ----------
    .. [Lee94] T.-C. Lee, R.L. Kashyap and C.-N. Chu, Building skeleton models
           via 3-D medial surface/axis thinning algorithms.
           Computer Vision, Graphics, and Image Processing, 56(6):462-478, 1994.

    .. [Zha84] 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(bool)
    >>> ellipse.view(np.uint8)
    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.view(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)

    CFordercopy>   Nleezhangz:skeletonize method should be either "lee" or "zhang", got .r   Nr      z4skeletonize method "zhang" only works for 2D images.r   z4skeletonize requires a 2D or 3D image as input, got zD.)astypebool
ValueErrorndim_skeletonize_zhang_skeletonize_lee)imager   skeletons      _/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/morphology/_skeletonize.pyskeletonizer      s    | LLSuL55E+++VVVVV
 
 	
 zQFNf.?.?%e,,	qVw..RSSS	qUZ1__5#E**UuzUUU
 
 	
 O    c                 T    | j         dk    rt          d          t          |           S )a;	  Return the skeleton of a 2D binary image.

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

    Parameters
    ----------
    image : numpy.ndarray
        An image containing the objects to be skeletonized. Zeros or ``False``
        represent background, nonzero values or ``True`` are foreground.

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

    See Also
    --------
    medial_axis, skeletonize, thin

    Notes
    -----
    The algorithm [Zha84]_ 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 neighboring
    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
    ----------
    .. [Zha84] 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(bool)
    >>> ellipse.view(np.uint8)
    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.view(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)

    r   z.Zhang's skeletonize method requires a 2D array)r   r   r	   )r   s    r   r   r   c   s-    J zQIJJJU###r    c                    	
 d fdt          j        fdt          d          D                       } fdt          j        fdt          d          D                       }| |z  }fd	fd
t          j        	fd	t          d          D                       }t          j        
fd
t          d          D                       }||z  }||z  }||fS )z4generate LUTs for thinning algorithm (for reference)c                      t          j         fdt          dd          D                                           t                    S )Nc                      g | ]
}|z	  d z  S )r    ).0ins     r   
<listcomp>z5_generate_thin_luts.<locals>.nabe.<locals>.<listcomp>   s!    999a!999r    r   	   )nparrayranger   r   )r(   s   `r   nabez!_generate_thin_luts.<locals>.nabe   s>    x9999U1a[[999::AA$GGGr    c                     d} |           }dD ](}||         s||dz            s||dz   dz           r|dz  })|dk    S )Nr   )r   r         r   r      r%   )r(   sbitsr'   r.   s       r   G1z_generate_thin_luts.<locals>.G1   sf    tAww 	 	AG $q1u+ q1uk1B QAvr    c                 &    g | ]} |          S r%   r%   )r&   r(   r5   s     r   r)   z'_generate_thin_luts.<locals>.<listcomp>   !    111rr!uu111r       c                     d\  }} |           }dD ]5}||         s||dz
           r|dz  }||         s||dz   dz           r|dz  }6t          ||          dv S )N)r   r   )r   r         r   r2   )r   r   )min)r(   n1n2r4   kr.   s        r   G2z_generate_thin_luts.<locals>.G2   s    BtAww 	 	AAw $q1u+ aAw $A{+ a2r{{f$$r    c                 &    g | ]} |          S r%   r%   )r&   r(   r@   s     r   r)   z'_generate_thin_luts.<locals>.<listcomp>   r7   r    c                 ^     |           }|d         s|d         s	|d          o|d          S )Nr   r   r;   r   r%   r(   r4   r.   s     r   G3z_generate_thin_luts.<locals>.G3   :    tAww!W8Q8Q=Ed1gFFr    c                 ^     |           }|d         s|d         s	|d          o|d          S )Nr:   r1   r   r0   r%   rC   s     r   G3pz _generate_thin_luts.<locals>.G3p   rE   r    c                 &    g | ]} |          S r%   r%   )r&   r(   rD   s     r   r)   z'_generate_thin_luts.<locals>.<listcomp>   r7   r    c                 &    g | ]} |          S r%   r%   )r&   r(   rG   s     r   r)   z'_generate_thin_luts.<locals>.<listcomp>   s!    3331A333r    )r+   r,   r-   )g1_lutg2_lutg12_lutg3_lutg3p_lutg123_lut	g123p_lutr5   r@   rD   rG   r.   s          @@@@@r   _generate_thin_lutsrQ      s]   H H H     X1111eCjj11122F% % % % % X1111eCjj11122FvoGG G G G GG G G G G X1111eCjj11122Fh3333c

33344GH'!IYr    (   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dtype(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   c                    t          | d           t          j        | t                                                                        t          j                  }t          j        g dg dg dgt          j                  }|pt          j        }d}t          j        t          j	        |          }}||k    ro||k     ri|}t          t          fD ]3}t          j        ||d          }t          j        ||          }	d||	<   4t          j	        |          }|d	z  }||k    r||k     i|                    t                    S )
a	  
    Perform morphological thinning of a binary image.

    Parameters
    ----------
    image : binary (M, N) ndarray
        The image to thin. If this input isn't already a binary image,
        it gets converted into one: In this case, zero values are considered
        background (False), nonzero values are considered foreground (True).
    max_num_iter : int, number of iterations, optional
        Regardless of the value of this parameter, the thinned image
        is returned immediately if an iteration produces no change.
        If this parameter is specified it thus sets an upper bound on
        the number of iterations performed.

    Returns
    -------
    out : ndarray of bool
        Thinned image.

    See Also
    --------
    skeletonize, medial_axis

    Notes
    -----
    This algorithm [1]_ works by making multiple passes over the image,
    removing pixels matching a set of criteria designed to thin
    connected regions while preserving eight-connected components and
    2 x 2 squares [2]_. In each of the two sub-iterations the algorithm
    correlates the intermediate skeleton image with a neighborhood mask,
    then looks up each neighborhood in a lookup table indicating whether
    the central pixel should be deleted in that sub-iteration.

    References
    ----------
    .. [1] Z. Guo and R. W. Hall, "Parallel thinning with
           two-subiteration algorithms," Comm. ACM, vol. 32, no. 3,
           pp. 359-373, 1989. :DOI:`10.1145/62065.62074`
    .. [2] Lam, L., Seong-Whan Lee, and Ching Y. Suen, "Thinning
           Methodologies-A Comprehensive Survey," IEEE Transactions on
           Pattern Analysis and Machine Intelligence, Vol 14, No. 9,
           p. 879, 1992. :DOI:`10.1109/34.161346`

    Examples
    --------
    >>> square = np.zeros((7, 7), dtype=bool)
    >>> square[1:-1, 2:-2] = 1
    >>> square[0, 1] =  1
    >>> square.view(np.uint8)
    array([[0, 1, 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)
    >>> skel = thin(square)
    >>> skel.view(np.uint8)
    array([[0, 1, 0, 0, 0, 0, 0],
           [0, 0, 1, 0, 0, 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, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
    r   rR   )r2   r0   r   )   r   r   )    @      r   constant)moder   )r   r+   
asanyarrayr   r   viewuint8r,   infsumG123_LUT	G123P_LUTndi	correlatetaker   )
r   max_num_iterskelmasknum_iter	n_pts_old	n_pts_newlutNDs
             r   thinrn      s9   J UA =d+++002277AAD 8YYY


MMM:"(KKKD  )26LH626$<<yI
y
 
 X%<%<	 i( 	 	CdDz:::AQADGGF4LL	A y
 
 X%<%< ;;tr    F)rngc                   ||                      t                    }n2|                      t                                                    }d|| <   t          j        d          dz                       t                    }|t          j        d t          d          D                       t          j        d t          d          D                       z  z  }t          j        |          }|r|                                }t          j        d t          d          D                       }	t          ||	          }
t          j
        d| j        d         d| j        d	         f         \  }}|                                }||         }t          j        ||         t          j        
          }t          j        ||         t          j        
          }t          j        |t          j                  }t          j                            |          }|                    t          j        |                                                    }t          j        ||
|         |f          }t          j        |t          j        
          }t          j        |t          j        
          }t+          |||||           |                     t                    }|| |          || <   |r||fS |S )a  Compute the medial axis transform of a binary image.

    Parameters
    ----------
    image : binary ndarray, shape (M, N)
        The image of the shape to skeletonize. If this input isn't already a
        binary image, it gets converted into one: In this case, zero values are
        considered background (False), nonzero values are considered
        foreground (True).
    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.
    rng : {`numpy.random.Generator`, int}, optional
        Pseudo-random number generator.
        By default, a PCG64 generator is used (see :func:`numpy.random.default_rng`).
        If `rng` is an int, it is used to seed the generator.

        The PRNG determines the order in which pixels are processed for
        tiebreaking.

        .. versionadded:: 0.19

    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, thin

    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=bool)
    >>> square[1:-1, 2:-2] = 1
    >>> square.view(np.uint8)
    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).view(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)

    NFi   rU   c           	          g | ]a}t          j        t          |          t                    d          t          j        t          |dz            t                    d          k    bS )r   i)rb   label_pattern_of_eight_connectr&   indexs     r   r)   zmedial_axis.<locals>.<listcomp>  si         Ik%00.AA!DyUW_!=!=~NNqQR  r    c                 X    g | ]'}t          j        t          |                    d k     (S )r   r+   r_   rs   ru   s     r   r)   zmedial_axis.<locals>.<listcomp>  s/    OOO5{51122Q6OOOr    c                 V    g | ]&}d t          j        t          |                    z
  'S )r*   rx   ru   s     r   r)   zmedial_axis.<locals>.<listcomp>  s/    @@@ERVK&&''	'@@@r    r   r   rR   )r   r   r   r+   aranger,   r-   rb   distance_transform_edt_table_lookupmgridshapeascontiguousarrayintpr]   randomdefault_rngpermutationr_   lexsortint32r
   )r   rg   return_distancero   masked_imagecenter_is_foregroundtabledistancestore_distancecornerness_tablecorner_scorer'   jresult	generator
tiebreakerr   s                    r   medial_axisr   h  s   f |||D))||D))..00#dU IcNNT199$??H  "'s    hOOE#JJOOOPPQ
	
 
  ),77H )! x@@U3ZZ@@@  !/?@@L 8AA&EKN(::;DAq  FH
QvYbg666A
QvYbg666A!&"(33F 	%%c**I&&ry1A1A1C1C'D'DEEJJ
L$>IJJE bh777E bh777EfaE5111]]4  Fteu ~%%r    c                     t          j        | dz  | dz  | dz  g| dz  | dz  | dz  g| dz  | dz  | d	z  ggt                    S )
zZ
    Return the pattern represented by an index value
    Byte decomposition of index
    r   r   r0   r2   rU   rV   rW   rX   r8   )r+   r,   r   )rv   s    r   rs   rs     sd    
 8T\54<6T\54<6T\54<6	

 	  r    c                    | j         d         dk     s| j         d         dk     r|                     t                    } t          j        | j         t
                    }|ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         d	z  z  cc<   |ddddfxx         | ddddf         d
z  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   |ddddfxx         | ddddf         dz  z  cc<   n,t          t          j        | t          j                            }||         } | S )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.

    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.
    r   r   r   Nr   r0   r2   rU   rV   rW   rX   r8   )	r~   r   r   r+   zerosintr   r   r]   )r   r   indexers      r   r|   r|     sx   B {1~U[^a//T""(5;,,ABB5"crc?T11AAA%QQQ-$..CRCE#2#qrr'NT11122%3B3-$..111qqq!!!tt++3B35ABB<$..QRRE!""crc'NT11QQQ5QQQ<$..SbSU122qrr6]T11%b&:5"(&K&KLL'NELr    c                 n   | j         dk     s| j         dk    rt          d| j          d          |                     t          dd          }| j         dk    r|t          j        df         }t	          j        |d	d
          }t          |          }t          |d	          }| j         dk    r|d         }|S )a  Compute 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 : ndarray, 2D or 3D
        An image containing the objects to be skeletonized. Zeros or ``False``
        represent background, nonzero values or ``True`` are foreground.

    Returns
    -------
    skeleton : ndarray of bool
        The thinned image.

    See Also
    --------
    skeletonize, medial_axis

    Notes
    -----
    The method of [Lee94]_ uses an octree data structure to examine a 3x3x3
    neighborhood of a pixel. The algorithm proceeds by iteratively sweeping
    over the image, and removing pixels at each iteration until the image
    stops changing. Each iteration consists of two steps: first, a list of
    candidates for removal is assembled; then pixels from this list are
    rechecked sequentially, to better preserve connectivity of the image.

    The algorithm this function implements is different from the algorithms
    used by either `skeletonize` or `medial_axis`, thus for 2D images the
    results produced by this function are generally different.

    References
    ----------
    .. [Lee94] T.-C. Lee, R.L. Kashyap and C.-N. Chu, Building skeleton models
           via 3-D medial surface/axis thinning algorithms.
           Computer Vision, Graphics, and Image Processing, 56(6):462-478, 1994.

    r   r   z>skeletonize can only handle 2D or 3D images; got image.ndim = z	 instead.r   Fr   .r   rY   )	pad_widthrZ   )
crop_widthr   )	r   r   r   r   r+   newaxispadr   r   )r   image_os     r   r   r   O  s    T zA~~a6 %
6 6 6
 
 	

 ll4sl77G zQ"*c/*fW
;;;G "'**G 7q)))GzQ!*Nr    )N)NF)__doc__numpyr+   scipyr   rb   _shared.utilsr   utilr   _skeletonize_lee_cyr   _skeletonize_various_cyr	   r
   r   r   r   rQ   r,   r   r`   ra   rn   generate_binary_structurert   r   rs   r|   r   r%   r    r   <module>r      s                    $ $ $ $ $ $       4 4 4 4 4 4          "& N N N N NbG$ G$ G$Z, , ,` 28 0 0 0 8<= = = BH 1 1 1 9=> > >	"` ` ` `J /.q!44` ` ` ` ` `F  2 2 2j@ @ @ @ @r    