Ë
    þÍ:j�  ã                   ó    — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ esdgZ	 	 	 	 	 	 dd	ed
ededee   dededededed   defd„Zy)é    )ÚOptional)ÚTensor)ÚLiteral)Úspectral_distortion_index)Úspatial_distortion_index)Ú_TORCHVISION_AVAILABLEÚquality_with_no_referenceNÚpredsÚmsÚpanÚpan_lrÚalphaÚbetaÚ
norm_orderÚwindow_sizeÚ	reduction)Úelementwise_meanÚsumÚnoneÚreturnc	           	      ó
  — t        |t        t        f«      r|dk  rt        d|› d�«      ‚t        |t        t        f«      r|dk  rt        d|› d�«      ‚t	        | |||«      }	t        | ||||||«      }
d|	z
  |z  d|
z
  |z  z  S )a`  Calculate `Quality with No Reference`_ (QualityWithNoReference_) also known as QNR.

    Metric is used to compare the joint spectral and spatial distortion between two images.

    Args:
        preds: High resolution multispectral image.
        ms: Low resolution multispectral image.
        pan: High resolution panchromatic image.
        pan_lr: Low resolution panchromatic image.
        alpha: Relevance of spectral distortion.
        beta: Relevance of spatial distortion.
        norm_order: Order of the norm applied on the difference.
        window_size: Window size of the filter applied to degrade the high resolution panchromatic image.
        reduction: A method to reduce metric score over labels.

            - ``'elementwise_mean'``: takes the mean (default)
            - ``'sum'``: takes the sum
            - ``'none'``: no reduction will be applied

    Return:
        Tensor with QualityWithNoReference score

    Raises:
        ValueError:
            If ``alpha`` or ``beta`` is not a non-negative real number.

    Example:
        >>> from torch import rand
        >>> from torchmetrics.functional.image import quality_with_no_reference
        >>> preds = rand([16, 3, 32, 32])
        >>> ms = rand([16, 3, 16, 16])
        >>> pan = rand([16, 3, 32, 32])
        >>> quality_with_no_reference(preds, ms, pan)
        tensor(0.9694)

    r   z>Expected `alpha` to be a non-negative real number. Got alpha: ú.z<Expected `beta` to be a non-negative real number. Got beta: é   )Ú
isinstanceÚintÚfloatÚ
ValueErrorr   r   )r
   r   r   r   r   r   r   r   r   Úd_lambdaÚd_ss              úv/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/torchmetrics/functional/image/qnr.pyr	   r	      s¡   € ô^ �eœc¤5˜\Ô*¨e°aªiÜÐYÐZ_ÐY`Ð`aÐbÓcÐcÜ�dœS¤%˜LÔ)¨T°AªXÜÐWÐX\ÐW]Ð]^Ð_Ó`Ð`Ü(¨°°JÀ	ÓJ€HÜ
" 5¨"¨c°6¸:À{ÐT]Ó
^€CØ�‰L˜UÑ" a¨#¡g°$Ñ%6Ñ6Ð6ó    )Nr   r   r   é   r   )Útypingr   Útorchr   Útyping_extensionsr   Ú&torchmetrics.functional.image.d_lambdar   Ú!torchmetrics.functional.image.d_sr   Útorchmetrics.utilities.importsr   Ú__doctest_skip__r   r   r	   © r!   r    ú<module>r+      s©   ðõ å Ý %å LÝ FÝ AáØ3Ð4Ðð  $ØØØØØ<Nñ57Øð57àð57ð 
ð57ð �VÑð	57ð
 ð57ð ð57ð ð57ð ð57ð Ð8Ñ9ð57ð ô57r!   