
    9i.                         S SK rS SKJrJrJr  SSKJr  SSKJ	r	  SSK
JrJr  SSKJr  SS	KJrJrJr  SS
KJr  / SQr/ SQr/ SQr/ SQrS rS rS rS r " S S\5      rg)    N)maximum_filterminimum_filterconvolve   )integral_image   structure_tensor)octagonstar)_censure_dob_loop)FeatureDetector_prepare_grayscale_input_2D_mask_border_keypoints)check_nD)   r   r      )   r   )	      r   r   )   r   )   
   )r      r      )   r   )r       ))r   r   r   r   )r   r   r   r   )r   r   )r   r   )r   r   )r      r   r#   r   )r   r   r   r   r#      r   r                -   .   @   Z      ))r   r   r"   )r   r   r   )r   r   )r%   r   r$   )r   r%   )r   r   )r!   r   r   )r&   r!   c           
      v   [         R                  " U R                  S   U R                  S   X!-
  S-   4[         R                  S9nUS:X  a  UR                  nXTR                  S   -  UXTR                  S   -  UR                  S   -  4Ul        [        U 5      n[        X!-
  S-   5       H=  nX-   nSSU-  S-   S-  -  n	SSUS-  -  SU-  -   -  n
[        XUS S 2S S 2U4   X5        M?     U$ US	:X  aY  [        X!-
  S-   5       HC  n[        X-   S-
     u  p[        X-   S-
     u  p[        U [        XX5      5      US S 2S S 2U4'   ME     U$ US
:X  af  [        X!-
  S-   5       HR  n[        [        X-   S-
     S      n[        [        X-   S-
     S      n[        U [        X5      5      US S 2S S 2U4'   MT     U$ )Nr   r   dtypedob      ?r   r   r   r   r   )npzerosshapefloat64itemsizestridesr   ranger   OCTAGON_OUTER_SHAPEOCTAGON_INNER_SHAPEr   _octagon_kernel
STAR_SHAPESTAR_FILTER_SHAPE_star_kernel)image	min_scale	max_scalemoderesponse	item_sizeintegral_imgininner_weightouter_weightmonominims                   W/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/feature/censure.py_filter_imagerR   B   s   xx	QQ)>)BC2::H u}%%	q))q))HNN1,==
 &e,y,q01AA
 !a%!)!11L"q!t)a!e"34L!Q'!2L 2@ O 
	 y,q01A():;FB():;FB (0O PHQ1W 2 O 
y,q01A,Y]Q->?BCA,Y]Q->?BCA (Q0B CHQ1W 2
 O    c                 @   U SU-  -   S-  SU-  US-   -  -
  nUSU-  -   S-  SU-  US-   -  -
  nSXE-
  -  nSU-  nU SU-  -   USU-  -   -
  S-  n[        X5      n	[        R                  " U SU-  -   U SU-  -   45      n
[        X#5      XU* 2X* 24'   Xi-  Xg-   U
-  -
  nU$ )Nr   r   r3   )r   r4   r5   )rL   rM   rN   rO   outerinnerrK   rJ   c	outer_oct	inner_octbfilters               rQ   r=   r=   u   s    !b&[QR26!22E!b&[QR26!22E%-(L;L
q2v+"q2v+	&1,AI"q2v+rAF{34I#BOIdAbDj&,*E)RRGNrS   c                    X S-  -   U-
  US-  -
  n[        U 5      n[        R                  " U5      n[        U5      XBU* 2X"* 24'   S[        R                  " X4-
  5      -  nS[        R                  " U5      -  nXS-  XV-   U-  -
  nU$ )Nr   r3   )r   r4   
zeros_likesum)rP   rI   rW   
outer_star
inner_starrK   rJ   rZ   s           rQ   r@   r@      s    	F
QaAaJz*J!!WJ!tQrTz"&&!89:L
++L'<+F**TTGNrS   c                 N    [        XSS9u  pEnSXU-   S-  X4U-  US-  -
  -  :  '   g )Nrc)orderFr   r	   )feature_maskrA   sigmaline_thresholdArrArcAccs          rQ   _suppress_linesri      s8    $U>MCcMRL)!NCi#q&6H$IIJrS   c                   2    \ rS rSrSr     SS jrS rSrg)CENSURE   am  CENSURE keypoint detector.

min_scale : int, optional
    Minimum scale to extract keypoints from.
max_scale : int, optional
    Maximum scale to extract keypoints from. The keypoints will be
    extracted from all the scales except the first and the last i.e.
    from the scales in the range [min_scale + 1, max_scale - 1]. The filter
    sizes for different scales is such that the two adjacent scales
    comprise of an octave.
mode : {'DoB', 'Octagon', 'STAR'}, optional
    Type of bi-level filter used to get the scales of the input image.
    Possible values are 'DoB', 'Octagon' and 'STAR'. The three modes
    represent the shape of the bi-level filters i.e. box(square), octagon
    and star respectively. For instance, a bi-level octagon filter consists
    of a smaller inner octagon and a larger outer octagon with the filter
    weights being uniformly negative in both the inner octagon while
    uniformly positive in the difference region. Use STAR and Octagon for
    better features and DoB for better performance.
non_max_threshold : float, optional
    Threshold value used to suppress maximas and minimas with a weak
    magnitude response obtained after Non-Maximal Suppression.
line_threshold : float, optional
    Threshold for rejecting interest points which have ratio of principal
    curvatures greater than this value.

Attributes
----------
keypoints : (N, 2) array
    Keypoint coordinates as ``(row, col)``.
scales : (N,) array
    Corresponding scales.

References
----------
.. [1] Motilal Agrawal, Kurt Konolige and Morten Rufus Blas
       "CENSURE: Center Surround Extremas for Realtime Feature
       Detection and Matching",
       https://link.springer.com/chapter/10.1007/978-3-540-88693-8_8
       :DOI:`10.1007/978-3-540-88693-8_8`

.. [2] Adam Schmidt, Marek Kraft, Michal Fularz and Zuzanna Domagala
       "Comparative Assessment of Point Feature Detectors and
       Descriptors in the Context of Robot Navigation"
       http://yadda.icm.edu.pl/yadda/element/bwmeta1.element.baztech-268aaf28-0faf-4872-a4df-7e2e61cb364c/c/Schmidt_comparative.pdf
       :DOI:`10.1.1.465.1117`

Examples
--------
>>> from skimage.data import astronaut
>>> from skimage.color import rgb2gray
>>> from skimage.feature import CENSURE
>>> img = rgb2gray(astronaut()[100:300, 100:300])
>>> censure = CENSURE()
>>> censure.detect(img)
>>> censure.keypoints
array([[  4, 148],
       [ 12,  73],
       [ 21, 176],
       [ 91,  22],
       [ 93,  56],
       [ 94,  22],
       [ 95,  54],
       [100,  51],
       [103,  51],
       [106,  67],
       [108,  15],
       [117,  20],
       [122,  60],
       [125,  37],
       [129,  37],
       [133,  76],
       [145,  44],
       [146,  94],
       [150, 114],
       [153,  33],
       [154, 156],
       [155, 151],
       [184,  63]])
>>> censure.scales
array([2, 6, 6, 2, 4, 3, 2, 3, 2, 6, 3, 2, 2, 3, 2, 2, 2, 3, 2, 2, 4, 2,
       2])

c                     UR                  5       nUS;  a  [        S5      eUS:  d  US:  d  X!-
  S:  a  [        S5      eXl        X l        X0l        X@l        XPl        S U l        S U l        g )N)r2   r   r   z/`mode` must be one of 'DoB', 'Octagon', 'STAR'.r   r   z@The scales must be >= 1 and the number of scales should be >= 3.)	lower
ValueErrorrB   rC   rD   non_max_thresholdre   	keypointsscales)selfrB   rC   rD   rp   re   s         rQ   __init__CENSURE.__init__   sv     zz|11NOOq=IMY-BQ-FU  #"	!2,rS   c                 $   [        US5        U R                  U R                  -
  n[        R                  " [        U5      5      n[        XR                  U R                  U R                  5      n[        US5      U:H  n[        US5      U:H  nXE-  nSXcU R                  :  '   [        SU5       H;  n[        USS2SS2U4   USU R                  U-   S-
  S-  -   U R                  5        M=     [        R                  " USSU24   5      u  pn
[        R                  " X/5      nXR                  -   S-   n
U R                  S:X  a  Xl        Xl        g[        R$                  " UR&                  S	   [(        S
9nU R                  S:X  an  [        U R                  S-   U R                  5       HF  n[*        US-
     S	   S-
  S-  [*        US-
     S   -   nU[-        UR&                  X5      X:H  -  -  nMH     OU R                  S:X  ax  [        U R                  S-   U R                  5       HQ  n[.        [0        US-
     S	      [.        [0        US-
     S	      S-  -   nU[-        UR&                  X5      X:H  -  -  nMS     X   U l        X   U l        g)zyDetect CENSURE keypoints along with the corresponding scale.

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

r   )r   r   r   Fr   Ng      @.r2   r   r0   r   r   )r   rC   rB   r4   ascontiguousarrayr   rR   rD   r   r   rp   r:   ri   re   nonzerocolumn_stackrq   rr   r5   r6   boolr;   r   r>   r?   )rs   rA   
num_scalesfilter_responseminimasmaximasrc   rH   rowscolsrr   rq   cumulative_maskrW   s                 rQ   detectCENSURE.detect  s   0 	^^dnn4
$$%@%GH (>>4>>499
 !)<O )<O(AFt'='==>q*%A
 Q1W%dnnq(1,33##	 &  ZZS!J,5F(GHFOOTL1	..(1,99&N K((9??1#5TB99	!4>>A-t~~>(Q/2Q61<?RE@@   #9%++y#TK$ 	 ? YY& 4>>A-t~~>0Q7:; !21q5!9!!<=BC   #9%++y#TK$  ? #3-rS   )rq   re   rC   rB   rD   rp   rr   N)r   r   DoBg333333?r   )__name__
__module____qualname____firstlineno____doc__rt   r   __static_attributes__ rS   rQ   rk   rk      s%    Sn 4U.rS   rk   )numpyr4   scipy.ndimager   r   r   	transformr   cornerr
   
morphologyr   r   
censure_cyr   feature.utilr   r   r   _shared.utilsr   r;   r<   r>   r?   rR   r=   r@   ri   rk   r   rS   rQ   <module>r      sm     B B & $ & ) 
 %    M
  0f
S
E.o E.rS   