
    0-Ph                        d dl 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
 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 d	dlmZmZmZmZ g dZi ddddddddddddddddddddd d!d"d#d$d%d&d%d'd(d)d*d+d,i d-d,d.d/d0d/d1d2d3d2d4d5d6d7d8d9d:d;d<d=d>d=d?d@dAdBdCdBdDdEdFdEdGdHi dIdHdJdKdLdKdMdNdOdNdPdQdRdSdTdSdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedddfdfdgdgdhdhdididjdjdk
Zi dededed/edEedSede dedBedfedhed!e!dle!d#ed%ed(e d*ei d,ed7e!de!d2e!d=e!d9ed;edHedKedNedQed@e dVeded5edXedieeeee eeee!edm	Z"dn e"#                                D             Z$ e%e&                                          Z'doZ(dp Z)dq Z*dr Z+ds Z,dt Z- G du dv          Z.e.Z/ddyZ0	 	 ddzdxddd{d|Z1	 	 ddddd}d~Z2d Z3d Z4	  e4             dS )    Nwraps)atan2)pi)sqrt)warn)ndimage)pdist   )_moments)find_contours)marching_cubes)euler_number	perimeterperimeter_crofton_normalize_spacing)regionpropsr   r   r   AreaareaBoundingBoxbboxBoundingBoxArea	area_bbox	bbox_areaCentralMomentsmoments_centralCentroidcentroid
ConvexAreaarea_convexconvex_areaConvexImageimage_convexconvex_imageCoordinatescoordsEccentricityeccentricityEquivDiameterequivalent_diameter_areaequivalent_diameterEulerNumberr   ExtentextentFeretDiameterferet_diameter_maxFeretDiameterMax
FilledAreaarea_filledfilled_areaFilledImageimage_filledfilled_image	HuMoments
moments_huImageimageInertiaTensorinertia_tensorInertiaTensorEigvalsinertia_tensor_eigvalsIntensityImageimage_intensityintensity_imageLabellabelLocalCentroidcentroid_locallocal_centroidMajorAxisLengthaxis_major_lengthmajor_axis_lengthMaxIntensityintensity_maxmax_intensityMeanIntensityintensity_meanmean_intensityMinIntensityintensity_minmin_intensitystd_intensityintensity_stdMinorAxisLengthaxis_minor_lengthminor_axis_lengthMomentsmomentsNormalizedMomentsmoments_normalizedOrientationorientation	Perimeterr   CroftonPerimeterr   SlicesliceSoliditysolidityWeightedCentralMomentsmoments_weighted_centralweighted_moments_centralcentroid_weightedmoments_weighted_hucentroid_weighted_localmoments_weightedmoments_weighted_normalized)
WeightedCentroidweighted_centroidWeightedHuMomentsweighted_moments_huWeightedLocalCentroidweighted_local_centroidWeightedMomentsweighted_momentsWeightedNormalizedMomentsweighted_moments_normalizedcoords_scaled)	rf   ri   rl   
num_pixelsr^   r   r   rb   rd   c                 .    g | ]\  }}|t           k    |S  )object).0coldtypes      \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/measure/_regionprops.py
<listcomp>r      s!    NNN*#uevoo#ooo    )rA   rL   rO   rR   rU   rk   rf   rh   rj   ri   rl   c                     t          j        |           }t          |j                  }|j        |t          |j                  z  }|S )zInfer the number of required arguments for a function

    Parameters
    ----------
    func : callable
        The function that is being inspected.

    Returns
    -------
    n_args : int
        The number of required arguments of func.
    )inspectgetfullargspeclenargsdefaults)funcargspecn_argss      r   _infer_number_of_required_argsr      sF     $T**GF##g&'''Mr   c                   
 t          j        d|z  t                    }t          j        |dd          }t          j        d|z  t                    }t          j        |dd          }||g}t           j                                        
|rt                     dk    r 
fd	}n }t          ||          \  }}t          j        |          rt          j        |          s4t          j	        |          j
        t          j	        |          j
        k    rt          j	        |          j        j        }	nt           j        }	|	S )
a  Infer the dtype of a region property calculated by func.

    If a region property function always returns the same shape and type of
    output regardless of input size, then the dtype is the dtype of the
    returned array. Otherwise, the property has object dtype.

    Parameters
    ----------
    func : callable
        Function to be tested. The signature should be array[bool] -> Any if
        intensity is False, or *(array[bool], array[float]) -> Any otherwise.
    intensity : bool
        Whether the regionprop is calculated on an intensity image.
    ndim : int
        The number of dimensions for which to check func.

    Returns
    -------
    dtype : NumPy data type
        The data type of the returned property.
    r   r~   )r   r   F)constant_values)   )r   r   r   c                 L     |                      | j                            S N)randomshape)maskr   rngs    r   _funcz&_infer_regionprop_dtype.<locals>._func   s#    4cjj44555r   )nponesboolpadr   default_rngr   mapisscalararrayr   r~   typeobject_)r   	intensityndimmask_1mask_2	propmasksr   props1props2r~   r   s   `         @r   _infer_regionprop_dtyper      sE   , WTD[---FVFFE:::FWTD[---FVFFE:::F I
)


!
!C 3D99Q>>	6 	6 	6 	6 	6 	6 	6 	**NFF
FK 8F!RXf%5%5%;;;  &+
Lr   c                 <     t                      fd            }|S )Nc                 x    | j         }j        }| j        s |           S ||vr |           ||<   ||         S r   )_cache__name___cache_active)objcachepropfs      r   wrapperz_cached.<locals>.wrapper   sO    
z  	1S66Mu!C&&E$KT{r   r   )r   r   s   ` r   _cachedr      s3    
1XX
 
 
 
 X
 Nr   c                 <     t                      fd            }|S )Nc                 b    | j         dk    rt          dj         d           | g|R i |S )Nr   z	Property z! is not implemented for 3D images)_ndimNotImplementedErrorr   )selfr   kwargsmethods      r   func2dzonly2d.<locals>.func2d   sR    :>>%NFONNN   vd,T,,,V,,,r   r   )r   r   s   ` r   only2dr      s3    
6]]- - - - ]- Mr   c                     g }t          ddd          D ]Ot          fdt          |           D                       }|                    t	          d|z                       P|S )a>  Compute ellipsoid axis lengths from inertia tensor eigenvalues.

    Parameters
    ---------
    inertia_tensor_eigvals : sequence of float
        A sequence of 3 floating point eigenvalues, sorted in descending order.

    Returns
    -------
    axis_lengths : list of float
        The ellipsoid axis lengths sorted in descending order.

    Notes
    -----
    Let a >= b >= c be the ellipsoid semi-axes and s1 >= s2 >= s3 be the
    inertia tensor eigenvalues.

    The inertia tensor eigenvalues are given for a solid ellipsoid in [1]_.
    s1 = 1 / 5 * (a**2 + b**2)
    s2 = 1 / 5 * (a**2 + c**2)
    s3 = 1 / 5 * (b**2 + c**2)

    Rearranging to solve for a, b, c in terms of s1, s2, s3 gives
    a = math.sqrt(5 / 2 * ( s1 + s2 - s3))
    b = math.sqrt(5 / 2 * ( s1 - s2 + s3))
    c = math.sqrt(5 / 2 * (-s1 + s2 + s3))

    We can then simply replace sqrt(5/2) by sqrt(10) to get the full axes
    lengths rather than the semi-axes lengths.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/List_of_moments_of_inertia#List_of_3D_inertia_tensors
    r   c              3   8   K   | ]\  }}|k    r|d z  n|V  dS )r   Nrz   )r|   ivaxs      r   	<genexpr>z6_inertia_eigvals_to_axes_lengths_3D.<locals>.<genexpr>+  s7      WWTQ!r''BqWWWWWWr   
   )rangesum	enumerateappendr   )r?   axis_lengthswr   s      @r   #_inertia_eigvals_to_axes_lengths_3Dr     sx    F LAr2 * *WWWWY?U5V5VWWWWWDaLL))))r   c                   &    e Zd ZdZdddddZd Z fdZeed                         Z	eed                         Z
ed	             Zed
             Zed             Zeed                         Zeed                         Zed             Zed             Zeed                         Zed             Zed             Zed             Zed             Zed             Zeed                         Zeed                         Zeed                         Zeed                         Zeed                         Zd Zed             Zed             Z ed             Z!ed             Z"ed              Z#ed!             Z$ed"             Z%eed#                         Z&eed$                         Z'eed%                         Z(eed&                         Z)eed'                         Z*eed(                         Z+eed)                         Z,ed*             Z-ed+             Z.ed,             Z/eed-                         Z0eed.                         Z1eed/                         Z2eed0                         Z3d1 Z4d2 Z5d3 Z6 xZ7S )4RegionPropertieszoPlease refer to `skimage.measure.regionprops` for more information
    on the available region properties.
    Nextra_propertiesspacingoffsetc                6   |M|j         }	|j        d |	         |j        k    r|j         |	|	dz   fv st          d          |j        |j        k     }
nd}
|| _        |!t	          j        |j         ft                    }t	          j        |          | _        || _	        || _
        || _        || _        || _        i | _        |j         | _        |
| _        t#          t%          | j                            | _        |t	          j        | j        d          }t+          || j                  | _        t	          j        | j                  | _        i | _        |D|D ].}|j        }t7          | |          rd| d}t9          |           /d |D             | _        d S d S )	Nr   zLLabel and intensity image shapes must match, except for channel (last) axis.Fr         ?zExtra property 'zR' is shadowed by existing property and will be inaccessible. Consider renaming it.c                     i | ]
}|j         |S rz   r   )r|   r   s     r   
<dictcomp>z-RegionProperties.__init__.<locals>.<dictcomp>n  s    %W%W%WddmT%W%W%Wr   )r   r   
ValueErrorrD   r   zerosintr   _offset_slicerb   _label_image_intensity_imager   r   r   _multichanneltupler   _spatial_axesfullr   _spacingprod_pixel_area_extra_propertiesr   hasattrr   )r   rb   rD   label_imagerB   cache_activer   r   r   r   multichannelr   namemsgs                 r   __init__zRegionProperties.__init__5  s    &#D%ete,0AAA#(T4!8,<<< 7   ',/DDLL L
>X{/1===Fx''
' /) %
)"5#4#455?gdj#..G*7DJ??74=11!#'(  }4&& (4 ( ( ( 
 III%W%WFV%W%W%WD""" ('r   c                 :    |dk    r                      |          S  j        |t          v rt          d| d          | j        v rƉ j        |         t                    }|dk    rx j        _ j        rB fdt           j        j	        d                   D             }t          j        |d          S   j         j                  S t          d|           |d	k    r  j                  S t          d
| d| d          |t          v ra|                                |k    rI j        't          |         t          v rt          d| d          t           t          |                   S t          dt!                      d| d          )N__setstate__zAttribute 'z<' unavailable when `intensity_image` has not been specified.r   c                 L    g | ] } j         j        d |f                   !S .)r;   rA   )r|   r   r   r   s     r   r   z0RegionProperties.__getattr__.<locals>.<listcomp>  sC     - - - ! !DT-A#q&-IJJ- - -r   r   axisz&intensity image required to calculate r   zECustom regionprop function's number of arguments must be 1 or 2, but z takes z arguments.'z' object has no attribute ')__getattribute__r   _require_intensity_imageAttributeErrorr   r   r   r   rA   r   r   stackr;   PROPSlowergetattrr   )r   attrr   multichannel_listr   s   `   @r   __getattr__zRegionProperties.__getattr__p  s+   >!! ((... (T5M-M-M +d + + +   4))))$/D3D99F{{(4) F- - - - -%*4+?+Eb+I%J%J- - -)  "x(9CCCC#tDJ0DEEE(GGG   1tDJ'''$G&*G G39G G G   U]]tzz||t33%-$K#;;;$/$ / / /  
 4t--- !ST$ZZ!S!SD!S!S!STTTr   c                     |t           v r/t                                          t           |         |           d S t                                          ||           d S r   )r   super__setattr__)r   r   value	__class__s      r   r  zRegionProperties.__setattr__  sP    5==GGdU33333GGe,,,,,r   c                 4    t          j        | j                  S r   )r   r   r;   r   s    r   rx   zRegionProperties.num_pixels  s     vdj!!!r   c                 D    t          j        | j                  | j        z  S r   )r   r   r;   r   r  s    r   r   zRegionProperties.area  s     vdj!!D$444r   c                      t           fdt           j                  D              fdt           j                  D             z             S )z
        Returns
        -------
        A tuple of the bounding box's start coordinates for each dimension,
        followed by the end coordinates for each dimension
        c                 4    g | ]}j         |         j        S rz   rb   startr|   r   r   s     r   r   z)RegionProperties.bbox.<locals>.<listcomp>  s"    <<<QTZ] <<<r   c                 4    g | ]}j         |         j        S rz   )rb   stopr  s     r   r   z)RegionProperties.bbox.<locals>.<listcomp>  s"    ===atz!}!===r   )r   r   r   r  s   `r   r   zRegionProperties.bbox  s^     <<<<%
*;*;<<<====5+<+<===>
 
 	
r   c                 *    | j         j        | j        z  S r   )r;   sizer   r  s    r   r   zRegionProperties.area_bbox  s    z!111r   c                 R    t          | j                            d                    S Nr   r   )r   rw   meanr  s    r   r   zRegionProperties.centroid  s$    T',,!,44555r   c                 D    t          j        | j                  | j        z  S r   )r   r   r#   r   r  s    r   r    zRegionProperties.area_convex  s     vd'((4+;;;r   c                 .    ddl m}  || j                  S )Nr   )convex_hull_image)morphology.convex_hullr  r;   )r   r  s     r   r#   zRegionProperties.image_convex  s)     	?>>>>>  ,,,r   c                      t          j         j                  }t          j         fdt	           j                  D                       }||z    j        z   j        z   S )Nc                 4    g | ]}j         |         j        S rz   r	  r  s     r   r   z2RegionProperties.coords_scaled.<locals>.<listcomp>  "    !Q!Q!Q!$*Q-"5!Q!Q!Qr   )r   argwherer;   r   r   r   r   r   r   indicesobject_offsets   `  r   rw   zRegionProperties.coords_scaled  s[    +dj))!Q!Q!Q!QuTZ?P?P!Q!Q!QRR'4=84<GGr   c                      t          j         j                  }t          j         fdt	           j                  D                       }||z    j        z   S )Nc                 4    g | ]}j         |         j        S rz   r	  r  s     r   r   z+RegionProperties.coords.<locals>.<listcomp>  r  r   )r   r  r;   r   r   r   r   r  s   `  r   r&   zRegionProperties.coords  sT    +dj))!Q!Q!Q!QuTZ?P?P!Q!Q!QRRw&55r   c                 P    | j         \  }}|dk    rdS t          d||z  z
            S )Nr   r   )r?   r   )r   l1l2s      r   r(   zRegionProperties.eccentricity  s4     ,B771ARK   r   c                 L    d| j         z  | j        z  t          z  d| j         z  z  S )Nr   r   )r   r   PIr  s    r   r*   z)RegionProperties.equivalent_diameter_area  s%    DJ*R/Q^DDr   c                 f    | j         dvrt          d          t          | j        | j                   S )Nr      z4Euler number is implemented for 2D or 3D images only)r   r   r   r;   r  s    r   r   zRegionProperties.euler_number  s:    :V##%I   DJ
333r   c                      | j         | j        z  S r   )r   r   r  s    r   r.   zRegionProperties.extent  s    y4>))r   c                 P   t          j        | j        ddd          }| j        dk    r%t          j        t          |dd                    }n!| j        dk    rt          |d	          \  }}}}t          || j        z  d
          }t          t          j
        |                    S )Nr   constantr   )moder         ?high)fully_connectedr'  )levelsqeuclidean)r   r   r#   r   vstackr   r   r
   r   r   max)r   identity_convex_hullcoordinates_	distancess        r   r0   z#RegionProperties.feret_diameter_max  s    !vqz1 
  
  
 :??)2CPPP KK Z1__#12Fc#R#R#R KAq+5}EE	BF9%%&&&r   c                 D    t          j        | j                  | j        z  S r   )r   r   r6   r   r  s    r   r3   zRegionProperties.area_filled  s    vd'((4+;;;r   c                 n    t          j        d| j        z            }t          j        | j        |          S )Nr'  )r   r   r   ndibinary_fill_holesr;   )r   	structures     r   r6   zRegionProperties.image_filled  s/     GD4:-..	$TZ;;;r   c                 8    | j         | j                 | j        k    S r   )r   rb   rD   r  s    r   r;   zRegionProperties.image  s      ,
::r   c                 R    | j         }t          j        | j        || j                  S )Nr   )r   r   r=   r;   r   r   mus     r   r=   zRegionProperties.inertia_tensor  s(     !&tz2t}MMMMr   c                 B    t          j        | j        | j                  S )N)T)r   r?   r;   r=   r  s    r   r?   z'RegionProperties.inertia_tensor_eigvals  s     .tzT=PQQQQr   c                     | j         t          d          | j        s| j        nt	          j        | j        | j                  }| j         | j                 |z  S )NzNo intensity image specified.)r   r   r   r;   r   expand_dimsr   rb   )r   r;   s     r   rA   z RegionProperties.image_intensity"  s^      ( !@AAA %8DJJ
DJ77 	
 $TZ0588r   c                 N    | j                             t          j        d          S )NFcopy)rA   astyper   float64r  s    r   _image_intensity_doublez(RegionProperties._image_intensity_double.  s     #**2:E*BBBr   c                       j         d j        z            fdt          j        t	          fdt           j                  D                                 S )Nr   c                 6    d| z  dz   dj         dz
  | z
  z  z   S NrM  r   r   r   r   r   s    r   _get_elementz5RegionProperties.centroid_local.<locals>._get_element6  '    $;%
Q0E(FFFr   c              3   @   K   | ]} |                   z  V  d S r   rz   r|   r   MM0rR  s     r   r   z2RegionProperties.centroid_local.<locals>.<genexpr>:  7      KK!LL&&'",KKKKKKr   )rZ   r   r   asarrayr   r   r   rV  rW  rR  s   `@@@r   rF   zRegionProperties.centroid_local1  s    Ltdj !	G 	G 	G 	G 	G zKKKKKKtz9J9JKKKKK
 
 	
r   c                     | j         | j                 }t          j        |d                              t          j        d          S Nr   r   FrG  )rA   r;   r   r2  rI  rJ  r   valss     r   rL   zRegionProperties.intensity_max=  ;    #DJ/vd###**2:E*BBBr   c                 N    t          j        | j        | j                 d          S r  )r   r  rA   r;   r  s    r   rO   zRegionProperties.intensity_meanB  s!    wt+DJ7a@@@@r   c                     | j         | j                 }t          j        |d                              t          j        d          S r\  )rA   r;   r   minrI  rJ  r]  s     r   rR   zRegionProperties.intensity_minF  r_  r   c                 R    | j         | j                 }t          j        |d          S r  )rA   r;   r   stdr]  s     r   rU   zRegionProperties.intensity_stdK  s&    #DJ/vd####r   c                     | j         dk    r| j        d         }dt          |          z  S | j         dk    r1| j        }t          d|d         |d         z   |d         z
  z            S t          d          )Nr   r      r'  r   r   z-axis_major_length only available in 2D and 3Dr   r?   r   r   )r   r!  evs      r   rI   z"RegionProperties.axis_major_lengthP  st    :??,Q/BtBxx<Z1__,Bbebembe34555LMMMr   c                     | j         dk    r| j        d         }dt          |          z  S | j         dk    r2| j        }t          d|d          |d         z   |d         z   z            S t          d          )	Nr   r   rf  r'  r   r   r   z-axis_minor_length only available in 2D and 3Drg  )r   r"  rh  s      r   rW   z"RegionProperties.axis_minor_length\  sv    :??,R0BtBxx<Z1__,Br!ufr!unr!u45666LMMMr   c                     t          j        | j                            t          j                  d| j                  }|S Nr'  r?  )r   rZ   r;   rI  r   uint8r   )r   rV  s     r   rZ   zRegionProperties.momentsh  s4     TZ..rx88!T]SSSr   c                     t          j        | j                            t          j                  | j        d| j                  }|S )Nr'  orderr   )r   r   r;   rI  r   rl  rF   r   r@  s     r   r   z RegionProperties.moments_centraln  sE     %Jbh''M	
 
 
 	r   c                     t          d | j        D                       rt          d          t          j        | j                  S )Nc              3   "   K   | ]
}|d k    V  dS )r   Nrz   )r|   ss     r   r   z.RegionProperties.moments_hu.<locals>.<genexpr>|  s&      //AqCx//////r   +`moments_hu` supports spacing = (1, 1) only)anyr   r   r   r9   r\   r  s    r   r9   zRegionProperties.moments_huy  sI     /////// 	U%&STTT"4#:;;;r   c                 D    t          j        | j        d| j                  S rk  )r   r\   r   r   r  s    r   r\   z#RegionProperties.moments_normalized  s*     * !T]
 
 
 	
r   c                     | j         j        \  }}}}||z
  dk    r|dk     r
t          dz  S t           dz  S dt          d|z  ||z
            z  S )Nr   g      @r,  )r=   flatr$  r   )r   abcs       r   r^   zRegionProperties.orientation  s_     (-
1aq5A::1uuCxsSy rAvq1u----r   c                     t          t          j        | j                            dk    rt	          d          t          | j        d          | j        d         z  S Nr   z,`perimeter` supports isotropic spacings onlyrf  r   )r   r   uniquer   r   r   r;   r  s    r   r   zRegionProperties.perimeter  sP     ry''((A--%&TUUUQ''$-*:::r   c                     t          t          j        | j                            dk    rt	          d          t          | j        d          | j        d         z  S r}  )r   r   r~  r   r   r   r;   r  s    r   r   z"RegionProperties.perimeter_crofton  sP     ry''((A--%&TUUU Q//$-2BBBr   c                      | j         | j        z  S r   )r   r    r  s    r   rd   zRegionProperties.solidity  s    y4+++r   c                 t    | j         }t          d t          || j        | j                  D                       S )Nc              3   8   K   | ]\  }}}||j         |z  z   V  d S r   )r
  )r|   idxslcspcs       r   r   z5RegionProperties.centroid_weighted.<locals>.<genexpr>  sG       
 
S# #)c/!
 
 
 
 
 
r   )rj   r   ziprb   r   )r   ctrs     r   rh   z"RegionProperties.centroid_weighted  sH    * 
 
!$S$*dm!D!D
 
 
 
 
 	
r   c                       j         d j        z            fdt          j        t	          fdt           j                  D                                 S )NrM  c                 6    d| z  dz   dj         dz
  | z
  z  z   S rO  rP  rQ  s    r   rR  z>RegionProperties.centroid_weighted_local.<locals>._get_element  rS  r   c              3   @   K   | ]} |                   z  V  d S r   rz   rU  s     r   r   z;RegionProperties.centroid_weighted_local.<locals>.<genexpr>  rX  r   )rk   r   r   rY  r   r   rZ  s   `@@@r   rj   z(RegionProperties.centroid_weighted_local  s    !tdj !	G 	G 	G 	G 	G zKKKKKKtz9J9JKKKKK
 
 	
r   c                                                         j        r<t          j         fdt	          j        d                   D             d          }nt          j        d j                  }|S )Nc                 X    g | ]&}t          j        d |f         dj                  'S .r'  rn  )r   rZ   r   )r|   r   r;   r   s     r   r   z5RegionProperties.moments_weighted.<locals>.<listcomp>  sE        $U36]!T]SSS  r   r   r   r'  rn  )	rK  r   r   r   r   r   r   rZ   r   )r   rZ   r;   s   ` @r   rk   z!RegionProperties.moments_weighted  s     ,,.. 		Nh    "5;r?33     GG &uAt}MMMGr   c                      j                                           j        r? fdt          j        d                   D             }t          j        |d          }nt          j        d j	                  }|S )Nc                 j    g | ]/}t          j        d |f         d |f         dj                  0S ).r'  )centerro  r   )r   r   r   )r|   r   r  r;   r   s     r   r   z=RegionProperties.moments_weighted_central.<locals>.<listcomp>  sX         (#q&M#c1f+Q    r   r   r   r'  rn  )
rj   rK  r   r   r   r   r   r   r   r   )r   moments_listrZ   r  r;   s   `  @@r   rf   z)RegionProperties.moments_weighted_central  s     *,,.. 	      u{2//	  L h|"555GG.s!T]  G r   c                 n   t          j        | j                  t          j        ddg          k                                    st	          d          | j        | j        rA| j        j        d         }t          j	        fdt          |          D             d          S t          j                  S )Nr   rs  r   c                 H    g | ]}t          j        d |f                   S r   )r   r9   )r|   r   nus     r   r   z8RegionProperties.moments_weighted_hu.<locals>.<listcomp>  s,    KKKQ$RQZ00KKKr   r   )r   r   r   allr   rl   r   r   r   r   r   r   r9   )r   	nchannelsr  s     @r   ri   z$RegionProperties.moments_weighted_hu  s     ''28QF+;+;;@@BB 	U%&STTT- 	+-3B7I8KKKK%	:J:JKKK   
 &r***r   c                       j          j        rB j        j        d         }t	          j         fdt          |          D             d          S t          j        d j	                  S )Nr   c                 X    g | ]&}t          j        d |f         dj                  'S r  )r   r\   r   )r|   r   rA  r   s     r   r   z@RegionProperties.moments_weighted_normalized.<locals>.<listcomp>  sN         /36
!T]    r   r   r'  rn  )
rf   r   r   r   r   r   r   r   r\   r   )r   r  rA  s   ` @r   rl   z,RegionProperties.moments_weighted_normalized  s     * 	S-3B7I8     #9--	       .rDMRRRRr   c                     t           }| j        t          }|                    |          }t	          t          |                    S r   )	PROP_VALSr   r   
differenceitersorted)r   propsunavailable_propss      r   __iter__zRegionProperties.__iter__  s>     ( 8$$%677EF5MM"""r   c                 b    t          | |d           }||S t          | t          |                   S r   )r   r   )r   keyr  s      r   __getitem__zRegionProperties.__getitem__  s2    c4((L4s,,,r   c           	          t          |t                    sdS t          D ]S}	 t          j                            t          | |d           t          ||d                      B# t          $ r Y  dS w xY wdS )NFT)
isinstancer   r  r   testingassert_equalr   AssertionError)r   otherr  s      r   __eq__zRegionProperties.__eq__  s    %!122 	5 	 	C
''D#t,,geS$.G.G    "   uuu ts   >A!!
A0/A0)8r   
__module____qualname____doc__r   r   r  propertyr   rx   r   r   r   r   r    r#   rw   r&   r   r(   r*   r   r.   r0   r3   r6   r;   r=   r?   rA   rK  rF   rL   rO   rR   rU   rI   rW   rZ   r   r9   r\   r^   r   r   rd   rh   rj   rk   rf   ri   rl   r  r  r  __classcell__)r  s   @r   r   r   0  s         9X 9X 9X 9X 9Xv3U 3U 3Uj- - - - - " " W X" 5 5 W X5 

 

 X

 2 2 X2 6 6 X6 < < W X< - - W X-
 H H XH
 6 6 X6
 ! ! V X! E E XE 4 4 X4 * * X* ' ' X' < < X< < < W X< ; ; W X; N N W XN R R W XR 9 9 W X9C C C 	
 	
 X	
 C C XC A A XA C C XC $ $ X$ 	N 	N X	N 	N 	N X	N   W X   W X < < V X<
 
 
 W X

 . . V X. ; ; V X;
 C C V XC
 , , X, 
 
 X
 	
 	
 X	
   W X   W X" + + V X+ S S W XS # # #- - -      r   r   rD   r   -c                    i }t          |           }|D ]6}| d         }|}t                              ||          }t          ||          }|t          v rt          |         }	n0|j        |         }
t          |
|j        du|j        j	                  }	t          j        |          s|t          v s|	t          j        u rQt          j        ||	          }t          |          D ]}| |         |         ||<   t          j        |          ||<   g }g }t          j        t          j        |                    D ]q}|                    |                    t+          t,          |f|z                                  |                    t          |          dk    r|n|d                    rt          |          }t          j        ||f|	          }t          |          D ]D}t          j        | |         |                   }t1          |          D ]\  }}||         |||f<   Et1          |          D ]\  }}|dd|f         ||<   8|S )a4  Convert image region properties list into a column dictionary.

    Parameters
    ----------
    regions : (K,) list
        List of RegionProperties objects as returned by :func:`regionprops`.
    properties : tuple or list of str, optional
        Properties that will be included in the resulting dictionary
        For a list of available properties, please see :func:`regionprops`.
        Users should remember to add "label" to keep track of region
        identities.
    separator : str, optional
        For non-scalar properties not listed in OBJECT_COLUMNS, each element
        will appear in its own column, with the index of that element separated
        from the property name by this separator. For example, the inertia
        tensor of a 2D region will appear in four columns:
        ``inertia_tensor-0-0``, ``inertia_tensor-0-1``, ``inertia_tensor-1-0``,
        and ``inertia_tensor-1-1`` (where the separator is ``-``).

        Object columns are those that cannot be split in this way because the
        number of columns would change depending on the object. For example,
        ``image`` and ``coords``.

    Returns
    -------
    out_dict : dict
        Dictionary mapping property names to an array of values of that
        property, one value per region. This dictionary can be used as input to
        pandas ``DataFrame`` to map property names to columns in the frame and
        regions to rows.

    Notes
    -----
    Each column contains either a scalar property, an object property, or an
    element in a multidimensional array.

    Properties with scalar values for each region, such as "eccentricity", will
    appear as a float or int array with that property name as key.

    Multidimensional properties *of fixed size* for a given image dimension,
    such as "centroid" (every centroid will have three elements in a 3D image,
    no matter the region size), will be split into that many columns, with the
    name {property_name}{separator}{element_num} (for 1D properties),
    {property_name}{separator}{elem_num0}{separator}{elem_num1} (for 2D
    properties), and so on.

    For multidimensional properties that don't have a fixed size, such as
    "image" (the image of a region varies in size depending on the region
    size), an object array will be used, with the corresponding property name
    as the key.

    Examples
    --------
    >>> from skimage import data, util, measure
    >>> image = data.coins()
    >>> label_image = measure.label(image > 110, connectivity=image.ndim)
    >>> proplist = regionprops(label_image, image)
    >>> props = _props_to_dict(proplist, properties=['label', 'inertia_tensor',
    ...                                              'inertia_tensor_eigvals'])
    >>> props  # doctest: +ELLIPSIS +SKIP
    {'label': array([ 1,  2, ...]), ...
     'inertia_tensor-0-0': array([  4.012...e+03,   8.51..., ...]), ...
     ...,
     'inertia_tensor_eigvals-1': array([  2.67...e+02,   2.83..., ...])}

    The resulting dictionary can be directly passed to pandas, if installed, to
    obtain a clean DataFrame:

    >>> import pandas as pd  # doctest: +SKIP
    >>> data = pd.DataFrame(props)  # doctest: +SKIP
    >>> data.head()  # doctest: +SKIP
       label  inertia_tensor-0-0  ...  inertia_tensor_eigvals-1
    0      1         4012.909888  ...                267.065503
    1      2            8.514739  ...                  2.834806
    2      3            0.666667  ...                  0.000000
    3      4            0.000000  ...                  0.000000
    4      5            0.222222  ...                  0.111111

    r   N)r   r   r   r   )r   r   getr   
COL_DTYPESr   r   r   r;   r   r   r   OBJECT_COLUMNSr   emptyr   rH  ndindexr   r   joinr   strrY  r   )regions
properties	separatoroutnr   r	orig_proprpr~   r   column_bufferr   modified_propslocsind	n_columnscolumn_dataklocmodified_props                        r   _props_to_dictr  !  sq   b CGA .7 .7AJ 	yyt$$Q:t$EE&t,D+,D8W\  E ;r?? 	7dn448K8KHQe444M1XX 4 4#*1:d#3a  W]33C	NN  NDz"(2,,// = =%%innSylS>P5Q5Q&R&RSSS3s88a<<CCSV<<<< D		I(Ay>???K1XX 0 0 Z
4 011'oo 0 0FAs(*3K1%%0 %.n$=$= 7 7 =%0A%6M""7Jr   T)r   r  r   r   c                   t          | ||||          }|t          |          d |D             z   }t          |          dk    r| j        }t	          j        d|z  t                    } d| d|z  <   |0t	          j        | j        |j        |d         z   |j                  }t          | ||||          }t          |||	          }	d
 |	
                                D             S t          |||	          S )a  Compute image properties and return them as a pandas-compatible table.

    The table is a dictionary mapping column names to value arrays. See Notes
    section below for details.

    .. versionadded:: 0.16

    Parameters
    ----------
    label_image : (M, N[, P]) ndarray
        Labeled input image. Labels with value 0 are ignored.
    intensity_image : (M, N[, P][, C]) ndarray, optional
        Intensity (i.e., input) image with same size as labeled image, plus
        optionally an extra dimension for multichannel data. The channel dimension,
        if present, must be the last axis. Default is None.

        .. versionchanged:: 0.18.0
            The ability to provide an extra dimension for channels was added.
    properties : tuple or list of str, optional
        Properties that will be included in the resulting dictionary
        For a list of available properties, please see :func:`regionprops`.
        Users should remember to add "label" to keep track of region
        identities.
    cache : bool, optional
        Determine whether to cache calculated properties. The computation is
        much faster for cached properties, whereas the memory consumption
        increases.
    separator : str, optional
        For non-scalar properties not listed in OBJECT_COLUMNS, each element
        will appear in its own column, with the index of that element separated
        from the property name by this separator. For example, the inertia
        tensor of a 2D region will appear in four columns:
        ``inertia_tensor-0-0``, ``inertia_tensor-0-1``, ``inertia_tensor-1-0``,
        and ``inertia_tensor-1-1`` (where the separator is ``-``).

        Object columns are those that cannot be split in this way because the
        number of columns would change depending on the object. For example,
        ``image`` and ``coords``.
    extra_properties : Iterable of callables
        Add extra property computation functions that are not included with
        skimage. The name of the property is derived from the function name,
        the dtype is inferred by calling the function on a small sample.
        If the name of an extra property clashes with the name of an existing
        property the extra property will not be visible and a UserWarning is
        issued. A property computation function must take a region mask as its
        first argument. If the property requires an intensity image, it must
        accept the intensity image as the second argument.
    spacing: tuple of float, shape (ndim,)
        The pixel spacing along each axis of the image.

    Returns
    -------
    out_dict : dict
        Dictionary mapping property names to an array of values of that
        property, one value per region. This dictionary can be used as input to
        pandas ``DataFrame`` to map property names to columns in the frame and
        regions to rows. If the image has no regions,
        the arrays will have length 0, but the correct type.

    Notes
    -----
    Each column contains either a scalar property, an object property, or an
    element in a multidimensional array.

    Properties with scalar values for each region, such as "eccentricity", will
    appear as a float or int array with that property name as key.

    Multidimensional properties *of fixed size* for a given image dimension,
    such as "centroid" (every centroid will have three elements in a 3D image,
    no matter the region size), will be split into that many columns, with the
    name {property_name}{separator}{element_num} (for 1D properties),
    {property_name}{separator}{elem_num0}{separator}{elem_num1} (for 2D
    properties), and so on.

    For multidimensional properties that don't have a fixed size, such as
    "image" (the image of a region varies in size depending on the region
    size), an object array will be used, with the corresponding property name
    as the key.

    Examples
    --------
    >>> from skimage import data, util, measure
    >>> image = data.coins()
    >>> label_image = measure.label(image > 110, connectivity=image.ndim)
    >>> props = measure.regionprops_table(label_image, image,
    ...                           properties=['label', 'inertia_tensor',
    ...                                       'inertia_tensor_eigvals'])
    >>> props  # doctest: +ELLIPSIS +SKIP
    {'label': array([ 1,  2, ...]), ...
     'inertia_tensor-0-0': array([  4.012...e+03,   8.51..., ...]), ...
     ...,
     'inertia_tensor_eigvals-1': array([  2.67...e+02,   2.83..., ...])}

    The resulting dictionary can be directly passed to pandas, if installed, to
    obtain a clean DataFrame:

    >>> import pandas as pd  # doctest: +SKIP
    >>> data = pd.DataFrame(props)  # doctest: +SKIP
    >>> data.head()  # doctest: +SKIP
       label  inertia_tensor-0-0  ...  inertia_tensor_eigvals-1
    0      1         4012.909888  ...                267.065503
    1      2            8.514739  ...                  2.834806
    2      3            0.666667  ...                  0.000000
    3      4            0.000000  ...                  0.000000
    4      5            0.222222  ...                  0.111111

    [5 rows x 7 columns]

    If we want to measure a feature that does not come as a built-in
    property, we can define custom functions and pass them as
    ``extra_properties``. For example, we can create a custom function
    that measures the intensity quartiles in a region:

    >>> from skimage import data, util, measure
    >>> import numpy as np
    >>> def quartiles(regionmask, intensity):
    ...     return np.percentile(intensity[regionmask], q=(25, 50, 75))
    >>>
    >>> image = data.coins()
    >>> label_image = measure.label(image > 110, connectivity=image.ndim)
    >>> props = measure.regionprops_table(label_image, intensity_image=image,
    ...                                   properties=('label',),
    ...                                   extra_properties=(quartiles,))
    >>> import pandas as pd # doctest: +SKIP
    >>> pd.DataFrame(props).head() # doctest: +SKIP
           label  quartiles-0  quartiles-1  quartiles-2
    0      1       117.00        123.0        130.0
    1      2       111.25        112.0        114.0
    2      3       111.00        111.0        111.0
    3      4       111.00        111.5        112.5
    4      5       112.50        113.0        114.0

    )rB   r   r   r   Nc                     g | ]	}|j         
S rz   r   )r|   r   s     r   r   z%regionprops_table.<locals>.<listcomp>=  s    (T(T(T4(T(T(Tr   r   r9  r   r   r   )r  r  c                 *    i | ]\  }}||d d         S )Nr   rz   )r|   r  r   s      r   r   z%regionprops_table.<locals>.<dictcomp>P  s&    333TQ1RaR5333r   )r   listr   r   r   r   r   r   r~   r  items)
r   rB   r  r   r  r   r   r  r   out_ds
             r   regionprops_tabler    s6   ^ ')  G #*%%(T(TCS(T(T(TT

7||qhtd{#666#$D4K & h!O$9$%%$@@%+  O +-
 
 
 w:SSS33U[[]]3333'jINNNNr   r   c                   | j         dvrt          d          t          j        | j        t          j                  s=t          j        | j        t                    rt          d          t          d          |"t          j        | j         ft                    }nBt          j	        |          }|j         dk    s|j
        | j         k    rt          d| d	          g }t          j        |           }t          |          D ]9\  }	}
|
|	dz   }t          |
|| |||||
          }|                    |           :|S )u*  Measure properties of labeled image regions.

    Parameters
    ----------
    label_image : (M, N[, P]) ndarray
        Labeled input image. Labels with value 0 are ignored.

        .. versionchanged:: 0.14.1
            Previously, ``label_image`` was processed by ``numpy.squeeze`` and
            so any number of singleton dimensions was allowed. This resulted in
            inconsistent handling of images with singleton dimensions. To
            recover the old behaviour, use
            ``regionprops(np.squeeze(label_image), ...)``.
    intensity_image : (M, N[, P][, C]) ndarray, optional
        Intensity (i.e., input) image with same size as labeled image, plus
        optionally an extra dimension for multichannel data. Currently,
        this extra channel dimension, if present, must be the last axis.
        Default is None.

        .. versionchanged:: 0.18.0
            The ability to provide an extra dimension for channels was added.
    cache : bool, optional
        Determine whether to cache calculated properties. The computation is
        much faster for cached properties, whereas the memory consumption
        increases.
    extra_properties : Iterable of callables
        Add extra property computation functions that are not included with
        skimage. The name of the property is derived from the function name,
        the dtype is inferred by calling the function on a small sample.
        If the name of an extra property clashes with the name of an existing
        property the extra property will not be visible and a UserWarning is
        issued. A property computation function must take a region mask as its
        first argument. If the property requires an intensity image, it must
        accept the intensity image as the second argument.
    spacing: tuple of float, shape (ndim,)
        The pixel spacing along each axis of the image.
    offset : array-like of int, shape `(label_image.ndim,)`, optional
        Coordinates of the origin ("top-left" corner) of the label image.
        Normally this is ([0, ]0, 0), but it might be different if one wants
        to obtain regionprops of subvolumes within a larger volume.

    Returns
    -------
    properties : list of RegionProperties
        Each item describes one labeled region, and can be accessed using the
        attributes listed below.

    Notes
    -----
    The following properties can be accessed as attributes or keys:

    **area** : float
        Area of the region i.e. number of pixels of the region scaled by pixel-area.
    **area_bbox** : float
        Area of the bounding box i.e. number of pixels of bounding box scaled by pixel-area.
    **area_convex** : float
        Area of the convex hull image, which is the smallest convex
        polygon that encloses the region.
    **area_filled** : float
        Area of the region with all the holes filled in.
    **axis_major_length** : float
        The length of the major axis of the ellipse that has the same
        normalized second central moments as the region.
    **axis_minor_length** : float
        The length of the minor axis of the ellipse that has the same
        normalized second central moments as the region.
    **bbox** : tuple
        Bounding box ``(min_row, min_col, max_row, max_col)``.
        Pixels belonging to the bounding box are in the half-open interval
        ``[min_row; max_row)`` and ``[min_col; max_col)``.
    **centroid** : array
        Centroid coordinate tuple ``(row, col)``.
    **centroid_local** : array
        Centroid coordinate tuple ``(row, col)``, relative to region bounding
        box.
    **centroid_weighted** : array
        Centroid coordinate tuple ``(row, col)`` weighted with intensity
        image.
    **centroid_weighted_local** : array
        Centroid coordinate tuple ``(row, col)``, relative to region bounding
        box, weighted with intensity image.
    **coords_scaled** : (K, 2) ndarray
        Coordinate list ``(row, col)`` of the region scaled by ``spacing``.
    **coords** : (K, 2) ndarray
        Coordinate list ``(row, col)`` of the region.
    **eccentricity** : float
        Eccentricity of the ellipse that has the same second-moments as the
        region. The eccentricity is the ratio of the focal distance
        (distance between focal points) over the major axis length.
        The value is in the interval [0, 1).
        When it is 0, the ellipse becomes a circle.
    **equivalent_diameter_area** : float
        The diameter of a circle with the same area as the region.
    **euler_number** : int
        Euler characteristic of the set of non-zero pixels.
        Computed as number of connected components subtracted by number of
        holes (input.ndim connectivity). In 3D, number of connected
        components plus number of holes subtracted by number of tunnels.
    **extent** : float
        Ratio of pixels in the region to pixels in the total bounding box.
        Computed as ``area / (rows * cols)``
    **feret_diameter_max** : float
        Maximum Feret's diameter computed as the longest distance between
        points around a region's convex hull contour as determined by
        ``find_contours``. [5]_
    **image** : (H, J) ndarray
        Sliced binary region image which has the same size as bounding box.
    **image_convex** : (H, J) ndarray
        Binary convex hull image which has the same size as bounding box.
    **image_filled** : (H, J) ndarray
        Binary region image with filled holes which has the same size as
        bounding box.
    **image_intensity** : ndarray
        Image inside region bounding box.
    **inertia_tensor** : ndarray
        Inertia tensor of the region for the rotation around its mass.
    **inertia_tensor_eigvals** : tuple
        The eigenvalues of the inertia tensor in decreasing order.
    **intensity_max** : float
        Value with the greatest intensity in the region.
    **intensity_mean** : float
        Value with the mean intensity in the region.
    **intensity_min** : float
        Value with the least intensity in the region.
    **intensity_std** : float
        Standard deviation of the intensity in the region.
    **label** : int
        The label in the labeled input image.
    **moments** : (3, 3) ndarray
        Spatial moments up to 3rd order::

            m_ij = sum{ array(row, col) * row^i * col^j }

        where the sum is over the `row`, `col` coordinates of the region.
    **moments_central** : (3, 3) ndarray
        Central moments (translation invariant) up to 3rd order::

            mu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }

        where the sum is over the `row`, `col` coordinates of the region,
        and `row_c` and `col_c` are the coordinates of the region's centroid.
    **moments_hu** : tuple
        Hu moments (translation, scale and rotation invariant).
    **moments_normalized** : (3, 3) ndarray
        Normalized moments (translation and scale invariant) up to 3rd order::

            nu_ij = mu_ij / m_00^[(i+j)/2 + 1]

        where `m_00` is the zeroth spatial moment.
    **moments_weighted** : (3, 3) ndarray
        Spatial moments of intensity image up to 3rd order::

            wm_ij = sum{ array(row, col) * row^i * col^j }

        where the sum is over the `row`, `col` coordinates of the region.
    **moments_weighted_central** : (3, 3) ndarray
        Central moments (translation invariant) of intensity image up to
        3rd order::

            wmu_ij = sum{ array(row, col) * (row - row_c)^i * (col - col_c)^j }

        where the sum is over the `row`, `col` coordinates of the region,
        and `row_c` and `col_c` are the coordinates of the region's weighted
        centroid.
    **moments_weighted_hu** : tuple
        Hu moments (translation, scale and rotation invariant) of intensity
        image.
    **moments_weighted_normalized** : (3, 3) ndarray
        Normalized moments (translation and scale invariant) of intensity
        image up to 3rd order::

            wnu_ij = wmu_ij / wm_00^[(i+j)/2 + 1]

        where ``wm_00`` is the zeroth spatial moment (intensity-weighted area).
    **num_pixels** : int
        Number of foreground pixels.
    **orientation** : float
        Angle between the 0th axis (rows) and the major
        axis of the ellipse that has the same second moments as the region,
        ranging from `-pi/2` to `pi/2` counter-clockwise.
    **perimeter** : float
        Perimeter of object which approximates the contour as a line
        through the centers of border pixels using a 4-connectivity.
    **perimeter_crofton** : float
        Perimeter of object approximated by the Crofton formula in 4
        directions.
    **slice** : tuple of slices
        A slice to extract the object from the source image.
    **solidity** : float
        Ratio of pixels in the region to pixels of the convex hull image.

    Each region also supports iteration, so that you can do::

      for prop in region:
          print(prop, region[prop])

    See Also
    --------
    label

    References
    ----------
    .. [1] Wilhelm Burger, Mark Burge. Principles of Digital Image Processing:
           Core Algorithms. Springer-Verlag, London, 2009.
    .. [2] B. Jähne. Digital Image Processing. Springer-Verlag,
           Berlin-Heidelberg, 6. edition, 2005.
    .. [3] T. H. Reiss. Recognizing Planar Objects Using Invariant Image
           Features, from Lecture notes in computer science, p. 676. Springer,
           Berlin, 1993.
    .. [4] https://en.wikipedia.org/wiki/Image_moment
    .. [5] W. Pabst, E. Gregorová. Characterization of particles and particle
           systems, pp. 27-28. ICT Prague, 2007.
           https://old.vscht.cz/sil/keramika/Characterization_of_particles/CPPS%20_English%20version_.pdf

    Examples
    --------
    >>> from skimage import data, util
    >>> from skimage.measure import label, regionprops
    >>> img = util.img_as_ubyte(data.coins()) > 110
    >>> label_img = label(img, connectivity=img.ndim)
    >>> props = regionprops(label_img)
    >>> # centroid of first labeled object
    >>> props[0].centroid
    (22.72987986048314, 81.91228523446583)
    >>> # centroid of first labeled object
    >>> props[0]['centroid']
    (22.72987986048314, 81.91228523446583)

    Add custom measurements by passing functions as ``extra_properties``

    >>> from skimage import data, util
    >>> from skimage.measure import label, regionprops
    >>> import numpy as np
    >>> img = util.img_as_ubyte(data.coins()) > 110
    >>> label_img = label(img, connectivity=img.ndim)
    >>> def pixelcount(regionmask):
    ...     return np.sum(regionmask)
    >>> props = regionprops(label_img, extra_properties=(pixelcount,))
    >>> props[0].pixelcount
    7741
    >>> props[1]['pixelcount']
    42

    r&  z"Only 2-D and 3-D images supported.zNon-integer image types are ambiguous: use skimage.measure.label to label the connected components of label_image, or label_image.astype(np.uint8) to interpret the True values as a single label.z+Non-integer label_image types are ambiguousNr   r   zIOffset should be an array-like of integers of shape (label_image.ndim,); z was provided.)r   r   r   )r   	TypeErrorr   
issubdtyper~   integerr   r   r   rY  r  r   r:  find_objectsr   r   r   )r   rB   r   r   r   r   
offset_arrr  objectsr   slrD   r  s                r   r   r   U  s|   | v%%<====*BJ77 
K=*D11 		K5   IJJJ~X{/1===

Z''
?a:?k6F#F#F** * *   G{++G7##  2:A -	
 	
 	
 	uNr   c                      dd l } dd lt          j        pd}d}t          j        dk    rd}|                     ||| j                  }fd|D             }|S )Nr    z+\*\*(\w+)\*\* \:.*?\n(.*?)(?=\n    [\*\S]+))r'     z'\*\*(\w+)\*\* \:.*?\n(.*?)(?=\n[\*\S]+))flagsc                     i | ]>}|                     d                               |                     d                    ?S )r   r   )groupdedent)r|   mtextwraps     r   r   z_parse_docs.<locals>.<dictcomp>  s;    IIIA

HOOAGGAJJ77IIIr   )rer  r   r  sysversion_infofinditerDOTALL)r  doc	arg_regexmatchesprop_docr  s        @r   _parse_docsr    sq    IIIOOO


#C>I
7"">	kk)S	k::GIIIIIIIHOr   c                      t                      } d t          t                    D             D ]"}| |         t          t          |          _        #d S )Nc                 <    g | ]}|                     d           |S )r5  )
startswith)r|   members     r   r   z,_install_properties_docs.<locals>.<listcomp>  s,    WWW@Q@QRU@V@VWfWWWr   )r  dirr   r   r  )r  ps     r   _install_properties_docsr    sU    }}HWW3'7#8#8WWW ; ;/7{ !$$,,; ;r   )r  r  )Nr  )NT)5r   r  	functoolsr   mathr   r   r$  r   warningsr   numpyr   scipyr	   r:  scipy.spatial.distancer
   r  r   _find_contoursr   _marching_cubes_lewinerr   _regionprops_utilsr   r   r   r   __all__r   floatr   r{   r  r  r  setvaluesr  r   r   r   r   r   r   r   _RegionPropertiesr  r  r   r  r  rz   r   r   <module>r     s    



                                               ( ( ( ( ( (       ) ) ) ) ) ) 3 3 3 3 3 3            L
K
KC	
FC	6C	 {C	 	C	
 'C	 
C	 -C	 =C	 >C	 NC	 8C	 NC	 /C	 5C	  >!C	" h#C	& )'C	 C	( ,)C	* -+C	, =-C	. >/C	0 N1C	2 3C	4 W5C	6 %7C	8 49C	: ';C	< (=C	> W?C	@ %AC	B &CC	D *EC	F ,GC	H OIC	 C	 C	J _KC	L %MC	N &OC	P OQC	R _SC	T _UC	V *WC	X ,YC	Z y[C	\ -]C	^ =_C	` aC	b +cC	h WiC	j 
kC	n 8oC	p  :qC	 C	r ,,.068)*!>#@EC	 C	 C	J,
E,, 5, 5	,
 , , C, , e, , u, f, V, E, ,  C!," e#, ,$ %%,& V',( F),* F+,, v-,. e/,0 e1,2 U3,4 e5,6 U7,8 U9,: S;,< u=,> u?,@ %A,B %C,D E, ,F !& #(W, , ,
\ ON
(8(8(:(:NNNC	   (. . .b  "	 	 	' ' 'Tj j j j j j j j\ % B B B BN  lO
 lO lO lO lO lOb 
m
 m m m m m`	  ; ; ;r   