Skip to main content

Functions to calculate Spatial Information / Temporal Information according to ITU-T P.910

Project description

siti-tools

SI/TI calculation tools.

Calculate spatial information (SI) and temporal information (TI) according to ITU-T P.910.

Contents:

Requirements

  • Python 3.5 or higher
  • FFmpeg libraries (to run pyav)

Under Ubuntu, to get ffmpeg libraries:

sudo apt update -qq && \
sudo apt install \
  libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev \
  libavfilter-dev libswscale-dev libavresample-dev

Under macOS, it is recommended to install ffmpeg via Homebrew:

brew install ffmpeg

Installation

Run:

pip3 install --user siti-tools

Alternatively, clone this repository and then:

pip3 install --user .

What is SI/TI?

The following info is given about SI / TI in ITU-T Recommendation P.910 ("Subjective video quality assessment methods for multimedia applications"):

Spatial Information

The spatial perceptual information (SI) is based on the Sobel filter. Each video frame (luminance plane) at time n (Fn) is first filtered with the Sobel filter [Sobel(Fn)]. The standard deviation over the pixels (stdspace) in each Sobel-filtered frame is then computed. This operation is repeated for each frame in the video sequence and results in a time series of spatial information of the scene. The maximum value in the time series (maxtime) is chosen to represent the spatial information content of the scene. This process can be represented in equation form as:

Temporal information

The temporal perceptual information (TI) is based upon the motion difference feature, Mn(i, j), which is the difference between the pixel values (of the luminance plane) at the same location in space but at successive times or frames. Mn(i, j) as a function of time (n) is defined as:

here Fn(i, j) is the pixel at the ith row and jth column of nth frame in time. The measure of temporal information (TI) is computed as the maximum over time (maxtime) of the standard deviation over space (stdspace) of Mn(i, j) over all i and j.

More motion in adjacent frames will result in higher values of TI

Usage

The tools expose the following via an API:

  • two main functions to calculate SI and TI given an array of frame data (si and ti)
  • a helper function to calculate SI and TI together (calculate_si_ti)
  • helper functions for reading files (read_container, read_file)

Read on to get some examples. If you need a command line version, check out:

Combined Calculation

In the simplest case, run:

from siti_tools.siti import calculate_si_ti

si_values, ti_values, frame_count = calculate_si_ti("/path/to/file.y4m")

You can then access the raw values in the individual variables.

⚠️ The first TI value will always be None, since it is not defined.

Individual Calculation

You can also manually calculate the values.

When calculating TI, make sure to compare against the previous frame data:

from siti_tools.file import read_container
from siti_tools.siti import si, ti

previous_frame_data = None
for frame in read_container("/path/to/file.y4m"):
    si_value = si(frame)
    ti_value = ti(frame, previous_frame_data)
    previous_frame_data = frame

The read_container function returns each frame individually and the loop will exit once it's done.

Documentation

To read the API documentation, head to https://telecommunication-telemedia-assessment.github.io/siti_tools.

Acknowledgements

If you use this software in your research, please include link to this repository.

Testing

Install pytest:

pip3 install -r requirements.dev.txt

Then run:

python3 -m pytest test/test.py

License

MIT License

siti_tools, Copyright (c) 2021 Werner Robitza

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Changelog

v0.0.1 (2021-03-08)

  • Improve README.

  • Initial commit.

  • Initial commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

siti-tools-0.0.1.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

siti_tools-0.0.1-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page