Accelerated implementation of the PSNR-HVS-M image metric
Project description
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
- Egiazarian, Karen, et al. "New full-reference quality metrics based on HVS." Proceedings of the Second International Workshop on Video Processing and Quality Metrics. Vol. 4. 2006.
- Ponomarenko, Nikolay, et al. "On between-coefficient contrast masking of DCT basis functions." Proceedings of the third international workshop on video processing and quality metrics. Vol. 4. 2007.
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 valuepsnr_hvsm
- returns only the PSNR-HVS-M valuehvs_mse_tile
- compute the weighted MSE of two 8x8 tileshvsm_mse_tile
- compute the weighted MSE with masking correction of two 8x8 tileshvs_mse
- compute HVS scores on all 8x8 tiles in the images, returns an array of numbershvsm_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for psnr_hvsm-0.0.7-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8cdcdf205f41da15ccc21e60676bab0bc3bb84a44033adb5fe4962bc4b30987 |
|
MD5 | 7e1401ede4f21bb67ce91a2875b4a412 |
|
BLAKE2b-256 | 76e7628b11dde116aa6ec1e711ff1c04224c955295bac3c3b90524f31d9f9f10 |
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 |
Hashes for psnr_hvsm-0.0.7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 935c8ab9f934fe310c187ec4ec3eba9485aaa81f7585af7649f5a4ed5cbe370a |
|
MD5 | 0653620016b847f8ad295d625b5399cc |
|
BLAKE2b-256 | 630dde8cc7525c6e5e7c3091cd50a1a7310ae8048c434b400b9583da503f3ce6 |
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 |
Hashes for psnr_hvsm-0.0.7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77d82e157ab038195a70f628f007a3eae13af648ffff0217956c10f1b42446a5 |
|
MD5 | 6775b4160338fb65d97ece5c3cdb6517 |
|
BLAKE2b-256 | 5b507cf77383bf9b508fdd6c374dde564e06b271583568ad64b44afe68bb20c8 |
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 |
Hashes for psnr_hvsm-0.0.7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62d98644db58505b88baf680386a4c43a2c290e7507aa303453e1be2e5557580 |
|
MD5 | 47633ab5930f813b8c1201b681fa9016 |
|
BLAKE2b-256 | fa0fd20244d0d994a4a5274bfbb47649f8b7abadee160dffbe120f8532a5a11f |
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 |