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
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.6-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc5dae9bb197bc3ad460f26548c7253f663421e8fe3a8e7203b9f48267f0626 |
|
MD5 | 689d7f53a415b92120d9d6e5931247dc |
|
BLAKE2b-256 | 2a4fe762000bf0252a93faa2e40628f37dcea6d2bb83f6f15927ef732ad3e654 |
Hashes for psnr_hvsm-0.0.6-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 365f018c48a2f59eff89db9aa7ee9fcd11449cba35784d2f9010ba6b8df3f78a |
|
MD5 | dc471c1cfe974ee7e3eab126109df65a |
|
BLAKE2b-256 | c79fa133e1c51cf041938d1ff9cfa3616cd1b3b76b1f20b4ea7963924340aad0 |
Hashes for psnr_hvsm-0.0.6-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c54202481c4c68f8df47173be35464d39e05971f9cb68b6dfda8961e9beaf7a9 |
|
MD5 | 8a8d209e096955f3402438d1ea9c7ebe |
|
BLAKE2b-256 | 80dd4d0a04dbd90f7b819fd4ed5367463f8036cb4fb9feccffb60ea4a6685bc9 |
Hashes for psnr_hvsm-0.0.6-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e611f57b76653db5afd1b1383b5df0afb320d1d46bdc177e1c2c90cc4e6832a6 |
|
MD5 | 258004e08ab6c3b3de2255179bc35b52 |
|
BLAKE2b-256 | ac260c6c2a2bc8576e64af792fce3084024e0e17c3d3efbe70db5670033beb06 |
Hashes for psnr_hvsm-0.0.6-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 648db513b35d77de15a43d34516dd373fdd88479eb219fd4d5cf1d43bdcf95d8 |
|
MD5 | dcfe003a61e4fd106010262606aa9ab9 |
|
BLAKE2b-256 | 07f5bc8533580423778b2dd42cd5af2acb97d2065ffd6fb6664547c1ebaf9dd3 |
Hashes for psnr_hvsm-0.0.6-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4381219fe490626b14dc6e3cf423932933f2ec023866514b68be395e06af2ade |
|
MD5 | b9a0ab893a1a16636af4a183b874c2f2 |
|
BLAKE2b-256 | 0f94fd7189004b01ddace8f09b91e26fa8e8771644d1e7e560249d8c9edf20f8 |
Hashes for psnr_hvsm-0.0.6-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca0a220a1aef2dcc0d6e3ee7bd96165b00275575afeefde21d11cbd4fc0786a7 |
|
MD5 | 4ad62c02e0b268a013af18e36e23d06b |
|
BLAKE2b-256 | 456f25ca39ab724e9a91e5cb41c7ba979e13f0b7ad61e5fd003ae4a0f675f867 |
Hashes for psnr_hvsm-0.0.6-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04cb7bf8658b3a7eb11709cf32317204fcb0e614b9cfc8b2fbdd090281894957 |
|
MD5 | ae90ab409e7e8ccbcfa364a1a123fc71 |
|
BLAKE2b-256 | 4e479518b64eba82ef2f1b30d98b6c0e3dc6e1296974ca238e369fdb72d2a5a9 |