ó
 ‰\c           @   s|  d  d l  m Z d  d l m Z m Z m Z d  d l 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 g Z d Z e j d d d g d d d g d d d g g d e j ƒZ e j d d f d e j ƒZ e j d d d f d e j ƒZ i  d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d  d! 6d" d# 6d$ d% 6d& d' 6d( d) 6d* d+ 6d, d- 6d. d/ 6d0 d1 6d2 d3 6d4 d5 6d6 d7 6d8 d9 6d: d; 6d< d= 6d> d? 6d@ dA 6d dB 6dC dD 6dE dF 6dG dH 6dI dJ 6dK dL 6dM dN 6Z e e j ƒ  ƒ Z  dO „  Z! dP „  Z" dQ e# f dR „  ƒ  YZ$ e% e& e% dS „ Z' dT dU „ Z( dV „  Z) dW „  Z* e* ƒ  d S(X   iÿÿÿÿ(   t   division(   t   sqrtt   atan2t   piN(   t   warn(   t   ndimagei   (   t   label(   t   _moments(   t   wrapst   regionpropst	   perimeters=  regionprops and image moments (including moments, normalized moments, central moments, and inertia tensor) of 2D images will change from xy coordinates to rc coordinates in version 0.16.
See http://scikit-image.org/docs/0.14.x/release_notes_and_installation.html#deprecations for details on how to avoid this message.i    t   dtypei   t   areat   Areat   bboxt   BoundingBoxt	   bbox_areat   BoundingBoxAreat   moments_centralt   CentralMomentst   centroidt   Centroidt   convex_areat
   ConvexAreat   convex_imaget   ConvexImaget   coordst   Coordinatest   eccentricityt   Eccentricityt   equivalent_diametert   EquivDiametert   euler_numbert   EulerNumbert   extentt   Extentt   filled_areat
   FilledAreat   filled_imaget   FilledImaget
   moments_hut	   HuMomentst   imaget   ImageR   t   Labelt   major_axis_lengtht   MajorAxisLengtht   max_intensityt   MaxIntensityt   mean_intensityt   MeanIntensityt   min_intensityt   MinIntensityt   minor_axis_lengtht   MinorAxisLengtht   momentst   Momentst   moments_normalizedt   NormalizedMomentst   orientationt   Orientationt	   Perimetert   solidityt   Solidityt   weighted_moments_centralt   WeightedCentralMomentst   weighted_centroidt   WeightedCentroidt   weighted_moments_hut   WeightedHuMomentst   weighted_momentst   WeightedMomentst   weighted_moments_normalizedt   WeightedNormalizedMomentsc            s   t  ˆ  ƒ ‡  f d †  ƒ } | S(   Nc            sB   |  j  } ˆ  j } | | k o$ |  j s: ˆ  |  ƒ | | <n  | | S(   N(   t   _cachet   __name__t   _cache_active(   t   objt   cachet   prop(   t   f(    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   wrapperJ   s
    		(   R   (   RP   RQ   (    (   RP   s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   _cachedI   s    
c            s   t  ˆ  ƒ ‡  f d †  ƒ } | S(   Nc            s5   |  j  d k r% t d ˆ  j ƒ ‚ n  ˆ  |  | | Ž S(   Ni   s,   Property %s is not implemented for 3D images(   t   _ndimt   NotImplementedErrorRK   (   t   selft   argst   kwargs(   t   method(    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   func2dX   s    (   R   (   RX   RY   (    (   RX   s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   only2dW   s    t   _RegionPropertiesc           B   sñ  e  Z d  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z e d „  ƒ Z	 e d „  ƒ Z
 d „  Z e d	 „  ƒ Z d
 „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z  e d „  ƒ Z! e d „  ƒ Z" e d „  ƒ Z# d  „  Z$ d! „  Z% d" „  Z& e d# „  ƒ Z' e d$ „  ƒ Z( e d% „  ƒ Z) e d& „  ƒ Z* d' „  Z+ d( „  Z, d) „  Z- RS(*   so   Please refer to `skimage.measure.regionprops` for more information
    on the available region properties.
    c         C   sô   | d  k	 r0 | j | j k s0 t d ƒ ‚ q0 n  | |  _ | |  _ | |  _ | |  _ | |  _ i  |  _ | j	 |  _
 | j	 d k s | d k r¢ t |  _ t |  _ nN | d k rÃ t |  _ t |  _ n- | d  k rä t |  _ t |  _ n t d ƒ ‚ d  S(   Ns2   Label and intensity image must have thesame shape.i   t   rct   xysY   Incorrect value for regionprops coordinates: %s. Possible values are: "rc", "xy", or None(   t   Nonet   shapet
   ValueErrorR   t   _slicet   _label_imaget   _intensity_imageRL   RJ   t   ndimRS   t   Falset   _use_xy_warningt   _transpose_momentst   True(   RU   t   sliceR   t   label_imaget   intensity_imaget   cache_activet   coordinates(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   __init__f   s(    									c         C   s   t  j |  j ƒ S(   N(   t   npt   sumR*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ‡   s    c         C   sZ   t  g  t |  j ƒ D] } |  j | j ^ q g  t |  j ƒ D] } |  j | j ^ q< ƒ S(   s°   
        Returns
        -------
        A tuple of the bounding box's start coordinates for each dimension,
        followed by the end coordinates for each dimension
        (   t   tuplet   rangeRS   Ra   t   startt   stop(   RU   t   i(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ‹   s    ,c         C   s
   |  j  j S(   N(   R*   t   size(   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   •   s    c         C   s   t  |  j j d d ƒ ƒ S(   Nt   axisi    (   Rq   R   t   mean(   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ˜   s    c         C   s   t  j |  j ƒ S(   N(   Ro   Rp   R   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ›   s    c         C   s   d d l  m } | |  j ƒ S(   Ni   (   t   convex_hull_image(   t   morphology.convex_hullRy   R*   (   RU   Ry   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   Ÿ   s    c         C   sP   t  j |  j ƒ } t  j g  t |  j ƒ D] } | | |  j | j ^ q( ƒ j S(   N(	   Ro   t   nonzeroR*   t   vstackRr   RS   Ra   Rs   t   T(   RU   t   indicesRu   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ¤   s    	c         C   s1   |  j  \ } } | d k r d St d | | ƒ S(   Ni    i   (   t   inertia_tensor_eigvalsR   (   RU   t   l1t   l2(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ©   s    c         C   sJ   |  j  d k r$ t d |  j t ƒ S|  j  d k rF d |  j t d Sd  S(   Ni   i   i   i   g      ð?gUUUUUUÕ?(   RS   R   R   t   PI(   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   °   s    c         C   sB   |  j  |  j k } t | d |  j d t d d ƒ\ } } | d S(   Nt   connectivityt
   return_numt
   backgroundi    i   (   R&   R*   R   RS   Rh   (   RU   t   euler_arrayt   _t   num(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR    ¶   s    c         C   s   |  j  |  j j S(   N(   R   R*   Rv   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR"   ¼   s    c         C   s   t  j |  j ƒ S(   N(   Ro   Rp   R&   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR$   ¿   s    c         C   s)   t  j d |  j ƒ } t j |  j | ƒ S(   Ni   (   i   (   Ro   t   onesRS   t   ndit   binary_fill_holesR*   (   RU   t	   structure(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR&   Â   s    c         C   s   |  j  |  j |  j k S(   N(   Rb   Ra   R   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR*   Ç   s    c         C   s   |  j  } t j |  j | ƒ S(   N(   R   R   t   inertia_tensorR*   (   RU   t   mu(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   Ë   s    	c         C   s   t  j |  j d |  j ƒS(   NR}   (   R   R   R*   R   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   Ð   s    c         C   s3   |  j  d  k r t d ƒ ‚ n  |  j  |  j |  j S(   Ns   No intensity image specified.(   Rc   R^   t   AttributeErrorRa   R*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyRk   Õ   s    c         C   s   |  j  j t j ƒ S(   N(   Rk   t   astypeRo   t   double(   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   _intensity_image_doubleÛ   s    c         C   sS   |  j  } |  j r | j } n  t | t t j |  j d t ƒƒ | d |  j ƒ S(   NR   i    (   i    (   R7   Rg   R}   Rq   Ro   t   eyeRS   t   int(   RU   t   M(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   local_centroidÞ   s
    		"c         C   s   t  j |  j |  j ƒ S(   N(   Ro   t   maxRk   R*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR/   å   s    c         C   s   t  j |  j |  j ƒ S(   N(   Ro   Rx   Rk   R*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR1   è   s    c         C   s   t  j |  j |  j ƒ S(   N(   Ro   t   minRk   R*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR3   ë   s    c         C   s   |  j  d } d t | ƒ S(   Ni    i   (   R   R   (   RU   R€   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR-   î   s    c         C   s   |  j  d } d t | ƒ S(   Niÿÿÿÿi   (   R   R   (   RU   R   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR5   ò   s    c         C   sP   t  j |  j j t j ƒ d ƒ } |  j r7 t t ƒ n  |  j	 rL | j
 } n  | S(   Ni   (   R   R7   R*   R   Ro   t   uint8Rf   R   t   XY_TO_RC_DEPRECATION_MESSAGERg   R}   (   RU   R•   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR7   ö   s    !		c         C   sY   t  j |  j j t j ƒ |  j d d ƒ} |  j r@ t t	 ƒ n  |  j
 rU | j } n  | S(   Nt   orderi   (   R   R   R*   R   Ro   R™   R–   Rf   R   Rš   Rg   R}   (   RU   RŽ   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR   ÿ   s    		c         C   s   t  j |  j ƒ S(   N(   R   R(   R9   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR(   	  s    c         C   s   t  j |  j d ƒ S(   Ni   (   R   R9   R   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR9     s    c         C   s~   |  j  j \ } } } } |  j r' d n d } | | d k r] | d k  rR t d St d Sn | d t d | | | ƒ Sd  S(   Niÿÿÿÿi   i    g      @g      à?iþÿÿÿ(   R   t   flatRg   R‚   R   (   RU   t   at   bt   ct   sign(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR;     s    	c         C   s   t  |  j d ƒ S(   Ni   (   R
   R*   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR
     s    c         C   s   |  j  |  j S(   N(   R   R   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR>   !  s    c         C   s)   |  j  } t d „  t | |  j ƒ Dƒ ƒ S(   Nc         s   s"   |  ] \ } } | | j  Vq d  S(   N(   Rs   (   t   .0t   idxt   slc(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pys	   <genexpr>&  s   (   t   weighted_local_centroidRq   t   zipRa   (   RU   t   ctr(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyRB   $  s    		c         C   s8   |  j  } | t t j |  j d t ƒƒ | d |  j S(   NR   i    (   i    (   RF   Rq   Ro   R“   RS   R”   (   RU   R•   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR¤   )  s    	c         C   s   t  j |  j ƒ  d ƒ S(   Ni   (   R   R7   R’   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyRF   .  s    c         C   s(   |  j  } t j |  j ƒ  d | d d ƒS(   Nt   centerR›   i   (   R¤   R   R   R’   (   RU   R¦   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR@   2  s    	c         C   s   t  j |  j ƒ S(   N(   R   R(   RH   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyRD   8  s    c         C   s   t  j |  j d ƒ S(   Ni   (   R   R9   R@   (   RU   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyRH   <  s    c      
   C   s=   t  } |  j d  k r- d } | j | ƒ } n  t t | ƒ ƒ S(   NRk   R/   R1   R3   RF   R@   RB   R¤   RD   RH   (
   Rk   R/   R1   R3   RF   R@   RB   R¤   RD   RH   (   t	   PROP_VALSRc   R^   t
   differencet   itert   sorted(   RU   t   propst   unavailable_props(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   __iter__@  s             c         C   s7   t  |  | d  ƒ } | d  k	 r" | St  |  t | ƒ Sd  S(   N(   t   getattrR^   t   PROPS(   RU   t   keyt   value(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   __getitem__S  s    c         C   sl   t  | t ƒ s t SxR t D]J } y/ t j j t |  | d  ƒ t | | d  ƒ ƒ Wq t	 k
 rc t SXq Wt
 S(   N(   t
   isinstanceR[   Re   R¨   Ro   t   testingt   assert_equalR¯   R^   t   AssertionErrorRh   (   RU   t   otherR±   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   __eq__Z  s    	(.   RK   t
   __module__t   __doc__Rn   RR   R   R   R   R   R   R   R   RZ   R   R   R    R"   R$   R&   R*   R   R   Rk   R’   R–   R/   R1   R3   R-   R5   R7   R   R(   R9   R;   R
   R>   RB   R¤   RF   R@   RD   RH   R®   R³   R¹   (    (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR[   a   sT   	!	
															
					c   
   	   C   sÂ   |  j  d k r t d ƒ ‚ n  t j |  j t j ƒ sE t d ƒ ‚ n  g  } t j |  ƒ } xa t | ƒ D]S \ } } | d k r… qg n  | d } t
 | | |  | | d | ƒ}	 | j |	 ƒ qg W| S(	   sG  Measure properties of labeled image regions.

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

        .. versionchanged:: 0.14.2
            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 : (N, M) ndarray, optional
        Intensity (i.e., input) image with same size as labeled image.
        Default is None.
    cache : bool, optional
        Determine whether to cache calculated properties. The computation is
        much faster for cached properties, whereas the memory consumption
        increases.
    coordinates : 'rc' or 'xy', optional
        Coordinate conventions for 2D images. (Only 'rc' coordinates are
        supported for 3D images.)

    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** : int
        Number of pixels of 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)``.
    **bbox_area** : int
        Number of pixels of bounding box.
    **centroid** : array
        Centroid coordinate tuple ``(row, col)``.
    **convex_area** : int
        Number of pixels of convex hull image.
    **convex_image** : (H, J) ndarray
        Binary convex hull image which has the same size as bounding box.
    **coords** : (N, 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** : float
        The diameter of a circle with the same area as the region.
    **euler_number** : int
        Euler characteristic of region. Computed as number of objects (= 1)
        subtracted by number of holes (8-connectivity).
    **extent** : float
        Ratio of pixels in the region to pixels in the total bounding box.
        Computed as ``area / (rows * cols)``
    **filled_area** : int
        Number of pixels of filled region.
    **filled_image** : (H, J) ndarray
        Binary region image with filled holes which has the same size as
        bounding box.
    **image** : (H, J) ndarray
        Sliced binary region image which has the same size as bounding box.
    **inertia_tensor** : (2, 2) ndarray
        Inertia tensor of the region for the rotation around its mass.
    **inertia_tensor_eigvals** : tuple
        The two eigen values of the inertia tensor in decreasing order.
    **intensity_image** : ndarray
        Image inside region bounding box.
    **label** : int
        The label in the labeled input image.
    **local_centroid** : array
        Centroid coordinate tuple ``(row, col)``, relative to region bounding
        box.
    **major_axis_length** : float
        The length of the major axis of the ellipse that has the same
        normalized second central moments as the region.
    **max_intensity** : float
        Value with the greatest intensity in the region.
    **mean_intensity** : float
        Value with the mean intensity in the region.
    **min_intensity** : float
        Value with the least intensity in the region.
    **minor_axis_length** : float
        The length of the minor axis of the ellipse that has the same
        normalized second central moments as the region.
    **moments** : (3, 3) ndarray
        Spatial moments up to 3rd order::

            m_ji = sum{ array(x, y) * x^j * y^i }

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

            mu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }

        where the sum is over the `x`, `y` coordinates of the region,
        and `x_c` and `y_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_ji = mu_ji / m_00^[(i+j)/2 + 1]

        where `m_00` is the zeroth spatial moment.
    **orientation** : float
        In 'rc' coordinates, 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.

        In `xy` coordinates, as above but the angle is now measured from the
        "x" or horizontal axis.
    **perimeter** : float
        Perimeter of object which approximates the contour as a line
        through the centers of border pixels using a 4-connectivity.
    **solidity** : float
        Ratio of pixels in the region to pixels of the convex hull image.
    **weighted_centroid** : array
        Centroid coordinate tuple ``(row, col)`` weighted with intensity
        image.
    **weighted_local_centroid** : array
        Centroid coordinate tuple ``(row, col)``, relative to region bounding
        box, weighted with intensity image.
    **weighted_moments** : (3, 3) ndarray
        Spatial moments of intensity image up to 3rd order::

            wm_ji = sum{ array(x, y) * x^j * y^i }

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

            wmu_ji = sum{ array(x, y) * (x - x_c)^j * (y - y_c)^i }

        where the sum is over the `x`, `y` coordinates of the region,
        and `x_c` and `y_c` are the coordinates of the region's weighted
        centroid.
    **weighted_moments_hu** : tuple
        Hu moments (translation, scale and rotation invariant) of intensity
        image.
    **weighted_moments_normalized** : (3, 3) ndarray
        Normalized moments (translation and scale invariant) of intensity
        image up to 3rd order::

            wnu_ji = wmu_ji / wm_00^[(i+j)/2 + 1]

        where ``wm_00`` is the zeroth spatial moment (intensity-weighted area).

    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] http://en.wikipedia.org/wiki/Image_moment

    Examples
    --------
    >>> from skimage import data, util
    >>> from skimage.measure import label
    >>> 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.729879860483141, 81.912285234465827)
    >>> # centroid of first labeled object
    >>> props[0]['centroid']
    (22.729879860483141, 81.912285234465827)

    i   i   s"   Only 2-D and 3-D images supported.s$   Label image must be of integer type.i   Rm   (   i   i   N(   Rd   t	   TypeErrorRo   t
   issubdtypeR   t   integerRŠ   t   find_objectst	   enumerateR^   R[   t   append(
   Rj   Rk   RN   Rm   t   regionst   objectsRu   t   slR   R¬   (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR	   i  s    Å
i   c   	      C   s3  | d k r t  } n t } |  j t j ƒ }  t j |  | d d ƒ} |  | } t j d d t j ƒ} d | d d d	 d
 d d g <t	 d ƒ | d d g <d t	 d ƒ d | d d g <t j
 | t j d d d g d d d g d d d g g ƒ d d d d ƒ} t j | j ƒ  d d ƒ} t j | | ƒ } | S(   sG  Calculate total perimeter of all objects in binary image.

    Parameters
    ----------
    image : array
        Binary image.
    neighbourhood : 4 or 8, optional
        Neighborhood connectivity for border pixel determination.

    Returns
    -------
    perimeter : float
        Total perimeter of all objects in binary image.

    References
    ----------
    .. [1] K. Benkrid, D. Crookes. Design and FPGA Implementation of
           a Perimeter Estimator. The Queen's University of Belfast.
           http://www.cs.qub.ac.uk/~d.crookes/webpubs/papers/perimeter.doc
    i   t   border_valuei    i2   R   i   i   i   i   i   i   i   i   i   i!   i   i   i
   t   modet   constantt   cvalt	   minlength(   t   STREL_4t   STREL_8R   Ro   R™   RŠ   t   binary_erosiont   zerosR‘   R   t   convolvet   arrayt   bincountt   ravelt   dot(	   R*   t   neighbourhoodt   strelt   eroded_imaget   border_imaget   perimeter_weightst   perimeter_imaget   perimeter_histogramt   total_perimeter(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyR
   D  s"    	
c             s\   d d  l  }  d d  l ‰  t j } |  j d | d |  j ƒ} t ‡  f d †  | Dƒ ƒ } | S(   Niÿÿÿÿs)   \*\*(\w+)\*\* \:.*?
(.*?)(?=
    [\*\S]+)t   flagsc         3   s6   |  ], } | j  d  ƒ ˆ  j | j  d ƒ ƒ f Vq d S(   i   i   N(   t   groupt   dedent(   R¡   t   m(   t   textwrap(    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pys	   <genexpr>{  s    (   t   reRß   R	   R»   t   finditert   DOTALLt   dict(   Rà   t   doct   matchest   prop_doc(    (   Rß   s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   _parse_docst  s    		c          C   s¬   t  ƒ  }  xœ g  t t ƒ D] } | j d ƒ s | ^ q D]l } y |  | t t | ƒ _ Wn* t k
 r„ |  | t t | ƒ j _ n Xt t | t	 t t | ƒ ƒ ƒ q8 Wd  S(   NR‡   (
   Rç   t   dirR[   t
   startswithR¯   R»   R   t   im_funct   setattrt   property(   Ræ   t   membert   p(    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   _install_properties_docs€  s    	(+   t
   __future__R    t   mathR   R   R   R‚   t	   itertoolst   warningsR   t   numpyRo   t   scipyR   RŠ   t   _labelR   t    R   t	   functoolsR   t   __all__Rš   RÏ   R™   RÊ   R‰   RË   t   STREL_26_3DR°   t   sett   valuesR¨   RR   RZ   t   objectR[   R^   Rh   R	   R
   Rç   Rï   (    (    (    s;   lib/python2.7/site-packages/skimage/measure/_regionprops.pyt   <module>   sv   !
		
ÿ 	Ú0		