§
    ²[6g_   ã            
       ó  — d Z ddlZddlmZ ej        ej        ej        ej        ej	        ej
        ej        ej        ej        ej        f
Zd„ eD ¦   «         Zej        dej        dej        dej        diZe                     e¦  «         e                     ¦   «         Ze                     d„ e                     ¦   «         D ¦   «         ¦  «         e                     dd	d
eej                 eej                 dœ¦  «         dd„Zd„ Zdd„ZdS )z†Vendored code from scikit-image in order to limit the number of dependencies
Extracted from scikit-image/skimage/exposure/exposure.py
é    N)Úwarnc                 ót   — i | ]5}|t          j        |¦  «        j        t          j        |¦  «        j        f“Œ6S © )ÚnpÚiinfoÚminÚmax)Ú.0Úts     úZ/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/plotly/express/imshow_utils.pyú
<dictcomp>r      s3   € ÐQÐQÐQ¸Q�1•r”x ‘{”{”­¬°©¬¬Ð8ÐQÐQÐQó    )FT)éÿÿÿÿé   c              #   ó.   K  — | ]\  }}|j         |fV — Œd S )N)Ú__name__)r
   ÚdÚlimitss      r   ú	<genexpr>r       s-   è è € ÐMÐM©I¨A¨v�A”J Ð'ÐMÐMÐMÐMÐMÐMr   )r   iÿ  )r   iÿ  )r   iÿ?  )Úuint10Úuint12Úuint14ÚboolÚfloatÚimageFc                 óÒ   — |dk    r| j         j        }|dk    r)t          j        | ¦  «        }t          j        | ¦  «        }n#|t
          v rt
          |         \  }}|rd}n|\  }}||fS )af  Return image intensity range (min, max) based on desired value type.

    Parameters
    ----------
    image : array
        Input image.
    range_values : str or 2-tuple, optional
        The image intensity range is configured by this parameter.
        The possible values for this parameter are enumerated below.

        'image'
            Return image min/max as the range.
        'dtype'
            Return min/max of the image's dtype as the range.
        dtype-name
            Return intensity range based on desired `dtype`. Must be valid key
            in `DTYPE_RANGE`. Note: `image` is ignored for this range type.
        2-tuple
            Return `range_values` as min/max intensities. Note that there's no
            reason to use this function if you just want to specify the
            intensity range explicitly. This option is included for functions
            that use `intensity_range` to support all desired range types.

    clip_negative : bool, optional
        If True, clip the negative range (i.e. return 0 for min intensity)
        even if the image dtype allows negative values.
    Údtyper   r   )r   Útyper   r   r	   ÚDTYPE_RANGE)r   Úrange_valuesÚclip_negativeÚi_minÚi_maxs        r   Úintensity_ranger$   ,   sz   € ð8 �wÒÐØ”{Ô'ˆà�wÒÐÝ”�u‘”ˆÝ”�u‘”ˆˆØ	�Ð	$Ð	$Ý" <Ô0‰ˆˆuØð 	ØˆEøà#‰ˆˆuØ�%ˆ<Ðr   c                 óZ  — t          | ¦  «        t          t          t          j        fv rt          j        S t          | ¦  «        t           k    r| S | t          v r6	 t          j        | ¦  «        j         S # t          $ r t          j	        cY S w xY wt          dt          | ¦  «        z  ¦  «        ‚)aO  Determine the output dtype for rescale_intensity.

    The dtype is determined according to the following rules:
    - if ``dtype_or_range`` is a dtype, that is the output dtype.
    - if ``dtype_or_range`` is a dtype string, that is the dtype used, unless
      it is not a NumPy data type (e.g. 'uint12' for 12-bit unsigned integers),
      in which case the data type that can contain it will be used
      (e.g. uint16 in this case).
    - if ``dtype_or_range`` is a pair of values, the output data type will be
      float.

    Parameters
    ----------
    dtype_or_range : type, string, or 2-tuple of int/float
        The desired range for the output, expressed as either a NumPy dtype or
        as a (min, max) pair of numbers.

    Returns
    -------
    out_dtype : type
        The data type appropriate for the desired output.
    z]Incorrect value for out_range, should be a valid image data type or a pair of values, got %s.)r   ÚlistÚtupler   ÚndarrayÚfloat_r   r   Ú	TypeErrorÚuint16Ú
ValueErrorÚstr)Údtype_or_ranges    r   Ú_output_dtyper/   W   s·   € õ. ˆNÑÔ¥¥e­R¬ZÐ8Ð8Ð8åŒyÐÝˆNÑÔ�tÒ#Ð#àÐØ�Ð$Ð$ð	å”8˜NÑ+Ô+Ô0Ð0øÝð 	ð 	ð 	å”9ÐÐÐð	øøøõ ð0Ý25°nÑ2EÔ2EñFñ
ô 
ð 	
s   ÁA2 Á2BÂ
Br   c           	      óT  — |dv rt          | j        j        ¦  «        }nt          |¦  «        }t          t          t          | |¦  «        ¦  «        \  }}t          t          t          | ||dk    ¬¦  «        ¦  «        \  }}t          j        t          j        ||||g¦  «        ¦  «        rt          dd¬¦  «         t          j
        | ||¦  «        } ||k    r*| |z
  ||z
  z  } t          j        | ||z
  z  |z   |¬¦  «        S t          j
        | ||¦  «                             |¦  «        S )a  Return image after stretching or shrinking its intensity levels.

    The desired intensity range of the input and output, `in_range` and
    `out_range` respectively, are used to stretch or shrink the intensity range
    of the input image. See examples below.

    Parameters
    ----------
    image : array
        Image array.
    in_range, out_range : str or 2-tuple, optional
        Min and max intensity values of input and output image.
        The possible values for this parameter are enumerated below.

        'image'
            Use image min/max as the intensity range.
        'dtype'
            Use min/max of the image's dtype as the intensity range.
        dtype-name
            Use intensity range based on desired `dtype`. Must be valid key
            in `DTYPE_RANGE`.
        2-tuple
            Use `range_values` as explicit min/max intensities.

    Returns
    -------
    out : array
        Image array after rescaling its intensity. This image is the same dtype
        as the input image.

    Notes
    -----
    .. versionchanged:: 0.17
        The dtype of the output array has changed to match the output dtype, or
        float if the output range is specified by a pair of floats.

    See Also
    --------
    equalize_hist

    Examples
    --------
    By default, the min/max intensities of the input image are stretched to
    the limits allowed by the image's dtype, since `in_range` defaults to
    'image' and `out_range` defaults to 'dtype':

    >>> image = np.array([51, 102, 153], dtype=np.uint8)
    >>> rescale_intensity(image)
    array([  0, 127, 255], dtype=uint8)

    It's easy to accidentally convert an image dtype from uint8 to float:

    >>> 1.0 * image
    array([ 51., 102., 153.])

    Use `rescale_intensity` to rescale to the proper range for float dtypes:

    >>> image_float = 1.0 * image
    >>> rescale_intensity(image_float)
    array([0. , 0.5, 1. ])

    To maintain the low contrast of the original, use the `in_range` parameter:

    >>> rescale_intensity(image_float, in_range=(0, 255))
    array([0.2, 0.4, 0.6])

    If the min/max value of `in_range` is more/less than the min/max image
    intensity, then the intensity levels are clipped:

    >>> rescale_intensity(image_float, in_range=(0, 102))
    array([0.5, 1. , 1. ])

    If you have an image with signed integers but want to rescale the image to
    just the positive range, use the `out_range` parameter. In that case, the
    output dtype will be float:

    >>> image = np.array([-10, 0, 10], dtype=np.int8)
    >>> rescale_intensity(image, out_range=(0, 127))
    array([  0. ,  63.5, 127. ])

    To get the desired range with a specific dtype, use ``.astype()``:

    >>> rescale_intensity(image, out_range=(0, 127)).astype(np.int8)
    array([  0,  63, 127], dtype=int8)

    If the input image is constant, the output will be clipped directly to the
    output range:
    >>> image = np.array([130, 130, 130], dtype=np.int32)
    >>> rescale_intensity(image, out_range=(0, 127)).astype(np.int32)
    array([127, 127, 127], dtype=int32)
    )r   r   r   )r!   z´One or more intensity levels are NaN. Rescaling will broadcast NaN to the full image. Provide intensity levels yourself to avoid this. E.g. with np.nanmin(image), np.nanmax(image).é   )Ú
stacklevel)r   )r/   r   r   Úmapr   r$   r   ÚanyÚisnanr   ÚclipÚasarrayÚastype)r   Úin_rangeÚ	out_rangeÚ	out_dtypeÚiminÚimaxÚominÚomaxs           r   Úrescale_intensityr@   ƒ   s8  € ðx Ð&Ð&Ð&Ý! %¤+Ô"2Ñ3Ô3ˆ	ˆ	å! )Ñ,Ô,ˆ	å•U�O¨E°8Ñ<Ô<Ñ=Ô=�J€Dˆ$ÝÝ�˜u iÀÈÂ	ÐKÑKÔKñô �J€Dˆ$õ 
„v�bŒh˜˜d D¨$Ð/Ñ0Ô0Ñ1Ô1ð 
ÝðHð ð		
ñ 	
ô 	
ð 	
õ ŒG�E˜4 Ñ&Ô&€Eàˆt‚|€|Ø˜‘ $¨¡+Ñ.ˆÝŒz˜% 4¨$¡;Ñ/°$Ñ6¸iÐHÑHÔHÐHåŒw�u˜d DÑ)Ô)×0Ò0°Ñ;Ô;Ð;r   )r   F)r   r   )Ú__doc__Únumpyr   Úwarningsr   ÚbyteÚubyteÚshortÚushortÚintcÚuintcÚint_ÚuintÚlonglongÚ	ulonglongÚ_integer_typesÚ_integer_rangesÚbool_Úfloat16Úfloat32Úfloat64Údtype_rangeÚupdateÚcopyr   Úitemsr$   r/   r@   r   r   r   ú<module>rX      sƒ  ððð ð Ð Ð Ð à Ð Ð Ð Ð Ð ð „GØ„HØ„HØ„IØ„GØ„HØ„GØ„GØ„KØ„Lð€ð RÐQÀ.ÐQÑQÔQ€à„HˆmØ„J�Ø„J�Ø„J�ð	€ð × Ò �?Ñ #Ô #Ð #ð ×ÒÑ Ô €Ø × Ò ÐMÐM¸×9JÒ9JÑ9LÔ9LÐMÑMÔMÑ MÔ MÐ MØ × Ò à Ø Ø Ø˜BœHÔ%Ø˜RœZÔ(ðð ñô ð ð(ð (ð (ð (ðV)
ð )
ð )
ðXt<ð t<ð t<ð t<ð t<ð t<r   