+
    Ai                     H    ^ RI t ^ RIt^ RIHt ^RIHtHt R tR t	RR lt
R# )    N)fftconvolve)check_nD_supported_float_typec                    \         P                  ! V ^ R7      pW!^ ,          R VRV^ ,          ) ^,
           ,
          p\         P                  ! V^R7      pVRV^,          R13,          VRRV^,          ) ^,
          13,          ,
          pV# )r   axisNNNN)npcumsumimagewindow_shape
window_sums   && V/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/feature/template.py_window_sum_2dr   	   s    5q)JOb1J?U,q/AQTUAU4VVJ:A.J1l1o**+j<R|A>NQR>R<R9R.SS      c                     \        W4      p\        P                  ! V^R7      pVRRV^,          R13,          VRRRV^,          ) ^,
          13,          ,
          pV# )   r   r	   Nr
   )r   r   r   r   s   && r   _window_sum_3dr      sg    4J:A.J1aa2--.
Q1l1o-111
2	3 
 r   c           	     R   \        V R4       V P                  VP                  8  d   \        R4      h\        P                  ! \        P
                  ! V P                  VP                  4      4      '       d   \        R4      hV P                  p\        V P                  4      pV P                  VRR7      p \        ;QJ d    . R VP                   4       F  NK  	  5M! R VP                   4       4      pVR8X  d   \        P                  ! WW4R7      p M\        P                  ! WVR7      p V P                  ^8X  d4   \        WP                  4      p\        V ^,          VP                  4      p	MCV P                  ^8X  d3   \        WP                  4      p\        V ^,          VP                  4      p	VP                  4       p
\        P                   ! VP                  4      p\        P"                  ! W,
          ^,          4      pV P                  ^8X  d+   \%        WR	R	R1R	R	R13,          R
R7      ^R1^R13,          pMAV P                  ^8X  d1   \%        WR	R	R1R	R	R1R	R	R13,          R
R7      ^R1^R1^R13,          pXXV
,          ,
          pX	p\        P&                  ! WVR7       \        P(                  ! WVR7       W,          pW,          p\        P*                  ! V^ VR7       \        P,                  ! WR7       \        P.                  ! WR7      pV\        P0                  ! V4      P2                  8  pVV,          VV,          ,          VV&   . p\5        VP                  4       F  pV'       d3   VP                  V,          ^,
          ^,          pVVV,          ,           pMIVP                  V,          ^,
          pVVV,          ,           VP                  V,          ,
          ^,           pVP7                  \9        VV4      4       K  	  V\        V4      ,          # )a+  Match a template to a 2-D or 3-D image using normalized correlation.

The output is an array with values between -1.0 and 1.0. The value at a
given position corresponds to the correlation coefficient between the image
and the template.

For `pad_input=True` matches correspond to the center and otherwise to the
top-left corner of the template. To find the best match you must search for
peaks in the response (output) image.

Parameters
----------
image : (M, N[, P]) array
    2-D or 3-D input image.
template : (m, n[, p]) array
    Template to locate. It must be `(m <= M, n <= N[, p <= P])`.
pad_input : bool
    If True, pad `image` so that output is the same size as the image, and
    output values correspond to the template center. Otherwise, the output
    is an array with shape `(M - m + 1, N - n + 1)` for an `(M, N)` image
    and an `(m, n)` template, and matches correspond to origin
    (top-left corner) of the template.
mode : see `numpy.pad`, optional
    Padding mode.
constant_values : see `numpy.pad`, optional
    Constant values used in conjunction with ``mode='constant'``.

Returns
-------
output : array
    Response image with correlation coefficients.

Notes
-----
Details on the cross-correlation are presented in [1]_. This implementation
uses FFT convolutions of the image and the template. Reference [2]_
presents similar derivations but the approximation presented in this
reference is not used in our implementation.

References
----------
.. [1] J. P. Lewis, "Fast Normalized Cross-Correlation", Industrial Light
       and Magic.
.. [2] Briechle and Hanebeck, "Template Matching using Fast Normalized
       Cross Correlation", Proceedings of the SPIE (2001).
       :DOI:`10.1117/12.421129`

Examples
--------
>>> template = np.zeros((3, 3))
>>> template[1, 1] = 1
>>> template
array([[0., 0., 0.],
       [0., 1., 0.],
       [0., 0., 0.]])
>>> image = np.zeros((6, 6))
>>> image[1, 1] = 1
>>> image[4, 4] = -1
>>> image
array([[ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0., -1.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.]])
>>> result = match_template(image, template)
>>> np.round(result, 3)
array([[ 1.   , -0.125,  0.   ,  0.   ],
       [-0.125, -0.125,  0.   ,  0.   ],
       [ 0.   ,  0.   ,  0.125,  0.125],
       [ 0.   ,  0.   ,  0.125, -1.   ]])
>>> result = match_template(image, template, pad_input=True)
>>> np.round(result, 3)
array([[-0.125, -0.125, -0.125,  0.   ,  0.   ,  0.   ],
       [-0.125,  1.   , -0.125,  0.   ,  0.   ,  0.   ],
       [-0.125, -0.125, -0.125,  0.   ,  0.   ,  0.   ],
       [ 0.   ,  0.   ,  0.   ,  0.125,  0.125,  0.125],
       [ 0.   ,  0.   ,  0.   ,  0.125, -1.   ,  0.125],
       [ 0.   ,  0.   ,  0.   ,  0.125,  0.125,  0.125]])
zUDimensionality of template must be less than or equal to the dimensionality of image.z#Image must be larger than template.F)copyc              3   (   "   T F  qV3x  K
  	  R # 5i)N ).0widths   & r   	<genexpr>!match_template.<locals>.<genexpr>   s     A.en.s   constant)	pad_widthmodeconstant_values)r    r!   Nvalid)r!   )out)dtype)r      r
   )r   ndim
ValueErrorr   anylessshaper   r%   astypetuplepadr   r   meanmathprodsumr   multiplydividemaximumsqrt
zeros_likefinfoepsrangeappendslice)r   template	pad_inputr!   r"   image_shapefloat_dtyper    image_window_sumimage_window_sum2template_meantemplate_volumetemplate_ssdxcorr	numeratordenominatorresponsemaskslicesid0d1s   &&&&&                 r   match_templaterO   !   s.   f UFzzHMM!4
 	
 
vvbggekk8>>233>??++K'4KLL5L1EA(..AA(..AAIzT
 u= zzQ)%@*5!8X^^D	q)%@*5!8X^^DMMOMii/O66839:LzzQEDbD$B$J#7gFqtQrTzR	qEDbD$B$",<#=GLbD!B$"
 (=88I#KKK 8HIII5EF#KKJJ{A;/GGK)}}U6H +.222Dt_{4'88HTNF8==!..#a'A-Bk!n$B"Q&Bk!n$x~~a'881<BeBm$ " E&M""r   )Fr   r   )r0   numpyr   scipy.signalr   _shared.utilsr   r   r   r   rO   r   r   r   <module>rS      s!      $ ;		Y#r   