
    9i                     h    S SK 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	S
.S jjrg)    N   )gaussian)_supported_float_type)rgb2lab)img_as_float   )_quickshift_cython)channel_axisc                   [        [        R                  " U 5      5      n [        U R                  5      n	U R                  U	SS9n U R                  S:  a  [        S5      e[        R                  " XSS9n U(       a)  U R                  S   S:w  a  [        S5      e[        U 5      n US:  a  [        S	5      e[        XUS
/SSS9n [        R                  " X-  5      n [        U UUUUS9n
U
$ )a  Segment image using quickshift clustering in Color-(x,y) space.

Produces an oversegmentation of the image using the quickshift mode-seeking
algorithm.

Parameters
----------
image : (M, N, C) ndarray
    Input image. The axis corresponding to color channels can be specified
    via the `channel_axis` argument.
ratio : float, optional, between 0 and 1
    Balances color-space proximity and image-space proximity.
    Higher values give more weight to color-space.
kernel_size : float, optional
    Width of Gaussian kernel used in smoothing the
    sample density. Higher means fewer clusters.
max_dist : float, optional
    Cut-off point for data distances.
    Higher means fewer clusters.
return_tree : bool, optional
    Whether to return the full segmentation hierarchy tree and distances.
sigma : float, optional
    Width for Gaussian smoothing as preprocessing. Zero means no smoothing.
convert2lab : bool, optional
    Whether the input should be converted to Lab colorspace prior to
    segmentation. For this purpose, the input is assumed to be RGB.
rng : {`numpy.random.Generator`, int}, optional
    Pseudo-random number generator.
    By default, a PCG64 generator is used (see :func:`numpy.random.default_rng`).
    If `rng` is an int, it is used to seed the generator.

    The PRNG is used to break ties, and is seeded with 42 by default.
channel_axis : int, optional
    The axis of `image` corresponding to color channels. Defaults to the
    last axis.

Returns
-------
segment_mask : (M, N) ndarray
    Integer mask indicating segment labels.

Notes
-----
The authors advocate to convert the image to Lab color space prior to
segmentation, though this is not strictly necessary. For this to work, the
image must be given in RGB format.

References
----------
.. [1] Quick shift and kernel methods for mode seeking,
       Vedaldi, A. and Soatto, S.
       European Conference on Computer Vision, 2008
F)copy   z"Only 2D color images are supportedr
   )sourcedestinationz.Only RGB images can be converted to Lab space.r   z`kernel_size` should be >= 1.r   reflect)sigmamoder   )kernel_sizemax_distreturn_treerng)r   np
atleast_3dr   dtypeastypendim
ValueErrormoveaxisshaper   r   ascontiguousarrayr	   )imageratior   r   r   r   convert2labr   r   float_dtypesegment_masks              `/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/segmentation/_quickshift.py
quickshiftr'   
   s    D u-.E'4KLL5L1EzzA~=>> KKCE;;r?aMNNQ899U%"3)RTUE  /E%L     )g      ?   
   Fr   T*   )numpyr   _shared.filtersr   _shared.utilsr   colorr   utilr   _quickshift_cyr	   r'    r(   r&   <module>r3      s?     & 1   .
 

^ ^r(   