o
    ^i                     @   sp   d dl ZddlmZ ddlmZmZ G dd dZG dd dZd	dd
ddddZ	dd Z
dd Zdd ZdS )    N   )img_as_float)_supported_float_typecheck_nDc                   @      e Zd Zdd Zdd ZdS )FeatureDetectorc                 C      t g | _d S N)nparray
keypoints_self r   O/var/www/html/RAG/RAG_venv/lib/python3.10/site-packages/skimage/feature/util.py__init__      zFeatureDetector.__init__c                 C      t  )z}Detect keypoints in image.

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

        NotImplementedError)r   imager   r   r   detect   s   	zFeatureDetector.detectN)__name__
__module____qualname__r   r   r   r   r   r   r   
       r   c                   @   r   )DescriptorExtractorc                 C   r   r	   )r
   r   descriptors_r   r   r   r   r      r   zDescriptorExtractor.__init__c                 C   r   )zExtract feature descriptors in image for given keypoints.

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

        r   )r   r   	keypointsr   r   r   extract   s   zDescriptorExtractor.extractN)r   r   r   r   r   r   r   r   r   r      r   r   kF
horizontal)keypoints_colormatches_coloronly_matches	alignmentc                   s:  t | } t |}t| j}
t|j}| jd |jd k r$|jd |
d< n| jd |jd kr5| jd |d< | jd |jd k rG|jd |
d< n| jd |jd krX| jd |d< |
| jkrwtj|
| jd}| |d| jd d| jd f< |} ||jkrtj||jd}||d|jd d|jd f< |}t| j}|	dkrtj| |gdd}d|d< n|	dkrtj| |gdd}d|d< n
d|	 d	}t||s|j	|dddf |dddf d
|d |j	|dddf |d  |dddf |d  d
|d |j
|dd |d| jd |d  | jd |d  df |jd }ddlm}  du r?tjjddfddt|D }n'| rP fddt|D }nt dr`t |kr` }nd}t|t|D ]0\}}|\}}|j||df ||df |d  f||df ||df |d  fd|| d qjdS )a  Plot matched features between two images.

    .. versionadded:: 0.23

    Parameters
    ----------
    image0 : (N, M [, 3]) array
        First image.
    image1 : (N, M [, 3]) array
        Second image.
    keypoints0 : (K1, 2) array
        First keypoint coordinates as ``(row, col)``.
    keypoints1 : (K2, 2) array
        Second keypoint coordinates as ``(row, col)``.
    matches : (Q, 2) array
        Indices of corresponding matches in first and second sets of
        descriptors, where `matches[:, 0]` (resp. `matches[:, 1]`) contains
        the indices in the first (resp. second) set of descriptors.
    ax : matplotlib.axes.Axes
        The Axes object where the images and their matched features are drawn.
    keypoints_color : matplotlib color, optional
        Color for keypoint locations.
    matches_color : matplotlib color or sequence thereof, optional
        Single color or sequence of colors for each line defined by `matches`,
        which connect keypoint matches. See [1]_ for an overview of supported
        color formats. By default, colors are picked randomly.
    only_matches : bool, optional
        Set to True to plot matches only and not the keypoint locations.
    alignment : {'horizontal', 'vertical'}, optional
        Whether to show the two images side by side (`'horizontal'`), or one above
        the other (`'vertical'`).

    References
    ----------
    .. [1] https://matplotlib.org/stable/users/explain/colors/colors.html#specifying-colors

    Notes
    -----
    To make a sequence of colors passed to `matches_color` work for any number of
    `matches`, you can wrap that sequence in :func:`itertools.cycle`.
    r      )dtypeNr!   )axisverticalzV`plot_matched_features` accepts either 'horizontal' or 'vertical' for alignment, but 'z~' was given. See https://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.plot_matched_features for details.none)
facecolors
edgecolorsgray)cmap)is_color_like)seedc                    s   g | ]}  d qS )   )random.0_)rngr   r   
<listcomp>   s    z)plot_matched_features.<locals>.<listcomp>c                    s   g | ]} qS r   r   r3   )r#   r   r   r7      s    __len__zb`matches_color` needs to be a single color or a sequence of length equal to the number of matches.-)color)r   listshaper
   zerosr'   r   concatenate
ValueErrorscatterimshowr(   matplotlib.colorsr/   r2   default_rngrangehasattrlen	enumerateplot)image0image1
keypoints0
keypoints1matchesaxr"   r#   r$   r%   
new_shape0
new_shape1
new_image0
new_image1offsetr   mesgnumber_of_matchesr/   colorserror_messageimatchidx0idx1r   )r#   r6   r   plot_matched_features,   s   6


 
 

.



r\   c                 C   s4   t | } t| d t| } t| j}| j|ddS )Nr   Fcopy)r
   squeezer   r   r   r'   astyper   float_dtyper   r   r   _prepare_grayscale_input_2D   s
   


rc   c                 C   s:   t | } t| tdd t| } t| j}| j|ddS )Nr      Fr]   )r
   r_   r   rD   r   r   r'   r`   ra   r   r   r   _prepare_grayscale_input_nD   s
   

re   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 )a  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``).

    r   r&   Nr   )image_shaper   distancerowscolsmaskr   r   r   _mask_border_keypoints   s   rk   )numpyr
   utilr   _shared.utilsr   r   r   r   r\   rc   re   rk   r   r   r   r   <module>   s     