Skip to main content

Accelerated implementation of the PSNR-HVS-M image metric

Project description

cibuildwheel python_versions pypi license

psnr_hvsm

Accelerated Python package for computing the PSNR-HVS-M image metric.

This is an implementation of the PSNR-HVS and PSNR-HVS-M metrics developed by Nikolay Ponomarenko.

Bibliography

Installation

psnr_hvsm supports Python 3.6-3.9. Packages are distributed on PyPi. Be sure to have an up-to-date pip to be able to install the correct packages on Linux:

python -m pip install --upgrade pip
pip install psnr_hvsm

Usage

Command line

Command line support is an extra that pulls opencv-python-headless:

pip install psnr_hvsm[command_line]
python -m psnr_hvsm original.png distorted.png

As a library

The function psnr_hvs_hvsm accepts images as single-channel floating-point NumPy arrays. The images need to be normalised, i.e. the values need to be in the range [0,1]. This can be achieved by converting the image to float and dividing by the maximum value given the bit depth. For 8 bits per component this is 255.

The images must be padded to a multiple of 8 in each dimension.

import cv2
from psnr_hvsm import psnr_hvs_hvsm

image1 = cv2.imread('tests/baboon.png', cv2.IMREAD_GRAYSCALE).astype(float) / 255
image2 = cv2.imread('tests/baboon_msk.png', cv2.IMREAD_GRAYSCALE).astype(float) / 255

psnr_hvs, psnr_hvsm = psnr_hvs_hvsm(image1, image2)

print(psnr_hvs, psnr_hvsm)
34.427054505764424 51.64722121999962

If you need to measure PSNR-HVS and PSNR-HVS-M on an RGB image, you need to convert it to an YUV colorspace and pass in only the luma component.

Other exported functions

  • psnr_hvs - returns only the PSNR-HVS value
  • psnr_hvsm - returns only the PSNR-HVS-M value
  • hvs_mse_tile - compute the weighted MSE of two 8x8 tiles
  • hvsm_mse_tile - compute the weighted MSE with masking correction of two 8x8 tiles
  • hvs_mse - compute HVS scores on all 8x8 tiles in the images, returns an array of numbers
  • hvsm_mse - compute HVS-M scores on all 8x8 tiles in the images, returns an array of numbers

Building

Dependencies

psnr_hvsm has several dependencies:

All of the above can be automatically resolved by running deps.ps1, which is a cross-platform PowerShell script (i.e. it can also be run under Linux if you have PowerShell installed).

Development mode

To install in development mode:

pip install --upgrade -r requirements.txt

Creating Python wheel

pip install --upgrade -r requirements-build.txt
python setup.py bdist_wheel

Running tests on different versions of Python using tox

pip install --upgrade -r requirements-tox.txt
tox --parallel auto

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

psnr_hvsm-0.0.7-cp39-cp39-win_amd64.whl (523.0 kB view details)

Uploaded CPython 3.9Windows x86-64

psnr_hvsm-0.0.7-cp39-cp39-manylinux_2_24_x86_64.whl (656.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

psnr_hvsm-0.0.7-cp38-cp38-win_amd64.whl (522.9 kB view details)

Uploaded CPython 3.8Windows x86-64

psnr_hvsm-0.0.7-cp38-cp38-manylinux_2_24_x86_64.whl (656.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

psnr_hvsm-0.0.7-cp37-cp37m-win_amd64.whl (523.2 kB view details)

Uploaded CPython 3.7mWindows x86-64

psnr_hvsm-0.0.7-cp37-cp37m-manylinux_2_24_x86_64.whl (655.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

psnr_hvsm-0.0.7-cp36-cp36m-win_amd64.whl (523.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

psnr_hvsm-0.0.7-cp36-cp36m-manylinux_2_24_x86_64.whl (655.0 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.24+ x86-64

File details

Details for the file psnr_hvsm-0.0.7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 523.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b8cdcdf205f41da15ccc21e60676bab0bc3bb84a44033adb5fe4962bc4b30987
MD5 7e1401ede4f21bb67ce91a2875b4a412
BLAKE2b-256 76e7628b11dde116aa6ec1e711ff1c04224c955295bac3c3b90524f31d9f9f10

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 656.5 kB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 1e8ec7dea3a08c96a099e750707994f2329e5427aee3ca79236248871ce164e8
MD5 7045a5d551b645bfc50e3f1c23ece930
BLAKE2b-256 9b414ff5a00575775112d236528b1d9bde28396bcc8ea229f64eb653fff1bbb2

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 522.9 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 935c8ab9f934fe310c187ec4ec3eba9485aaa81f7585af7649f5a4ed5cbe370a
MD5 0653620016b847f8ad295d625b5399cc
BLAKE2b-256 630dde8cc7525c6e5e7c3091cd50a1a7310ae8048c434b400b9583da503f3ce6

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 656.3 kB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3e307ee34e14d83ad0b76d9db044f963e8dfb2b2f21821e4194adf66791f5b79
MD5 525445264cbe8d29f9ecd37d435147a2
BLAKE2b-256 d3aa01764e92ffb18eb27cf783972aadedea124be915fca4ad74e516843354cf

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 523.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 77d82e157ab038195a70f628f007a3eae13af648ffff0217956c10f1b42446a5
MD5 6775b4160338fb65d97ece5c3cdb6517
BLAKE2b-256 5b507cf77383bf9b508fdd6c374dde564e06b271583568ad64b44afe68bb20c8

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 655.0 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 de3979620c9addced46f15a843bd01e8eb9f53475e924fae32ed5311b5d7fe1f
MD5 6f44a79e5c0c52625fb33aa75fc37c7f
BLAKE2b-256 3137be9560ac5d1e5daef8bb7a91c2f49398c0cd9a1e69693a8ac1ea2cb38b6b

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 523.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 62d98644db58505b88baf680386a4c43a2c290e7507aa303453e1be2e5557580
MD5 47633ab5930f813b8c1201b681fa9016
BLAKE2b-256 fa0fd20244d0d994a4a5274bfbb47649f8b7abadee160dffbe120f8532a5a11f

See more details on using hashes here.

File details

Details for the file psnr_hvsm-0.0.7-cp36-cp36m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: psnr_hvsm-0.0.7-cp36-cp36m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 655.0 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for psnr_hvsm-0.0.7-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 c37c0bd0489163673300fcfa16863920b0d5b0f2c803a3ac5db7b9ab964ae7a0
MD5 8147527df27075e06cad7b6f6ed12063
BLAKE2b-256 b3b800677feef6196338e66a172a3a0f2896ae6d2cd1b6c2c5d2c7f532398863

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