Skip to main content

Calculate the sharpness of an image with the CPBD metric (Python 3.12+ compatible)

Project description

About

CPBD is a perceptual-based no-reference objective image sharpness metric based on the cumulative probability of blur detection developed at the Image, Video and Usability Laboratory of Arizona State University.

[The metric] is based on the study of human blur perception for varying contrast values. The metric utilizes a probabilistic model to estimate the probability of detecting blur at each edge in the image, and then the information is pooled by computing the cumulative probability of blur detection (CPBD).

This software is a Python port of the reference MATLAB implementation. To approximate the behaviour of MATLAB’s proprietary implementation of the Sobel operator, it uses an implementation inspired by GNU Octave.

References

CPBD is described in detail in the following papers:

Credits

If you publish research results using this code, I kindly ask you to reference the papers of the original authors of the metric as stated in the previous section as well as their reference implementation in your bibliography. See also the copyright statement of the reference implementation in the license file. Thank you!

Installation

$ pip install cpbd

Usage

In [1]: import cpbd

In [2]: from scipy import ndimage

In [3]: input_image = ndimage.imread('/tmp/LIVE_Images_GBlur/img4.bmp', mode='L')

In [4]: cpbd.compute(input_image)
Out[4]: 0.75343203230148048

Development

$ git clone git@github.com:0x64746b/python-cpbd.git
Cloning into 'python-cpbd'...
$ cd python-cpbd
$ pip install -U '.[dev]'

To quickly run the tests with the invocation interpreter:

$ python setup.py test

To test the library under different interpreters:

$ tox

Performance

The following graph visualizes the accuracy of this port in comparison with the reference implementation when tested on the images of the LIVE database:

Performance on LIVE database

Project details


Download files

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

Source Distribution

cpbd_py312-1.0.1.tar.gz (370.9 kB view details)

Uploaded Source

Built Distribution

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

cpbd_py312-1.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file cpbd_py312-1.0.1.tar.gz.

File metadata

  • Download URL: cpbd_py312-1.0.1.tar.gz
  • Upload date:
  • Size: 370.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for cpbd_py312-1.0.1.tar.gz
Algorithm Hash digest
SHA256 585d425b93e77d42b4d4ebd9554ccb620b177ff9b43634025940bc8039c5c025
MD5 957a92b04e1e4bd477c34e14e41531e3
BLAKE2b-256 76046a62f3565994130edeeacecc57b1e24784968351d66fd2234f96f364bbd4

See more details on using hashes here.

File details

Details for the file cpbd_py312-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: cpbd_py312-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for cpbd_py312-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d118355de66ae7354c67627024404a3129400a8f60af7097da426ad6ae7eba11
MD5 0b53f94ddaea523482ab52158964c148
BLAKE2b-256 36b0027b95ff84c7101a0de567a140ab8f1c54368a686f253db77fa906d6df7a

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