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.
The values produced by this library fall within <0.1 dB precision when compared
to the values within the TID2013
dataset.
(See the folder tid2013_results
.) The cause of the
discrepancy is not clear but the possible culprit is the internals of the
BT.601-5 conversion that is done within the Matlab function rgb2ycbcr
. In
this library the color transform is not prescribed, but in the command-line
version the BT.601 for 8-bit digital RGB signals is used if the input is an
8-bit-per-component RGB image and the analog version is used otherwise.
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.8-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b46e49caeb5182f5285eea676d08f3b20bc3a85aa29ecea159535c7b6d88ad |
|
MD5 | cfd6b844d2c4f8b719135a42b57d0c26 |
|
BLAKE2b-256 | fcfee8b99bf06ced688ef6983c64bfd7d0b81395f4fafd9fe8fd7b1670f926af |
Hashes for psnr_hvsm-0.0.8-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fee93f321090b9c227f7fd12dc8d05fa51e4e73493710baa42b6c234c45add65 |
|
MD5 | 1cb27187f7015b770c218deb737e37c2 |
|
BLAKE2b-256 | df41e35811e993bb043b9fcdf293e744767d6e9da3887898b079cff557ec927a |
Hashes for psnr_hvsm-0.0.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ce93f2598587d6b00e7936cf856ebff7c72312a02ff68bd379b39f800b26c62 |
|
MD5 | 39c5e5bb1d60d996fe92e0375d82c2f6 |
|
BLAKE2b-256 | 6a653d664dc3276c67fc9a48c9ad1503722d4a653785a76a78c4220de4efb359 |
Hashes for psnr_hvsm-0.0.8-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a7ced99f78ec2039e47eb015f5fadc8034958d04822f850c00896f5f50a334c |
|
MD5 | f17eac9af9d9ee2c4ab2c6acee8d00e0 |
|
BLAKE2b-256 | 50d86f9c744dc02229492c271c259c6f5f5b2aaafea210a366b95b5a3d038f1f |
Hashes for psnr_hvsm-0.0.8-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 316409f8967d966116f1e49e6edf2c8a89d53f35f5d2b4c349babf9a89a21857 |
|
MD5 | e2398a14fe296751dc30ed36327bcf16 |
|
BLAKE2b-256 | b6c77349cf40bf8479b0091272346d2d01e62c851075fa0ec638a7dc398fe470 |
Hashes for psnr_hvsm-0.0.8-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b310452444686dade2b5bcbd1d8c0cc19417378664ca62f29aaeb34e024805aa |
|
MD5 | 37b2e7bd547ba7e2e7457ffde2dcdf01 |
|
BLAKE2b-256 | 56f096dc7465cb4023ba7a1115df52e28a394fc00e4cd053d3b50148f35bc052 |
Hashes for psnr_hvsm-0.0.8-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfdae5c59eec0512ff0dd41cf969895a1f3ce9bffac1da84d2b3934df195d057 |
|
MD5 | 3c7555c1f632f02fa073d70a68cd49f4 |
|
BLAKE2b-256 | 0e6457a7dbf9bb17e991d0219d4e10e1ddb0687d402c270ca6a86964c153ab88 |
Hashes for psnr_hvsm-0.0.8-cp36-cp36m-manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97252e0a201c7370277b90d97d4fdcb8d961ab7dbe97cf7cf3161e94bc5c7b7a |
|
MD5 | 80107c17f6095b93a4208a6c9d5b69da |
|
BLAKE2b-256 | d51e7ee57d5b176236cb907f1bcb8108e23408eb39c85980e2508e77f66c0826 |