+
    Ai                          R t ^ RIHt ^ RIt^ RIHtHt ^RIH	t	 ^RI
Ht ^RIHt ^RIHt ^RIHt R	R
.tR tR tRR ltR^/R ltR# )zConvex Hull.)productN)
ConvexHull
QhullError)grid_points_in_poly)possible_hull)label)unique_rows)warnconvex_hull_imageconvex_hull_objectc                     \         P                  ! ^V ,          V 34      p\        \        \	        V 4      R4      4       F  w  pw  r4WAW#3&   K  	  V# )   )g      g      ?)npzeros	enumerater   range)ndimoffsetsvertexaxisoffsets   &    \/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/morphology/convex_hull.py_offsets_diamondr      sJ    hhD$'(G"+GE$K,M"N & #ON    c                <   V P                   w  r4VP                   ^ ,          p\        P                  ! V\        R7      p\        P                  ! V\        P
                  R7      p\        P                  ! V\        P
                  R7      p\        P                  ! V\        R7      p	\        V4       Fg  p
\        P                  ! WRV13,          WR7       \        P                  ! WqWR13,          VR7       \        P                  ! WV	R7       Wi,          pKi  	  V# )a  Checks all the coordinates for inclusiveness in the convex hull.

Parameters
----------
gridcoords : (M, N) ndarray
    Coordinates of ``N`` points in ``M`` dimensions.
hull_equations : (M, N) ndarray
    Hyperplane equations of the facets of the convex hull.
tolerance : float
    Tolerance when determining whether a point is inside the hull. Due
    to numerical floating point errors, a tolerance of 0 can result in
    some points erroneously being classified as being outside the hull.

Returns
-------
coords_in_hull : ndarray of bool
    Binary 1D ndarray representing points in n-dimensional space
    with value ``True`` set for points inside the convex hull.

Notes
-----
Checking the inclusiveness of coordinates in a convex hull requires
intermediate calculations of dot products which are memory-intensive.
Thus, the convex hull equations are checked individually with all
coordinates to keep within the memory limit.

References
----------
.. [1] https://github.com/scikit-image/scikit-image/issues/5019

dtypeN)out)
shaper   onesboolemptyfloat64r   dotaddless)
gridcoordshull_equations	tolerancer   n_coordsn_hull_equationscoords_in_hull	dot_arraytest_ineq_tempcoords_single_ineqidxs   &&&        r   _check_coords_in_hullr0      s    @  %%ND%++A.WWXT2N 4IXXhbjj9N($7 %&
~5D5j):E
ye4.I
/AB, ' r   c           	        V P                   p\        P                  ! V 4      ^ 8X  d7   \        R\        4       \        P
                  ! V P                  \        R7      # V^8X  d1   \        \        P                  ! V \        P                  R7      4      pM[\        P                  ! \        P                  ! V 4      4      pV'       d*    \        V4      pTP                  TP                   ,          pV'       dG   \#        V P                   4      pVR\        P$                  R3,          V,           P'                  RV4      p\)        V4      p \        V4      p	T	P                  T	P                   ,          p
T^8X  d/   \+        T P                  T
RR7      pT'       d   T^8  pT# T^8H  pT# \        P&                  ! \        P,                  \/        \1        \2        T P                  4      4      ,          TR34      p\5        YP6                  T4      p\        P&                  ! YP                  4      pT#   \         d?   p\        RT 24       \        P
                  ! T P                  \        R7      u Rp?# Rp?ii ; i  \         d?   p\        RT 24       \        P
                  ! T P                  \        R7      u Rp?# Rp?ii ; i)	a@  Compute the convex hull image of a binary image.

The convex hull is the set of pixels included in the smallest convex
polygon that surround all white pixels in the input image.

Parameters
----------
image : array
    Binary input image. This array is cast to bool before processing.
offset_coordinates : bool, optional
    If ``True``, a pixel at coordinate, e.g., (4, 7) will be represented
    by coordinates (3.5, 7), (4.5, 7), (4, 6.5), and (4, 7.5). This adds
    some "extent" to a pixel when computing the hull.
tolerance : float, optional
    Tolerance when determining whether a point is inside the hull. Due
    to numerical floating point errors, a tolerance of 0 can result in
    some points erroneously being classified as being outside the hull.
include_borders : bool, optional
    If ``False``, vertices/edges are excluded from the final hull mask.

Returns
-------
hull : (M, N) array of bool
    Binary image with pixels in convex hull set to True.

References
----------
.. [1] https://blogs.mathworks.com/steve/2011/10/04/binary-image-convex-hull-algorithm-notes/

zIInput image is entirely zero, no valid convex hull. Returning empty imager   zQFailed to get convex hull image. Returning empty image, see error message below:
N:NNNF)binarize)r   r   count_nonzeror	   UserWarningr   r   r    r   ascontiguousarrayuint8	transposenonzeror   r   pointsverticesr   newaxisreshaper   r   mgridtuplemapslicer0   	equations)imageoffset_coordinatesr(   include_bordersr   coordshull0errr   hullr;   labelsmaskr&   r+   s   &&&&           r   r
   r
   J   s,   B ::D	!#$	

 xx400 qyr33EJKbjj/09"6* \\%..1F "5::.BJJ)*W4==b$G  F1&! {{4==)H qy$U[[(UK .v{ K 4:Q; K ZZs5%++/F)G H4QS*U
.z>>9Uzz.++6KU  9He
 xx4889*  1@e	

 xx4001s<   H. 
I: .I793I2,I72I7:K3J>8K>Kconnectivityc                  V P                   ^8  d   \        R4      hVR9  d   \        R4      h\        W^ R7      p\        P                  ! V P
                  \        R7      p\        P                  ! V P
                  \        R7      p\        ^VP                  4       ^,           4       F&  p\        W%8H  4      p\        P                  ! WC4      pK(  	  V# )a  Compute the convex hull image of individual objects in a binary image.

The convex hull is the set of pixels included in the smallest convex
polygon that surround all white pixels in the input image.

Parameters
----------
image : (M, N) ndarray
    Binary input image.
connectivity : {1, 2}, int, optional
    Determines the neighbors of each pixel. Adjacent elements
    within a squared distance of ``connectivity`` from pixel center
    are considered neighbors.::

        1-connectivity      2-connectivity
              [ ]           [ ]  [ ]  [ ]
               |               \  |  /
         [ ]--[x]--[ ]      [ ]--[x]--[ ]
               |               /  |  \
              [ ]           [ ]  [ ]  [ ]

Returns
-------
hull : ndarray of bool
    Binary image with pixels inside convex hull set to ``True``.

Notes
-----
This function uses ``skimage.morphology.label`` to define unique objects,
finds the convex hull of each using ``convex_hull_image``, and combines
these regions with logical OR. Be aware the convex hulls of unconnected
objects may overlap in the result. If this is suspected, consider using
convex_hull_image separately on each object or adjust ``connectivity``.
zInput must be a 2D imagez%`connectivity` must be either 1 or 2.)rL   
backgroundr   )   r   )r   
ValueErrorr   r   r   r   r    r   maxr
   
logical_or)rC   rL   
labeled_im
convex_obj
convex_imgis   &$    r   r   r      s    F zzA~3446!@AAuAFJ%++T2J%++T2J1jnn&*+&z7
]]::
 , r   )Tg|=T)__doc__	itertoolsr   numpyr   scipy.spatialr   r   measure.pnpolyr   _convex_hullr   measure._labelr   utilr   _shared.utilsr	   __all__r   r0   r
   r    r   r   <module>rb      sI       0 0 ' "    4
51h`F1a 1r   