
    |h                     t    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d
dddZ	d Z
d Zd Zy)    N   )img_as_float)_supported_float_typecheck_nDc                       e Zd Zd Zd Zy)FeatureDetectorc                 8    t        j                  g       | _        y N)nparray
keypoints_selfs    S/var/www/html/test/engine/venv/lib/python3.12/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   
   s    '	$r   r   c                       e Zd Zd Zd Zy)DescriptorExtractorc                 8    t        j                  g       | _        y r
   )r   r   descriptors_r   s    r   r   zDescriptorExtractor.__init__   s    HHRL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      s    )$r   r   kF
horizontal)keypoints_colormatches_coloronly_matches	alignmentc                   t        |       } t        |      }t        | j                        }
t        |j                        }| j                  d   |j                  d   k  r|j                  d   |
d<   n1| j                  d   |j                  d   kD  r| j                  d   |d<   | j                  d   |j                  d   k  r|j                  d   |
d<   n1| j                  d   |j                  d   kD  r| j                  d   |d<   |
| j                  k7  rHt        j                  |
| j
                        }| |d| j                  d   d| j                  d   f<   |} ||j                  k7  rHt        j                  ||j
                        }||d|j                  d   d|j                  d   f<   |}t        j                  | j                        }|	dk(  rt        j                  | |gd      }d|d<   n5|	dk(  rt        j                  | |gd      }d|d<   nd|	 d	}t        |      |sR|j                  |dddf   |dddf   d
|       |j                  |dddf   |d   z   |dddf   |d   z   d
|       |j                  |d       |j                  d| j                  d   |d   z   | j                  d   |d   z   df       |j                  d   }ddlm} |Ht        j                  j                  d      }t!        |      D cg c]  }|j                  d       }}nK ||      rt!        |      D cg c]  }| }}n*t#        |d      rt%        |      |k(  r|}nd}t        |      t'        |      D ]F  \  }}|\  }}|j)                  ||df   ||df   |d   z   f||df   ||df   |d   z   fd||          H yc c}w c c}w )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)seed   __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.colorsr3   random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_matchesr3   rng_colorserror_messageimatchidx0idx1s                              r   plot_matched_featuresr]   ,   s   l &!F&!Ffll#Jfll#J||Aa(Q
1	a6<<?	*Q
1||Aa(Q
1	a6<<?	*Q
1V\\!XXj=
;A
$V\\!_$&7Q&778V\\!XXj=
;A
$V\\!_$&7Q&778XXfll#FL /a8q		j	 /a8q	(k * 	 


q!tq!t&	 	 	
 	

q!tvay(q!tvay(&	 	 	
 IIe&I!GGQQ&)+V\\!_vay-H!LMa(/ii###+)./@)ABA#**Q-BB	}	%)./@)ABA-BB			*s=/AEV/VF 	 ''g& 
5
d
a *T1W"5q	"ABa *T1W"5q	"AB)	 	 	

 CBs   O	Oc                     t        j                  |       } t        | d       t        |       } t	        | j
                        }| j                  |d      S )Nr   Fcopy)r   squeezer   r   r   r+   astyper   float_dtypes     r   _prepare_grayscale_input_2Dre      sE    JJuEUAE'4K<<%<00r   c                     t        j                  |       } t        | t        dd             t	        |       } t        | j                        }| j                  |d      S )Nr      Fr_   )r   ra   r   rC   r   r   r+   rb   rc   s     r   _prepare_grayscale_input_nDrh      sK    JJuEUE!QK E'4K<<%<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_keypointsro      s    ( q>Dq>D Q,)AqD/	)QT?dXo12	4qLIadO+	- QT?dXo12	4 	 Kr   )numpyr   utilr   _shared.utilsr   r   r   r   r]   re   rh   ro   r   r   r   <module>rs      sH     $ $ $ $4 K
\11r   