Ë
    îì�i(  ã                   ó(   — d dl Zdd„Z G d„ d«      Zy)é    Nc                 ó|  — ddl m} t        j                  | j                  t        j
                  «      st        d«      ‚| j                  }| j                  d«      } |€"t        j                  ||j                  ¬«      }n+|j                  |k7  rt        d|› d|j                  › d�«      ‚	 |j                  «       }d	|_        |j                  | j                  d¬«      }|j                  |j                  d¬«      } || |||«       |S # t        $ r' t        d
|j                  › d|j                  › d�«      ‚w xY w)a  Map values from input array from input_vals to output_vals.

    Parameters
    ----------
    input_arr : array of int, shape (M[, ...])
        The input label image.
    input_vals : array of int, shape (K,)
        The values to map from.
    output_vals : array, shape (K,)
        The values to map to.
    out : array, same shape as `input_arr`
        The output array. Will be created if not provided. It should
        have the same dtype as `output_vals`.

    Returns
    -------
    out : array, same shape as `input_arr`
        The array of mapped values.

    Notes
    -----
    If `input_arr` contains values that aren't covered by `input_vals`, they
    are set to 0.

    Examples
    --------
    >>> import numpy as np
    >>> import skimage as ski
    >>> ski.util.map_array(
    ...    input_arr=np.array([[0, 2, 2, 0], [3, 4, 5, 0]]),
    ...    input_vals=np.array([1, 2, 3, 4, 6]),
    ...    output_vals=np.array([6, 7, 8, 9, 10]),
    ... )
    array([[0, 7, 7, 0],
           [8, 9, 0, 0]])
    é   )Ú
_map_arrayz7The dtype of an array to be remapped should be integer.éÿÿÿÿ©ÚdtypezbIf out array is provided, it should have the same shape as the input array. Input array has shape z", provided output array has shape ú.)r   z`If out array is provided, it should be either contiguous or 1-dimensional. Got array with shape z and strides F©Úcopy)Ú_remapr   ÚnpÚ
issubdtyper   ÚintegerÚ	TypeErrorÚshapeÚreshapeÚemptyÚ
ValueErrorÚviewÚAttributeErrorÚstridesÚastype)Ú	input_arrÚ
input_valsÚoutput_valsÚoutr   Ú
orig_shapeÚout_views          ú|/var/www/ITT-ServiceAPI-Services/ITT-Document-Scan/mrzscanner/mrzenv/lib/python3.12/site-packages/skimage/util/_map_array.pyÚ	map_arrayr       s9  € õJ #ä�=‰=˜Ÿ™¬"¯*©*Ô5ÜÐQÓRÐRà—‘€Jð ×!Ñ! "Ó%€IØ
€{Ü�h‰h�z¨×):Ñ):Ô;‰Ø	�‰�jÒ	 Üð6Ø6@°\ð B&Ø&)§i¡i [°ð3ó
ð 	
ð

Ø—8‘8“:ˆØˆŒð ×"Ñ" 9§?¡?¸Ð"Ó?€JØ×$Ñ$ S§Y¡Y°UÐ$Ó;€KÙˆy˜( J°Ô<Ø€Jøô ò 
Üð6Ø69·i±i°[ð AØ—{‘{�m 1ð&ó
ð 	
ð
ús   Â-D Ä0D;c                   óR   — e Zd ZdZd„ Zd„ Zdd„Zed„ «       Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zy)ÚArrayMapu  Class designed to mimic mapping by NumPy array indexing.

    This class is designed to replicate the use of NumPy arrays for mapping
    values with indexing:

    >>> values = np.array([0.25, 0.5, 1.0])
    >>> indices = np.array([[0, 0, 1], [2, 2, 1]])
    >>> values[indices]
    array([[0.25, 0.25, 0.5 ],
           [1.  , 1.  , 0.5 ]])

    The issue with this indexing is that you need a very large ``values``
    array if the values in the ``indices`` array are large.

    >>> values = np.array([0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0])
    >>> indices = np.array([[0, 0, 10], [0, 10, 10]])
    >>> values[indices]
    array([[0.25, 0.25, 1.  ],
           [0.25, 1.  , 1.  ]])

    Using this class, the approach is similar, but there is no need to
    create a large values array:

    >>> in_indices = np.array([0, 10])
    >>> out_values = np.array([0.25, 1.0])
    >>> values = ArrayMap(in_indices, out_values)
    >>> values
    ArrayMap(array([ 0, 10]), array([0.25, 1.  ]))
    >>> print(values)
    ArrayMap:
      0 â†’ 0.25
      10 â†’ 1.0
    >>> indices = np.array([[0, 0, 10], [0, 10, 10]])
    >>> values[indices]
    array([[0.25, 0.25, 1.  ],
           [0.25, 1.  , 1.  ]])

    Parameters
    ----------
    in_values : array of int, shape (K,)
        The source values from which to map.
    out_values : array, shape (K,)
        The destination values from which to map.
    c                 ó<   — || _         || _        d| _        d | _        y )Né   )Ú	in_valuesÚ
out_valuesÚ_max_str_linesÚ_array)Úselfr%   r&   s      r   Ú__init__zArrayMap.__init__z   s   € Ø"ˆŒØ$ˆŒØˆÔØˆ�ó    c                 óF   — t        j                  | j                  «      dz   S )z<Return one more than the maximum label value being remapped.r   )r   Úmaxr%   ©r)   s    r   Ú__len__zArrayMap.__len__€   s   € ä�v‰v�d—n‘nÓ%¨Ñ)Ð)r+   Nc                 óÖ   — |€| j                   j                  }t        j                  t        j                  | j
                  «      dz   |¬«      }| j                   || j
                  <   |S )z¼Return an array that behaves like the arraymap when indexed.

        This array can be very large: it is the size of the largest value
        in the ``in_vals`` array, plus one.
        r   r   )r&   r   r   Úzerosr-   r%   )r)   r   r   Úoutputs       r   Ú	__array__zArrayMap.__array__„   sQ   € ð ˆ=Ø—O‘O×)Ñ)ˆEÜ—‘œ"Ÿ&™& §¡Ó0°1Ñ4¸EÔBˆØ!%§¡ˆˆt�~‰~ÑØˆr+   c                 ó.   — | j                   j                  S ©N)r&   r   r.   s    r   r   zArrayMap.dtype�   s   € à�‰×$Ñ$Ð$r+   c                 ó`   — dt        | j                  «      › dt        | j                  «      › d�S )Nz	ArrayMap(z, ú))Úreprr%   r&   r.   s    r   Ú__repr__zArrayMap.__repr__”   s+   € Øœ4 §¡Ó/Ð0°´4¸¿¹Ó3HÐ2IÈÐKÐKr+   c                 ó®  — t        | j                  «      | j                  dz   k  rct        t        | j                  «      «      }dj	                  dg|D �cg c]$  }d| j                  |   › d| j
                  |   › �‘Œ& c}z   «      }|S t        t        d| j                  dz  «      «      }t        t        | j                   dz  d«      «      }dj	                  dg|D �cg c]$  }d| j                  |   › d| j
                  |   › �‘Œ& c}z   dgz   |D �cg c]$  }d| j                  |   › d| j
                  |   › �‘Œ& c}z   «      }|S c c}w c c}w c c}w )	Nr   ú
z	ArrayMap:z  u    â†’ r   é   z  ...)Úlenr%   r'   ÚrangeÚjoinr&   Úlist)r)   ÚrowsÚiÚstringÚrows0Úrows1s         r   Ú__str__zArrayMap.__str__—   s^  € Üˆt�~‰~Ó $×"5Ñ"5¸Ñ"9Ò9Üœ˜TŸ^™^Ó,Ó-ˆDØ—Y‘YØ�ØNRÖSÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÒDÒSñTóˆFð ˆô œ˜q $×"5Ñ"5¸Ñ":Ó;Ó<ˆEÜœ × 3Ñ 3Ð3°qÑ8¸!Ó<Ó=ˆEØ—Y‘YØ�ØNSÖTÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÒDÒTñUà�)ñð OTÖTÈ�R˜Ÿ™ qÑ)Ð*¨%°·±ÀÑ0BÐ/CÒDÒTñUóˆFð ˆùò Tùò UùâTs   Á)E
Ã)E
Ä)E
c                 ó$   — | j                  |«      S r5   )Ú__getitem__)r)   Úarrs     r   Ú__call__zArrayMap.__call__©   s   € Ø×Ñ Ó$Ð$r+   c                 ó  — t        j                  |«      }|rt        j                  |g«      }nft        |t        «      rV|j
                  xs d}|j                  �|j                  n
t        | «      }|j                  }t        j                  |||«      }|j                  t        k(  rt        j                  |«      }t        || j                  j                  |j                  d¬«      | j                   «      }|r|d   }|S )Nr   Fr
   )r   ÚisscalarÚarrayÚ
isinstanceÚsliceÚstartÚstopr=   ÚstepÚaranger   ÚboolÚflatnonzeror    r%   r   r&   )r)   ÚindexÚscalarrP   rQ   rR   r   s          r   rH   zArrayMap.__getitem__¬   sÊ   € Ü—‘˜UÓ#ˆÙÜ—H‘H˜e˜WÓ%‰EÜ˜œuÔ%Ø—K‘KÒ$ 1ˆEØ!&§¡Ð!7�5—:’:¼SÀ»YˆDØ—:‘:ˆDÜ—I‘I˜e T¨4Ó0ˆEØ�;‰;œ$ÒÜ—N‘N 5Ó)ˆEäØØ�N‰N×!Ñ! %§+¡+°EÐ!Ó:Ø�O‰Oó
ˆñ Ø�a‘&ˆCØˆ
r+   c                 óè   — | j                   €| j                  «       | _         || j                   |<   t        j                  | j                   «      | _        | j                   | j                     | _        y r5   )r(   r3   r   rU   r%   r&   )r)   ÚindicesÚvaluess      r   Ú__setitem__zArrayMap.__setitem__Â   sP   € Ø�;‰;ÐØŸ.™.Ó*ˆDŒKØ%ˆ�‰�GÑÜŸ™¨¯©Ó4ˆŒØŸ+™+ d§n¡nÑ5ˆ�r+   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r*   r/   r3   Úpropertyr   r9   rF   rJ   rH   r[   © r+   r   r"   r"   L   sE   „ ñ+òZò*ó
ð ñ%ó ð%òLòò$%òó,6r+   r"   r5   )Únumpyr   r    r"   ra   r+   r   ú<module>rc      s   ðÛ óE÷P{6ò {6r+   