Ë
    îì�i•  ã                   ó&   — d dl ZddlmZ dddœd„Zy)é    Né   )Úlabel)Úoutc                ó°  ‡— t        ˆfd„| j                  D «       «      r|€t        d«      ‚|€| j                  «       }|�_d|j                  › d|j                  › �}|j                  |j                  k7  rt        |f‚|j                  t
        k7  rt        d«      ‚| }n¨t        j                  |t
        ¬«      }‰dz   }t        |«      }t        | d«      }	|j                  D �
cg c]  }
t        d«      ‘Œ }}
t        |j                  «      D ]6  }|||<   d	|t        |«      <   |	||<   d	|t        |«      <   t        d«      ||<   Œ8 t        |d
d	¬«      \  } }t        j                  | |   «      }t        j                  |dz   «      }t        j                   ||«      }|| j#                  d«         j#                  | j                  «      }|||<   |S c c}
w )a²  Clear objects connected to the label image border.

    Parameters
    ----------
    labels : (M[, N[, ..., P]]) array of int or bool
        Imaging data labels.
    buffer_size : int, optional
        The width of the border examined.  By default, only objects
        that touch the outside of the image are removed.
    bgval : float or int, optional
        Cleared objects are set to this value.
    mask : ndarray of bool, same shape as `image`, optional.
        Image data mask. Objects in labels image overlapping with
        False pixels of mask will be removed. If defined, the
        argument buffer_size will be ignored.
    out : ndarray
        Array of the same shape as `labels`, into which the
        output is placed. By default, a new array is created.

    Returns
    -------
    out : (M[, N[, ..., P]]) array
        Imaging data labels with cleared borders

    Examples
    --------
    >>> import numpy as np
    >>> from skimage.segmentation import clear_border
    >>> labels = np.array([[0, 0, 0, 0, 0, 0, 0, 1, 0],
    ...                    [1, 1, 0, 0, 1, 0, 0, 1, 0],
    ...                    [1, 1, 0, 1, 0, 1, 0, 0, 0],
    ...                    [0, 0, 0, 1, 1, 1, 1, 0, 0],
    ...                    [0, 1, 1, 1, 1, 1, 1, 1, 0],
    ...                    [0, 0, 0, 0, 0, 0, 0, 0, 0]])
    >>> clear_border(labels)
    array([[0, 0, 0, 0, 0, 0, 0, 0, 0],
           [0, 0, 0, 0, 1, 0, 0, 0, 0],
           [0, 0, 0, 1, 0, 1, 0, 0, 0],
           [0, 0, 0, 1, 1, 1, 1, 0, 0],
           [0, 1, 1, 1, 1, 1, 1, 1, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0]])
    >>> mask = np.array([[0, 0, 1, 1, 1, 1, 1, 1, 1],
    ...                  [0, 0, 1, 1, 1, 1, 1, 1, 1],
    ...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
    ...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
    ...                  [1, 1, 1, 1, 1, 1, 1, 1, 1],
    ...                  [1, 1, 1, 1, 1, 1, 1, 1, 1]]).astype(bool)
    >>> clear_border(labels, mask=mask)
    array([[0, 0, 0, 0, 0, 0, 0, 1, 0],
           [0, 0, 0, 0, 1, 0, 0, 1, 0],
           [0, 0, 0, 1, 0, 1, 0, 0, 0],
           [0, 0, 0, 1, 1, 1, 1, 0, 0],
           [0, 1, 1, 1, 1, 1, 1, 1, 0],
           [0, 0, 0, 0, 0, 0, 0, 0, 0]])

    c              3   ó(   •K  — | ]	  }‰|k\  –— Œ y ­w)N© )Ú.0ÚsÚbuffer_sizes     €ú‡/var/www/ITT-ServiceAPI-Services/ITT-Document-Scan/mrzscanner/mrzenv/lib/python3.12/site-packages/skimage/segmentation/_clear_border.pyú	<genexpr>zclear_border.<locals>.<genexpr>?   s   øè ø€ Ò
2 ˆ;˜!ÕÑ
2ùs   ƒNz/buffer size may not be greater than labels sizez3labels and mask should have the same shape but are z and zmask should be of type bool.)Údtypeé   Tr   )Ú
backgroundÚ
return_numéÿÿÿÿ)ÚanyÚshapeÚ
ValueErrorÚcopyr   ÚboolÚ	TypeErrorÚnpÚ
zeros_likeÚsliceÚrangeÚndimÚtupler   ÚuniqueÚarangeÚisinÚreshape)Úlabelsr   ÚbgvalÚmaskr   Úerr_msgÚbordersÚextÚslstartÚslendÚ_ÚslicesÚdÚnumberÚborders_indicesÚindicesÚ
label_masks    `               r   Úclear_borderr2      s¼  ø€ ôr Ó
2 V§\¡\Ô
2Ô2°t°|äÐJÓKÐKà
€{Ø�k‰k‹mˆàÐðØ—9‘9�+˜U 4§:¡: ,ð0ð 	ð �9‰9˜Ÿ
™
Ò"Ü˜wÐ'Ð'Ø�:‰:œÒÜÐ:Ó;Ð;Ø�%‰ô —-‘- ¬4Ô0ˆØ˜A‰oˆÜ˜“*ˆÜ�s�d˜DÓ!ˆØ'*§y¡yÖ1 !”%˜•+Ð1ˆÐ1Ü�s—x‘x“ò 	$ˆAØˆF�1‰IØ%)ˆG”E˜&“MÑ"ØˆF�1‰IØ%)ˆG”E˜&“MÑ"Ü˜d›ˆF�1ŠIð	$ô ˜3¨1¸Ô>�N€FˆFô —i‘i  w¡Ó0€OÜ�i‰i˜ ™
Ó#€Gä—‘˜ /Ó2€Jà�f—n‘n RÓ(Ñ)×1Ñ1°&·,±,Ó?€Dð €Cˆ�Ià€Jùò/ 2s   Ã&G)r   r   N)Únumpyr   Úmeasurer   r2   r   ó    r   ú<module>r6      s   ðÛ å ðgÀ4õ gr5   