ó
 ‰\c           @   sƒ   d  d l  Z d d l m Z d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 d e
 d
 d „ Z d „  Z d „  Z d S(   iÿÿÿÿNi   (   t   img_as_float(   t	   assert_nDt   FeatureDetectorc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   t  j g  ƒ |  _ d  S(   N(   t   npt   arrayt
   keypoints_(   t   self(    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   __init__	   s    c         C   s   t  ƒ  ‚ d S(   s}   Detect keypoints in image.

        Parameters
        ----------
        image : 2D array
            Input image.

        N(   t   NotImplementedError(   R   t   image(    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   detect   s    	(   t   __name__t
   __module__R   R
   (    (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyR      s   	t   DescriptorExtractorc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   t  j g  ƒ |  _ d  S(   N(   R   R   t   descriptors_(   R   (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyR      s    c         C   s   t  ƒ  ‚ d S(   sï   Extract feature descriptors in image for given keypoints.

        Parameters
        ----------
        image : 2D array
            Input image.
        keypoints : (N, 2) array
            Keypoint locations as ``(row, col)``.

        N(   R   (   R   R	   t	   keypoints(    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   extract   s    (   R   R   R   R   (    (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyR      s   	t   kt
   horizontalc
         C   sÞ  t  | ƒ } t  | ƒ } t | j ƒ }
 t | j ƒ } | j d | j d k  rd | j d |
 d <n. | j d | j d k r’ | j d | d <n  | j d | j d k  rÀ | j d |
 d <n. | j d | j d k rî | j d | d <n  |
 | j k rHt j |
 d | j ƒ} | | d | j d … d | j d … f <| } n  | | j k r¢t j | d | j ƒ} | | d | j d … d | j d … f <| } n  t j | j ƒ } |	 d k rèt j | | g d d ƒ} d | d <nO |	 d k rt j | | g d d ƒ} d | d <n d j |	 ƒ } t	 | ƒ ‚ | sÈ|  j
 | d d … d f | d d … d f d	 d
 d | ƒ|  j
 | d d … d f | d | d d … d f | d d	 d
 d | ƒn  |  j | d d d d ƒ|  j d | j d | d | j d | d d f ƒ x¿ t | j d ƒ D]ª } | | d f } | | d f } | d k rst j j d ƒ } n | } |  j | | d f | | d f | d f | | d f | | d f | d f d d | ƒq,Wd S(   s¼  Plot matched features.

    Parameters
    ----------
    ax : matplotlib.axes.Axes
        Matches and image are drawn in this ax.
    image1 : (N, M [, 3]) array
        First grayscale or color image.
    image2 : (N, M [, 3]) array
        Second grayscale or color image.
    keypoints1 : (K1, 2) array
        First keypoint coordinates as ``(row, col)``.
    keypoints2 : (K2, 2) array
        Second keypoint coordinates as ``(row, col)``.
    matches : (Q, 2) array
        Indices of corresponding matches in first and second set of
        descriptors, where ``matches[:, 0]`` denote the indices in the first
        and ``matches[:, 1]`` the indices in the second set of descriptors.
    keypoints_color : matplotlib color, optional
        Color for keypoint locations.
    matches_color : matplotlib color, optional
        Color for lines which connect keypoint matches. By default the
        color is chosen randomly.
    only_matches : bool, optional
        Whether to only plot matches and not plot the keypoint locations.
    alignment : {'horizontal', 'vertical'}, optional
        Whether to show images side by side, ``'horizontal'``, or one above
        the other, ``'vertical'``.

    i    i   t   dtypeNR   t   axist   verticalsÁ   plot_matches accepts either 'horizontal' or 'vertical' for alignment, but '{}' was given. See http://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.plot_matches for details.t
   facecolorst   nonet
   edgecolorst   interpolationt   nearestt   cmapt   grayi   t   -t   color(   R    t   listt   shapeR   t   zerosR   R   t   concatenatet   formatt
   ValueErrort   scattert   imshowR   t   ranget   Nonet   randomt   randt   plot(   t   axt   image1t   image2t
   keypoints1t
   keypoints2t   matchest   keypoints_colort   matches_colort   only_matchest	   alignmentt
   new_shape1t
   new_shape2t
   new_image1t
   new_image2t   offsetR	   t   mesgt   it   idx1t   idx2R   (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   plot_matches+   s\    "*	*		/?7+%c         C   s&   t  j |  ƒ }  t |  d ƒ t |  ƒ S(   Ni   (   R   t   squeezeR   R    (   R	   (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   _prepare_grayscale_input_2DŒ   s    c         C   sš   |  d } |  d } | d | d d … d f k  | d d … d f | | d k  @| d | d d … d f k  @| d d … d f | | d k  @} | S(   sò  Mask coordinates that are within certain distance from the image border.

    Parameters
    ----------
    image_shape : (2, ) array_like
        Shape of the image as ``(rows, cols)``.
    keypoints : (N, 2) array
        Keypoint coordinates as ``(rows, cols)``.
    distance : int
        Image border distance.

    Returns
    -------
    mask : (N, ) bool array
        Mask indicating if pixels are within the image (``True``) or in the
        border region of the image (``False``).

    i    i   N(    (   t   image_shapeR   t   distancet   rowst   colst   mask(    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   _mask_border_keypoints’   s    

‚(   t   numpyR   t   utilR    t   _shared.utilsR   t   objectR   R   R(   t   FalseR?   RA   RG   (    (    (    s3   lib/python2.7/site-packages/skimage/feature/util.pyt   <module>   s   	_	