
    a6d                     |    d dl ZddlmZ ddlmZmZ  G d d          Z G d d          Z	 	 ddZ	d Z
d Zd ZdS )    N   )img_as_float)_supported_float_typecheck_nDc                       e Zd Zd Zd ZdS )FeatureDetectorc                 8    t          j        g           | _        d S N)nparray
keypoints_selfs    4lib/python3.11/site-packages/skimage/feature/util.py__init__zFeatureDetector.__init__	   s    (2,,    c                     t                      )z}Detect keypoints in image.

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

        NotImplementedError)r   images     r   detectzFeatureDetector.detect   s     "###r   N)__name__
__module____qualname__r   r    r   r   r   r      s2        ' ' '	$ 	$ 	$ 	$ 	$r   r   c                       e Zd Zd Zd ZdS )DescriptorExtractorc                 8    t          j        g           | _        d S r
   )r   r   descriptors_r   s    r   r   zDescriptorExtractor.__init__   s    HRLLr   c                     t                      )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   	keypointss      r   extractzDescriptorExtractor.extract   s     "###r   N)r   r   r   r   r"   r   r   r   r   r      s2        ) ) )$ $ $ $ $r   r   kF
horizontalc
                    t          |          }t          |          }t          |j                  }
t          |j                  }|j        d         |j        d         k     r|j        d         |
d<   n,|j        d         |j        d         k    r|j        d         |d<   |j        d         |j        d         k     r|j        d         |
d<   n,|j        d         |j        d         k    r|j        d         |d<   |
|j        k    r>t          j        |
|j                  }||d|j        d         d|j        d         f<   |}||j        k    r>t          j        ||j                  }||d|j        d         d|j        d         f<   |}t          j        |j                  }|	dk    rt          j        ||gd          }d|d<   n9|	dk    rt          j        ||gd          }d|d<   nd|	 d	}t          |          |sl| 	                    |dddf         |dddf         d
|           | 	                    |dddf         |d         z   |dddf         |d         z   d
|           | 
                    |d           |                     d|j        d         |d         z   |j        d         |d         z   df           t          j                                        }t          |j        d                   D ]}||df         }||df         }||                    d          }n|}|                     ||df         ||df         |d         z   f||df         ||df         |d         z   fd|           dS )a  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'``.

    r      )dtypeNr$   )axisverticalzKplot_matches accepts either 'horizontal' or 'vertical' for alignment, but 'zu' was given. See https://scikit-image.org/docs/dev/api/skimage.feature.html#skimage.feature.plot_matches for details.none)
facecolors
edgecolorsgray)cmap   -)color)r   listshaper   zerosr'   r   concatenate
ValueErrorscatterimshowr(   randomdefault_rngrangeplot)aximage1image2
keypoints1
keypoints2matcheskeypoints_colormatches_coloronly_matches	alignment
new_shape1
new_shape2
new_image1
new_image2offsetr   mesgrngiidx1idx2r1   s                         r   plot_matchesrQ   +   s   B &!!F&!!Ffl##Jfl##J|Aa((Q
1	a6<?	*	*Q
1|Aa((Q
1	a6<?	*	*Q
1V\!!Xj===
9?
#FLO#%5fl1o%556V\!!Xj===
9?
#FLO#%5fl1o%556Xfl##FL  /a888q			j	 	 /a888q		 #,       B


:aaad#Z1%5$ 	 	B 	B 	B


:aaad#fQi/AAAqD1AF1I1M$ 	 	B 	B 	B IIe&I!!!GGQQ&)+V\!_vay-H!LMMM
)


!
!C7=#$$ " "q!t}q!t} JJqMMEE!E
D!G$jq&9F1I&EFD!G$jq&9F1I&EF5 	 	" 	" 	" 	"" "r   c                     t          j        |           } t          | d           t          |           } t	          | j                  }|                     |d          S )Nr   Fcopy)r   squeezer   r   r   r'   astyper   float_dtypes     r   _prepare_grayscale_input_2DrY      sS    JuEUAE'44K<<%<000r   c                     t          j        |           } t          | t          dd                     t	          |           } t          | j                  }|                     |d          S )Nr      FrS   )r   rU   r   r;   r   r   r'   rV   rW   s     r   _prepare_grayscale_input_nDr\      s[    JuEUE!QKK   E'44K<<%<000r   c                     | d         }| d         }|dz
  |dddf         k     |dddf         ||z
  dz   k     z  |dz
  |dddf         k     z  |dddf         ||z
  dz   k     z  }|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masks         r   _mask_border_keypointsrc      s    ( q>Dq>Dli1o-A$/A"5681	!!!Q$/1 A$/A"568D
 Kr   )r#   NFr$   )numpyr   utilr   _shared.utilsr   r   r   r   rQ   rY   r\   rc   r   r   r   <module>rg      s              ; ; ; ; ; ; ; ;$ $ $ $ $ $ $ $"$ $ $ $ $ $ $ $( HM'_" _" _" _"D1 1 11 1 1    r   