cutcutcodec.core.analysis.video.complexity.rms_time_diff

cutcutcodec.core.analysis.video.complexity.rms_time_diff(imgs: Tensor, threads: int = 0) Tensor[source]

Compute the temporal root mean square time difference complexity for 2 images.

Note

It comes from ENCODING TIME AND ENERGY MODEL FOR SVT-AV1 BASED ON VIDEO COMPLEXITY.

This function implements the following formula:

\[C_{td} = \sqrt{ \frac{1}{hw} \sum_{\boldsymbol{i} \in [\![1, h]\!] \times [\![1, w]\!]}\left( \boldsymbol{Y_t}(\boldsymbol{i}) - \boldsymbol{Y_{t+1}}(\boldsymbol{i}) \right)^2 }\]
With:
  • \(\boldsymbol{Y}\) the Y layer of the image as a 2d matrix.

  • \(t+1\) the frame just after \(t\).

Parameters

imgsarraylike

The Y[UV] images, of shape ([*batch], 2, height, width, [channels]). Only the Y component is used. It has to be in range [0, 1].

threadsint, optional

Defines the number of threads. The value -1 means that the function uses as many calculation threads as there are cores. The default value (0) allows the same behavior as (-1) if the function is called in the main thread, otherwise (1) to avoid nested threads. Any other positive value corresponds to the number of threads used.

Returns

rms_time_diffarraylike

The \(C_{td} \in \mathbb{R}^+\) scalar for each couple of image (of shape batch).

Examples

>>> import numpy as np
>>> from cutcutcodec.core.analysis.video.complexity import rms_time_diff
>>> np.random.seed(0)
>>> imgs = np.random.random((2, 720, 1080, 3))  # It could also be a torch array list...
>>> rms_time_diff(imgs).round(1)
np.float64(0.4)
>>>