
    9i                     P    S SK rS SKJrJr  S rS\R                  SS4SS.S jjrg)	    N)cKDTreedistancec                    [        U 5      nUR                  XUS9n[        5       nSn[        U5       H  u  pX;  d  M  U	R	                  U5        [
        R                  " X   /X	   SUS9R                  S5      n
[        X5       VVs/ s H  u  pX:  d  M  UPM     n	nnUR                  U	5        US-  nUc  M  Xs:  d  M    O   [        R                  " U [        U5      SS9nUb  USU nU$ s  snnf )	a  Returns a subset of coord where a minimum spacing is guaranteed.

Parameters
----------
coord : ndarray
    The coordinates of the considered points.
spacing : float
    the maximum allowed spacing between the points.
p_norm : float
    Which Minkowski p-norm to use. Should be in the range [1, inf].
    A finite large p may cause a ValueError if overflow can occur.
    ``inf`` corresponds to the Chebyshev distance and 2 to the
    Euclidean distance.
max_out: int
    If not None, at most the first ``max_out`` candidates are
    returned.

Returns
-------
output : ndarray
    A subset of coord where a minimum spacing is guaranteed.

)rpr   	minkowski)r      N)axis)r   query_ball_pointset	enumerateremover   cdistreshapezipupdatenpdeletetuple)coordspacingp_normmax_outtreeindicesrejected_peaks_indices	nacceptedidx
candidatesdistcdoutputs                 U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/_shared/coord.py_ensure_spacingr&      s    4 5>D##E#?G UI$W-,c">>e/gbk  ),J(=M(=!(=JM #))*5NI"y'; .  YYue$:;!DF!M Ns   	C0C0r
   2   i  )max_split_sizec                
   U n[        U 5      (       a  [        R                  " U 5      n Uc  U /nOc[        U 5      nU/n	Un
XS   -
  U:  a2  U
S-  n
U	R                  U	S   [	        X5      -   5        XS   -
  U:  a  M2  [        R
                  " X	5      n[        R                  " SU R                  S   4U R                  S9nU H<  n[        [        R                  " Xk/5      XU5      nUc  M*  [        U5      U:  d  M;    U$    U$ )a/  Returns a subset of coord where a minimum spacing is guaranteed.

Parameters
----------
coords : array_like
    The coordinates of the considered points.
spacing : float
    the maximum allowed spacing between the points.
p_norm : float
    Which Minkowski p-norm to use. Should be in the range [1, inf].
    A finite large p may cause a ValueError if overflow can occur.
    ``inf`` corresponds to the Chebyshev distance and 2 to the
    Euclidean distance.
min_split_size : int
    Minimum split size used to process ``coords`` by batch to save
    memory. If None, the memory saving strategy is not applied.
max_out : int
    If not None, only the first ``max_out`` candidates are returned.
max_split_size : int
    Maximum split size used to process ``coords`` by batch to save
    memory. This number was decided by profiling with a large number
    of points. Too small a number results in too much looping in
    Python instead of C, slowing down the process, while too large
    a number results in large memory allocations, slowdowns, and,
    potentially, in the process being killed -- see gh-6010. See
    benchmark results `here
    <https://github.com/scikit-image/scikit-image/pull/6035#discussion_r751518691>`_.

Returns
-------
output : array_like
    A subset of coord where a minimum spacing is guaranteed.

r	      r   r
   )dtype)lenr   
atleast_2dappendminarray_splitzerosshaper+   r&   vstack)coordsr   r   min_split_sizer   r(   r$   
batch_listcoord_count	split_idx
split_sizebatchs               r%   ensure_spacingr;   ;   s   V F
6{{v&! Jf+K'(I'J"->a
  2Z1P!PQ "-> :J1fll1o.fllCE$		6/*GWF "s6{g'=M   M    )numpyr   scipy.spatialr   r   r&   infr;    r<   r%   <module>rA      s4     +3p 66A Ar<   