+
    Ai(                     r    ^ RI t^ RIt^ RIHt ^ RIHt ^RIH	t	H
t
 RR ltRRR/R lltR tR	 tR
 tR tR# )    N)linalg)SCIPY_GE_1_17_0_DEV0)_ncut_ncut_cyc                    V'       g   VP                  4       pVP                  RR7       UUUu. uF  w  rEqfR,          V8  g   K  WE3NK  	  ppppVP                  V4       \        P                  ! V4      p\
        P                  ! V P                  4       ^,           V P                  R7      p	\        V4       F3  w  rV F(  pVP                  V,          R,           F  pWV&   K	  	  K*  	  K5  	  W,          # u upppi )a-  Combine regions separated by weight less than threshold.

Given an image's labels and its RAG, output new labels by
combining regions whose nodes are separated by a weight less
than the given threshold.

Parameters
----------
labels : ndarray
    The array of labels.
rag : RAG
    The region adjacency graph.
thresh : float
    The threshold. Regions connected by edges with smaller weights are
    combined.
in_place : bool
    If set, modifies `rag` in place. The function will remove the edges
    with weights less that `thresh`. If set to `False` the function
    makes a copy of `rag` before proceeding.

Returns
-------
out : ndarray
    The new labelled array.

Examples
--------
>>> from skimage import data, segmentation, graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels)
>>> new_labels = graph.cut_threshold(labels, rag, 10)

References
----------
.. [1] Alain Tremeau and Philippe Colantoni
       "Regions Adjacency Graph Applied To Color Image Segmentation"
       :DOI:`10.1109/83.841950`

Tdataweightdtypelabels)copyedgesremove_edges_fromnxconnected_componentsnparangemaxr   	enumeratenodes)r   ragthreshin_placexyd	to_removecomps	map_arrayir   nodelabels   &&&&          V/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/graph/_graph_cut.pycut_thresholdr%   	   s    R hhj (+yydy';U';GA!{f?T!';IU)$##C(E
 		&**,*&,,?Ie$D422#$%  3  %
  Vs   C9C9rngc                  \         P                  P                  V4      pV'       g   VP                  4       pVP	                  4        F  pVP                  WwVR7       K  	  \        WW64       \         P                  ! V P                  4       ^,           V P                  R7      pVP	                  RR7       F  w  rV
R,          WR,          &   K  	  W,          # )a  Perform Normalized Graph cut on the Region Adjacency Graph.

Given an image's labels and its similarity RAG, recursively perform
a 2-way normalized cut on it. All nodes belonging to a subgraph
that cannot be cut further are assigned a unique label in the
output.

Parameters
----------
labels : ndarray
    The array of labels.
rag : RAG
    The region adjacency graph.
thresh : float
    The threshold. A subgraph won't be further subdivided if the
    value of the N-cut exceeds `thresh`.
num_cuts : int
    The number or N-cuts to perform before determining the optimal one.
in_place : bool
    If set, modifies `rag` in place. For each node `n` the function will
    set a new attribute ``rag.nodes[n]['ncut label']``.
max_edge : float, optional
    The maximum possible value of an edge in the RAG. This corresponds to
    an edge between identical regions. This is used to put self
    edges in the RAG.
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 `rng` is used to determine the starting point
    of `scipy.sparse.linalg.eigsh`.

Returns
-------
out : ndarray
    The new labeled array.

Examples
--------
>>> from skimage import data, segmentation, graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
>>> new_labels = graph.cut_normalized(labels, rag)

References
----------
.. [1] Shi, J.; Malik, J., "Normalized cuts and image segmentation",
       Pattern Analysis and Machine Intelligence,
       IEEE Transactions on, vol. 22, no. 8, pp. 888-905, August 2000.

)r
   r   Tr   
ncut labelr   )
r   randomdefault_rngr   r   add_edge_ncut_relabelzerosr   r   )r   r   r   num_cutsr   max_edger&   r"   r    nr   s   &&&&&&$    r$   cut_normalizedr1   G   s    ~ ))


$Chhj		T1  #x-)>I		t	$!"<	H+ %     c                T   \        VP                  4       4       UUu. uF  w  r#W,          '       g   K  VNK  	  ppp\        VP                  4       4       UUu. uF  w  r#W,          '       d   K  VNK  	  pppVP                  V4      pVP                  V4      pWg3# u uppi u uppi )a"  Compute resulting subgraphs from given bi-partition.

Parameters
----------
cut : array
    A array of booleans. Elements set to `True` belong to one
    set.
rag : RAG
    The Region Adjacency Graph.

Returns
-------
sub1, sub2 : RAG
    The two resulting subgraphs from the bi-partition.
)r   r   subgraph)cutr   r!   r0   nodes1nodes2sub1sub2s   &&      r$   partition_by_cutr:      s    4 &ciik2=2DAcffaa2F=%ciik2A2DA#&&aa2FA<<D<<D: >As   BBB$0B$c                l   \         P                  pV P                  4       pV P                  4       p\         P                  ! V \
        R7      p\         P                  ! WV4      '       d   Wt3# \         P                  ! WVVRR7       F*  pW8  p	\        P                  ! WV4      p
W8  g   K&  T	pT
pK,  	  Wt3# )a  Threshold an eigenvector evenly, to determine minimum ncut.

Parameters
----------
ev : array
    The eigenvector to threshold.
d : ndarray
    The diagonal matrix of the graph.
w : ndarray
    The weight matrix of the graph.
num_cuts : int
    The number of evenly spaced thresholds to check for.

Returns
-------
mask : array
    The array of booleans which denotes the bi-partition.
mcut : float
    The value of the minimum ncut.
r   F)endpoint)
r   infminr   
zeros_likeboolallcloselinspacer   	ncut_cost)evr   wr.   mcutmnmxmin_masktmaskcosts   &&&&       r$   get_min_ncutrM      s    * 66D	B	B
 }}Rt,H	{{2~ [[E:vt*;HD ; >r2   c                    \        V P                  4       4      pV P                  V,          R,          ^ ,          pV P                  RR7       F	  w  rEW5V&   K  	  R# )aQ  Assign a unique integer to the given attribute in the RAG.

This function assumes that all labels in `rag` are unique. It
picks up a random label from them and assigns it to the `attr_name`
attribute of all the nodes.

rag : RAG
    The Region Adjacency Graph.
attr_name : string
    The attribute to which a unique integer is assigned.
r   Tr   N)r>   r   )r   	attr_namer"   	new_labelr0   r   s   &&    r$   
_label_allrQ      sI     syy{D		$)!,I		t	$ ) %r2   c                z   \         P                  ! V 4      w  rEVP                  ^ ,          pV^8  Ed|   WE8g  P                  ^ 8  Edh   VP	                  4       p\
        P                  ! \
        P                  ! VP                  VP                  R7      VP                  R7      Vn        WtV,
          ,          V,          pVP                  VP                  ^ ,          4      p	\        '       d   RV/M/ p
\        P                  ! V3RRRV	R\        ^dV^,
          4      /V
B w  r\
        P                  ! V4      \
        P                  ! V4      r\        P                   ! V4      pVRV3,          p\#        WWR4      w  ppVV8  d+   \%        W4      w  pp\'        VWV4       \'        VWV4       R# \)        V R	4       R# )
a  Perform Normalized Graph cut on the Region Adjacency Graph.

Recursively partition the graph into 2, until further subdivision
yields a cut greater than `thresh` or such a cut cannot be computed.
For such a subgraph, indices to labels of all its nodes map to a single
unique value.

Parameters
----------
rag : RAG
    The region adjacency graph.
thresh : float
    The threshold. A subgraph won't be further subdivided if the
    value of the N-cut exceeds `thresh`.
num_cuts : int
    The number or N-cuts to perform before determining the optimal one.
random_generator : `numpy.random.Generator`
    Provides initial values for eigenvalue solver.
)outr&   whichSMv0k:NNNNr(   )r   DW_matricesshapennzr   r   
reciprocalsqrtr	   r)   r   r   eigshr>   realr   argmin2rM   r:   r,   rQ   )r   r   r.   random_generatorr   rE   md2ArV   rng_kwvalsvectorsindex2rD   cut_maskrF   r8   r9   s   &&&&               r$   r,   r,      se   ( S!DA	
A	AAF<<!# VVX --RWW =277K a%L2$$QWWQZ0 /C.B%)*QWdWrWSa!e_WPVW rwww'7g!!$'QY%bQ9$&= *(8JD$$2BC$2BC sL!r2   )T)gMbP?
   Tg      ?)networkxr   numpyr   scipy.sparser   skimage._shared.compatr    r   r   r%   r1   r:   rM   rQ   r,    r2   r$   <module>rp      sC       7 ;|M 	M` F)X!$G"r2   