cutcutcodec.core.analysis.video.quality.vif_torch.vif_conv_torch

cutcutcodec.core.analysis.video.quality.vif_torch.vif_conv_torch(dis: Tensor, ref: Tensor) float[source]

Pure torch implementation of cutcutcodec.core.analysis.video.quality.vif().

It is based on a native torch convolution.

Parameters

dis, reftorch.Tensor

The distorded and reference images of shape (batch, height, width). Assumed to be only the luminosity in range [0, 1].

Returns

viftorch.Tensor

The VIF Index of similarity between two images. Usually in [0, 1], of shape (batch,). Can be bigger than 1 for predicted \(x\) images with higher contrast than original one.

Examples

>>> import torch
>>> from cutcutcodec.core.analysis.video.quality.vif_torch import vif_conv_torch
>>> _ = torch.manual_seed(0)
>>> ref = torch.rand(4, 720, 1080)
>>> dis = 0.8 * ref + 0.2 * torch.rand(4, 720, 1080)
>>> vif_conv_torch(dis, ref)
tensor([0.6440, 0.6444, 0.6441, 0.6436])
>>>
>>> import torchmetrics
>>> torchmetrics.functional.image.visual_information_fidelity(
...     dis[:, None, :, :], ref[:, None, :, :], reduction="none",
... )
tensor([0.6440, 0.6444, 0.6441, 0.6437])
>>>