Accelerated implementations of the PSNR-HVS, PSNR-HVS-M, PSNR-HA and PSNR-HMA image metrics
Project description
psnr_hvsm
Accelerated Python package for computing several image metrics based on human perception.
This is an implementation of the PSNR-HVS, PSNR-HVS-M, PSNR-HA and PSNR-HMA metrics developed by Nikolay Ponomarenko.
The values produced by this library have been cross-checked against the results
within the TID2013
dataset.
(See the folder tid2013_results
.) The only difference is
that this library follows the common convention that PSNR for identical signals
equals 100.0.
A miniscule discrepancy for PSNR-HMA (<0.01dB on average) is under investigation.
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.
- Ponomarenko, Nikolay, et al. "Modified image visual quality metrics for contrast change and mean shift accounting." 2011 11th International Conference The Experience of Designing and Application of CAD Systems in Microelectronics (CADSM). IEEE, 2011.
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.
from imageio import imread
from psnr_hvsm import psnr_hvs_hvsm
image1 = imread('tests/baboon.png').astype(float) / 255
image2 = imread('tests/baboon_msk.png').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.
Computing metrics for the TID2013 dataset
If you have a copy of the TID2013 dataset, you can re-verify the metrics for yourself:
python -m psnr_hvsm.tid2013_metrics D:\tid2013\ .\tid2013_results\
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.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3795d05ccd2251e48329dbd0eef87a065785b0bf69c57f9e4d68ef70b240fab |
|
MD5 | 08d24966e406d096fde9bc2ecf59f4ee |
|
BLAKE2b-256 | 27dba25f2ae4157f3adc8151b696df85238e1f2a7fcbd8f2fc09053a5cd8dfab |
Hashes for psnr_hvsm-0.1.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23e1a8680a2e342f2c8acf93b46630e0ab833e110ffca78addafbf8334aa2e64 |
|
MD5 | e0fe9f05d2530d525a5365c24e49e920 |
|
BLAKE2b-256 | 29f6ec9d51b848d8de42c8caa8bbcd1f9af1ba9bf9a6a1ee4b5daad6917ae0ea |
Hashes for psnr_hvsm-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee1c7c956bac2ac132e1c0c5c53263fd00d2b08237e07c183cce2fa618d3f4d8 |
|
MD5 | 420e6bccdd17c20b7cee8e177b02ec7b |
|
BLAKE2b-256 | d1570f63060f1a2e26a9be918caaab1c8c5b5b6200978211857cd7608a857e60 |
Hashes for psnr_hvsm-0.1.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ca4f22351a18dccabdef70a26edc9548d1579b6e916628fa694519c764c2b1a |
|
MD5 | e97ffec81a80a6f61c15b9be662ea626 |
|
BLAKE2b-256 | 422127b1481bed9a0a31fd3ec403372e95e18efdf481c2a32c70d16f89d0a6db |
Hashes for psnr_hvsm-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2331b8c92fa8f28f294cf82d29862e83ff223ef982cef97c5f9a4ab3d5e59763 |
|
MD5 | b7a942fbcb6f0be368c92148a0b9bc1a |
|
BLAKE2b-256 | b6a6cf0413609b949a5067a66f49c62acfe2bf258548fcfba21cebb69d583c22 |
Hashes for psnr_hvsm-0.1.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77869e597e7453f66e868885aafaa7e78e596e81d8a81a7a652f917dac364f9f |
|
MD5 | 1f30cb0c5d025bd5d250624eb86e0d27 |
|
BLAKE2b-256 | f45f21c6cbca075c366a6ce572bb4b56246f62919235b9efe4073d122cde8f8b |
Hashes for psnr_hvsm-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adb83c34cf98be04c229fa84215af5722510e97e82c5a7fce9e639eef8df5a93 |
|
MD5 | c7f49a1cb0b31f14ecd7265f2a52f297 |
|
BLAKE2b-256 | 070da5f20dbee217b2df0f2212013d747ede80546ab9ba6e733f039690ed8e6c |
Hashes for psnr_hvsm-0.1.0-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19be5b7f300102f3f9ed9b6b84dda9e34393413b11d56ed40ff6e75181973ee4 |
|
MD5 | df2539616f951a3242b7cf479b89d4bb |
|
BLAKE2b-256 | 4608320a108c4940750ce72fc984d4d5e9b003bdfde99f8684effbe93f3c0715 |