
    9iP'                         S SK r S SKrS SKJrJrJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SSKJr           S
S	 jrg)    N)arctan2exppisqrt   )draw)img_as_float)gaussian)check_nD)gray2rgbc
                    [        U SS5        [        U 5      n U R                  n
Ub)  Ub&  [        U5      S-
  [        U5      :w  a  [	        S5      eUb  [        U5      nUS   nUb  [        U5      S-
  nUc/  [        U5       Vs/ s H  oUS-   -  [        SU-  5      -  PM     nnUc,  [        U5       Vs/ s H  oUS-   -  [        U5      -  PM     nnUS;  a  [	        S5      e[        R                  " U R                  U
S	9n[        R                  " U R                  U
S	9n[        R                  " U SSS
9USS2SS24'   [        R                  " U SSS
9USS2SS24'   [        US-  US-  -   5      n[        X5      nU[        -  n[        U5       Vs/ s H  nSU-  [        -  U-  [        -
  PM     nn[        R                  " U4U R                  -   U
S	9n[        U5       H`  u  nn[!        U[        R"                  " UU-
  5      -  5      UUSS2SS24'   [        R$                  " UUSS2SS24   U5      UUSS2SS24'   Mb     US   /U-   n[        R                  " US-   4UR                  -   U
S	9n[        US-   5       H7  n[        U5       H%  n['        UUSS2SS24   X{   SS9UUUSS2SS24'   M'     M9     [        U5       Vs/ s H  nS[        -  U-  U-  PM     nnX4-  S-   U-  n[        R                  " UU R                  S   SU-  -
  U R                  S   SU-  -
  4U
S	9nUSSS2X"* 2X"* 24   USU2SS2SS24'   Un[        U5       H  n[        U5       H  nU[)        [+        X   [,        R.                  " UU   5      -  5      5      -   nUR                  S   U-   nU[)        [+        X   [,        R"                  " UU   5      -  5      5      -   nUR                  S   U-   nUUS-   SS2UU2UU24   UUUU-   2SS2SS24'   UU-  nM     M     USS2SSU2SSU24   nUR1                  SS5      R1                  SS5      nUS:w  a  US-  nUS:X  a1  U[        R2                  " USS9SS2SS2[        R4                  4   -  nOUS:X  a=  U[        [        R2                  " US-  SS95      SS2SS2[        R4                  4   -  nOyUS:X  as  [        SUU5       Hb  n[        [        R2                  " USS2SS2XU-   24   S-  SS95      nUSS2SS2XU-   24==   USS2SS2[        R4                  4   -  ss'   Md     U	(       Ga  [7        U 5      n[        UR                  S   5       GH  n[        UR                  S   5       GH  n/ SQn X-  U-   n!UU-  U-   n"[8        R:                  " U!U"[)        US   5      5      u  n#n$n%[8        R<                  " UU#U$4U U%S9  [        R>                  " UUUSS24   5      n&[        U5       H  u  n'nUUUU'4   U&-  n(US   U(-  [,        R.                  " U5      -  nUS   U(-  [,        R"                  " U5      -  n[8        R@                  " U!U"[)        U!U-   5      [)        U"U-   5      5      u  n#n$n%[8        R<                  " UU#U$4U U%S9  M     [        U5       GH  u  n)n*[        SU)-   5      U-  n+SU+-
  SU+4n [        U5       GHm  u  n,n-U![)        [+        U*[,        R.                  " U-5      -  5      5      -   n.U"[)        [+        U*[,        R"                  " U-5      -  5      5      -   n/[8        R:                  " U.U/[)        UU)S-      5      5      u  n#n$n%[8        R<                  " UU#U$4U U%S9  [        U5       H  u  n'nUUUUU)U-  U-  -   U,U-  -   U'-   4   n(U(U&-  n(UU)S-      U(-  [,        R.                  " U5      -  nUU)S-      U(-  [,        R"                  " U5      -  n[8        R@                  " U.U/[)        U.U-   5      [)        U/U-   5      5      u  n#n$n%[8        R<                  " UU#U$4U U%S9  M     GMp     GM     GM     GM     UU4$ U$ s  snf s  snf s  snf s  snf )a  Extract DAISY feature descriptors densely for the given image.

DAISY is a feature descriptor similar to SIFT formulated in a way that
allows for fast dense extraction. Typically, this is practical for
bag-of-features image representations.

The implementation follows Tola et al. [1]_ but deviate on the following
points:

  * Histogram bin contribution are smoothed with a circular Gaussian
    window over the tonal range (the angular range).
  * The sigma values of the spatial Gaussian smoothing in this code do not
    match the sigma values in the original code by Tola et al. [2]_. In
    their code, spatial smoothing is applied to both the input image and
    the center histogram. However, this smoothing is not documented in [1]_
    and, therefore, it is omitted.

Parameters
----------
image : (M, N) array
    Input image (grayscale).
step : int, optional
    Distance between descriptor sampling points.
radius : int, optional
    Radius (in pixels) of the outermost ring.
rings : int, optional
    Number of rings.
histograms : int, optional
    Number of histograms sampled per ring.
orientations : int, optional
    Number of orientations (bins) per histogram.
normalization : [ 'l1' | 'l2' | 'daisy' | 'off' ], optional
    How to normalize the descriptors

      * 'l1': L1-normalization of each descriptor.
      * 'l2': L2-normalization of each descriptor.
      * 'daisy': L2-normalization of individual histograms.
      * 'off': Disable normalization.

sigmas : 1D array of float, optional
    Standard deviation of spatial Gaussian smoothing for the center
    histogram and for each ring of histograms. The array of sigmas should
    be sorted from the center and out. I.e. the first sigma value defines
    the spatial smoothing of the center histogram and the last sigma value
    defines the spatial smoothing of the outermost ring. Specifying sigmas
    overrides the following parameter.

        ``rings = len(sigmas) - 1``

ring_radii : 1D array of int, optional
    Radius (in pixels) for each ring. Specifying ring_radii overrides the
    following two parameters.

        ``rings = len(ring_radii)``
        ``radius = ring_radii[-1]``

    If both sigmas and ring_radii are given, they must satisfy the
    following predicate since no radius is needed for the center
    histogram.

        ``len(ring_radii) == len(sigmas) + 1``

visualize : bool, optional
    Generate a visualization of the DAISY descriptors

Returns
-------
descs : array
    Grid of DAISY descriptors for the given image as an array
    dimensionality  (P, Q, R) where

        ``P = ceil((M - radius*2) / step)``
        ``Q = ceil((N - radius*2) / step)``
        ``R = (rings * histograms + 1) * orientations``

descs_img : (M, N, 3) array (only if visualize==True)
    Visualization of the DAISY descriptors.

References
----------
.. [1] Tola et al. "Daisy: An efficient dense descriptor applied to wide-
       baseline stereo." Pattern Analysis and Machine Intelligence, IEEE
       Transactions on 32.5 (2010): 815-830.
.. [2] http://cvlab.epfl.ch/software/daisy
r   imgN   z"`len(sigmas)-1 != len(ring_radii)`)l1l2daisyoffzInvalid normalization method.)dtype)naxisr   reflect)sigmamoder   g|=r   )r   r   r   )r   r   r   )alpha)!r   r	   r   len
ValueErrorrangefloatnpzerosshapediffr   r   r   empty	enumerater   cosmultiplyr
   introundmathsinswapaxessumnewaxisr   r   circle_perimeter_aa	set_colormaxline_aa)0imagestepradiusrings
histogramsorientationsnormalizationsigmas
ring_radii	visualizefloat_dtypeidxdygrad_maggrad_oriorientation_kappaoorientation_angleshisthist_smoothjtheta	desc_dimsdescsidxy_miny_maxx_minx_maxnorms	descs_imgcolordesc_ydesc_xrowscolsvalmax_bino_numbin_sizer_numrcolor_offsett_numthist_yhist_xs0                                                   V/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/feature/_daisy.pyr   r      s   D UAuE++K 	"K!Os:.=>>JBFa~?DU|L|!AE"U1u9%55|L?DU|L|!A&u5|
L88899 
%++[	1B	%++[	1B!!,Bq#2#vJ!!,BssAvJ BEBEM"HrH$r)BGBUVBUQ!a%"*|3b8BUV88\Oekk1ED,-1-x!|0DDEQ1WDAqM8<Q1W	 . Qi[6!F((EAI<$**4KHK519|$A&.Q1WVYY'K1a
# %  /4J.?@.?QVaZ*$.?E@#a'<7IHH	EKKNQZ/Q!f*1LME "-Q6'>6'>-Q!RE-<-A

C5\z"ASz}txxa7I'I!JKKEKKNU*ESz}txxa7I'I!JKKEKKNU*E4?Aq%+uU{25E#l**Aq01 <C #  !VtVVtV#$ENN1a ))!Q/E D RVVE*1a+;<<Ed"T"&&23Aq"**4DEEEg%1i6RVVE!Q4D0D*D$E$JQRSTaAL 0001U1a;K5LL1 7 UO	u{{1~&A5;;q>*!F*TF*"&":":FCq	N#dC y4,SI&&q!Qw0 )*< =HE1$Q5[1G;HX-;BX-;B&*llFRK(8#frk:J'OD$ NN9tTlEM !> !** 5HE1#(U#3e#;L-q,?E$-e$4q!'#eAO.D*E!E!'#eAO.D*E!E*.*B*B"FCuqy0A,B+dC y4,SQ(12D(EHE1', ! ! ,"'*"4|"C!D"',"6!7 #(!(!)(H %/H!'	!2X!=!KB!'	!2X!=!KB.2ll &FRK0@#frkBR/OD$ !NN9tTlEQTU! )F %5 !6' + '` iq ML W$ As    a;7b  bb
)	            rg   r   NNF)r*   numpyr    r   r   r   r    r   
util.dtyper	   _shared.filtersr
   _shared.utilsr   rS   r   r        rc   <module>ro      sC      ( (  % & $ 
 

lrn   