Git Product home page Git Product logo

python-cpbd's Introduction

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 [email protected]: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

python-cpbd's People

Contributors

0x64746b avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-cpbd's Issues

Compute CPBDscore on diffusion MRI 4D data

I would like to know how to compute CPBD score on diffusion MRI 4-D data, since the default function works on 2D images.

Moreover, I wanted to make sure I am applying the commands correctly.
Diffusion MRI data are 4-D grayscale images in nifti (.nii.gz) format.

Here is the code I use -for now on a single slice of a diffusion MRI volume in order to have a 2-D image:

            # select single slice and volume from 4-D diffusion MRI data to have 2-D one
             orig = data[:, :, sli, vol]
            matplotlib.image.imsave('blur1_rev.png', orig)
             input_image1 = cv2.imread('blur1_rev.png')
             input_image1 = cv2.cvtColor(input_image1, cv2.COLOR_BGR2GRAY)
             cpbd.compute(input_image1)

thank you in advance ,
Rosella

No imread() in 2020's Scipy v1.5.x. How to read image to feed to cpbd.compute() ?

I am unable to read an image for cpbd.compute() to process. The example usage in README is broken.

This code:
from scipy import ndimage
input_image = ndimage.imread('/tmp/LIVE_Images_GBlur/img4.bmp', mode='L')

Results in:
AttributeError: module 'scipy.ndimage' has no attribute 'imread'

The docs for Scipy say imread was removed in version 1.2,
"imread is deprecated in SciPy 1.0. 0, and will be removed in 1.2."
https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imread.html

I have found a StackOverflow page that recommends using image.io:
https://stackoverflow.com/questions/15345790/scipy-misc-module-has-no-attribute-imread

However, there is no mode="L" parameter, just a format param, which overrides the image format guess from the extension (ie format="JPEG").

 import imageio
 iio_image = imageio.imread(inputpath)
 cpbd_focus1 = cpbd.compute(iio_image)

However, using plain imageio.imread results in cpbd complaining about the input shape, because its in RGB.
ValueError: The parameter image must be a 2-dimensional array

If I convert the image to grayscale, it works.

import cpbd
import cv2
import imageio
iio_image = imageio.imread('testimg.jpg')
grey_iio_image = cv2.cvtColor(iio_image, cv2.COLOR_BGR2GRAY)
cpbd.compute(grey_iio_image)
0.25540727105384264

Please update your README to address this change in modern scipy.

Thank you!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.