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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file siti-tools-0.0.1.tar.gz.

File metadata

  • Download URL: siti-tools-0.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.1

File hashes

Hashes for siti-tools-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1d40e5e42ae2f646428bedcaf8409ed9cb8bd2b6183699bc9257bcbbf41cfc25
MD5 51e37fa465f54538175c9157f6859ba1
BLAKE2b-256 ffd86053c6e5c3f330e7123aab01081f1b86ed01c70b8a7d835a0f332c1b8a23

See more details on using hashes here.

File details

Details for the file siti_tools-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: siti_tools-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.0.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.1

File hashes

Hashes for siti_tools-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58aff5884374852aa24696a923446f5d227fc3a3eaafc3ea51d7917d680a2057
MD5 60e9230e6ea0da620844f2443c0a38d9
BLAKE2b-256 c5f732d6196c2d878550011d62c2696f0d3a74427504df5fbec4a04c5fc6ef5a

See more details on using hashes here.

Supported by

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