+
    Ai                          ^ RI t^ RIHt ^RIHt ^RIHt ^RIH	t	H
t
Ht . ROtR t]R 4       t]RR	/R
 l4       tRR/R ltR tR^d/R ltR# )    N)entropy)dispatchable)dtype_range)_supported_float_typecheck_shape_equalitywarnc                    \        V P                  VP                  34      p\        P                  ! WR7      p \        P                  ! WR7      pW3# )zC
Promote im1, im2 to nearest appropriate floating point precision.
dtype)r   r   npasarray)image0image1
float_types   && \/var/www/html/photoedit/myenv/lib/python3.14/site-packages/skimage/metrics/simple_metrics.py
_as_floatsr      s?     'fll'CDJZZ1FZZ1F>    c                    \        W4       \        W4      w  r\        P                  ! W,
          ^,          \        P                  R7      # )az  
Compute the mean-squared error between two images.

Parameters
----------
image0, image1 : ndarray
    Images.  Any dimensionality, must have same shape.

Returns
-------
mse : float
    The mean-squared error (MSE) metric.

Notes
-----
.. versionchanged:: 0.16
    This function was renamed from ``skimage.measure.compare_mse`` to
    ``skimage.metrics.mean_squared_error``.

r
   )r   r   r   meanfloat64)r   r   s   &&r   mean_squared_errorr      s4    , (/NF77FO)<<r   normalization	euclideanc                  \        W4       \        W4      w  rVP                  4       pVR8X  dB   \        P                  ! \        P
                  ! W ,          \        P                  R7      4      pMPVR8X  d'   V P                  4       V P                  4       ,
          pM#VR8X  d   V P                  4       pM\        R4      h\        P                  ! \        W4      4      V,          # )a  
Compute the normalized root mean-squared error (NRMSE) between two
images.

Parameters
----------
image_true : ndarray
    Ground-truth image, same shape as im_test.
image_test : ndarray
    Test image.
normalization : {'euclidean', 'min-max', 'mean'}, optional
    Controls the normalization method to use in the denominator of the
    NRMSE.  There is no standard method of normalization across the
    literature [1]_.  The methods available here are as follows:

    - 'euclidean' : normalize by the averaged Euclidean norm of
      ``im_true``::

          NRMSE = RMSE * sqrt(N) / || im_true ||

      where || . || denotes the Frobenius norm and ``N = im_true.size``.
      This result is equivalent to::

          NRMSE = || im_true - im_test || / || im_true ||.

    - 'min-max'   : normalize by the intensity range of ``im_true``.
    - 'mean'      : normalize by the mean of ``im_true``

Returns
-------
nrmse : float
    The NRMSE metric.

Notes
-----
.. versionchanged:: 0.16
    This function was renamed from ``skimage.measure.compare_nrmse`` to
    ``skimage.metrics.normalized_root_mse``.

References
----------
.. [1] https://en.wikipedia.org/wiki/Root-mean-square_deviation

r   r
   zmin-maxr   zUnsupported norm_type)r   r   lowerr   sqrtr   r   maxmin
ValueErrorr   )
image_true
image_testr   denoms   &&$ r   normalized_root_mser#   5   s    \ 0'
?J "'')M#!8LM	)	# :>>#33	&	 !01177%j=>FFr   
data_rangec                  \        W4       Vf   V P                  VP                  8w  d   \        R4       \        V P                  P                  ,          w  r4\
        P                  ! V 4      \
        P                  ! V 4      reWd8  g   WS8  d   \        R4      hV^ 8  d   TpMWC,
          p\        W4      w  r\        W4      p\        V4      p^
\
        P                  ! V^,          V,          4      ,          # )a  
Compute the peak signal to noise ratio (PSNR) for an image.

Parameters
----------
image_true : ndarray
    Ground-truth image, same shape as im_test.
image_test : ndarray
    Test image.
data_range : int, optional
    The data range of the input image (distance between minimum and
    maximum possible values).  By default, this is estimated from the image
    data-type.

Returns
-------
psnr : float
    The PSNR metric.

Notes
-----
.. versionchanged:: 0.16
    This function was renamed from ``skimage.measure.compare_psnr`` to
    ``skimage.metrics.peak_signal_noise_ratio``.

References
----------
.. [1] https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio

zFInputs have mismatched dtype.  Setting data_range based on image_true.zuimage_true has intensity values outside the range expected for its data type. Please manually specify the data_range.)r   r   r   r   typer   r   r   r   r   r   floatlog10)r    r!   r$   dmindmaxtrue_mintrue_maxerrs   &&$     r   peak_signal_noise_ratior.   s   s    > 0z/// !!1!1!6!67
VVJ/
1C(?hoM  q=JJ'
?J
Z
4Cz"J*a-3.///r   c                   \         ;QJ d/    R \        WP                  4       4       F  '       d   K   RM$	  RM ! R \        WP                  4       4       4      '       g   \        RV RV P                   R24      h\        WP                  4       UUu. uF  w  r#^ W#,
          3NK  	  ppp\        P
                  ! WR^ R7      # u uppi )	a&  Pad an array with trailing zeros to a given target shape.

Parameters
----------
arr : ndarray
    The input array.
shape : tuple
    The target shape.

Returns
-------
padded : ndarray
    The padded array.

Examples
--------
>>> _pad_to(np.ones((1, 1), dtype=int), (1, 3))
array([[1, 0, 0]])
c              3   .   "   T F  w  rW8  x  K  	  R # 5i)N ).0sis   &  r   	<genexpr>_pad_to.<locals>.<genexpr>   s     8"7$!qv"7s   FTzTarget shape z# cannot be smaller than inputshape z along any axis.constant)	pad_widthmodeconstant_values)allzipshaper   r   pad)arrr=   r3   r4   paddings   &&   r   _pad_torA      s    ( 38#eYY"783338#eYY"7888E7 #YYK/1
 	
 '*%&;<&;da15z&;G<66#z1MM =s   Cbinsc                  V P                   VP                   8w  d'   \        RV P                    RVP                    R24      hV P                  VP                  8w  dC   \        P                  ! V P                  VP                  4      p\        W4      p\        W4      pMYrT\        P                  ! \        P                  ! VR4      \        P                  ! VR4      .VRR7      w  rg\        \        P                  ! V^ R7      4      p\        \        P                  ! V^R7      4      p	\        \        P                  ! VR4      4      p
W,           V
,          # )a  Compute the normalized mutual information (NMI).

The normalized mutual information of :math:`A` and :math:`B` is given by:

.. math::

   Y(A, B) = \frac{H(A) + H(B)}{H(A, B)}

where :math:`H(X) := - \sum_{x \in X}{p(x) \log p(x)}` is the entropy,
:math:`X` is the set of image values, and :math:`p(x)` is the probability
of occurrence of value :math:`x \in X`.

It was proposed to be useful in registering images by Colin Studholme and
colleagues [1]_. It ranges from 1 (perfectly uncorrelated image values)
to 2 (perfectly correlated image values, whether positively or negatively).

Parameters
----------
image0, image1 : ndarray
    Images to be compared. The two input images must have the same number
    of dimensions.
bins : int or sequence of int, optional
    The number of bins along each axis of the joint histogram.

Returns
-------
nmi : float
    The normalized mutual information between the two arrays, computed at
    the granularity given by ``bins``. Higher NMI implies more similar
    input images.

Raises
------
ValueError
    If the images don't have the same number of dimensions.

Notes
-----
If the two input images are not the same shape, the smaller image is padded
with zeros.

References
----------
.. [1] C. Studholme, D.L.G. Hill, & D.J. Hawkes (1999). An overlap
       invariant entropy measure of 3D medical image alignment.
       Pattern Recognition 32(1):71-86
       :DOI:`10.1016/S0031-3203(98)00091-0`
z6NMI requires images of same number of dimensions. Got zD for `image0` and zD for `image1`.T)rB   density)axis)
ndimr   r=   r   maximumrA   histogramddreshaper   sum)r   r   rB   	max_shapepadded0padded1hist	bin_edgesH0H1H01s   &&$        r   normalized_mutual_informationrT      s   b {{fkk!;;-2{{m?,
 	

 ||v||#JJv||V\\:	&,&,!nn	GR	 "**Wb"9:OD 
1%	&B	1%	&B
"**T2&
'CGs?r   )r   r#   r.   rT   )numpyr   scipy.statsr   util._backendsr   
util.dtyper   _shared.utilsr   r   r   __all__r   r   r#   r.   rA   rT   r1   r   r   <module>r[      sw      ) $ M M = =4 :G :G :Gz80$ 80vN:H# Hr   