cutcutcodec.core.analysis.video.complexity
Video complexity metrics.
Functions
|
Compute the spacial root mean square sobel gratient complexity for the image. |
|
Compute the temporal root mean square time difference complexity for 2 images. |
Details
- cutcutcodec.core.analysis.video.complexity.rms_sobel(img: Tensor) Tensor[source]
Compute the spacial root mean square sobel gratient complexity for the image.
Note
It comes from
ENCODING TIME AND ENERGY MODEL FOR SVT-AV1 BASED ON VIDEO COMPLEXITY.This function implements the following formula:
\[\begin{split}\begin{cases} C_{sob} = \sqrt{ \frac{1}{(h-2)(w-2)} \sum_{\boldsymbol{i} \in [\![1, h-2]\!] \times [\![1, w-2]\!]}\left( \boldsymbol{G_x}^2(\boldsymbol{i}) + \boldsymbol{G_y}^2(\boldsymbol{i}) \right) } \\ \boldsymbol{G_x} = \boldsymbol{S} \star \boldsymbol{Y} \\ \boldsymbol{G_y} = \boldsymbol{S}^\intercal \star \boldsymbol{Y} \\ \boldsymbol{S} = \begin{pmatrix} -1 & 0 & 1 \\ -2 & 0 & 2 \\ -1 & 0 & 1 \\ \end{pmatrix} \end{cases}\end{split}\]- With:
\(\star\) the correlation product along the axis
heightandwidth.\(\boldsymbol{Y}\) the Y layer of the image as a 2d matrix.
Parameters
- imgarraylike
The Y[UV] images, of shape ([*batch], [1], height, width, [channels]). Only the Y component is used. It has to be in range [0, 1]. As there is no padding on the edges, the image must be at least 3x3 pixels.
Returns
- rms_sobelarraylike
The \(C_{sob} \in \mathbb{R}^+\) scalar for each image (of shape batch).
Examples
>>> import numpy as np >>> from cutcutcodec.core.analysis.video.complexity import rms_sobel >>> np.random.seed(0) >>> img = np.random.random((720, 1080, 3)) # It could also be a torch array list... >>> rms_sobel(img).round(1) np.float64(1.4) >>>
- cutcutcodec.core.analysis.video.complexity.rms_time_diff(imgs: Tensor) 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].
Returns
- rms_sobelarraylike
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) >>>
Modules
Helper for metrics. |