Performs analysis on images to determine whether they are blurry.
Project description
pyblurry
Performs analysis on images to determine whether they are blurry.
pyblurry is a simple library providing functionality to determine whether images are blurry using different detection algorithms.
Installation
The easiest is to use pip:
$ pip install pyblurry
Usage
To determine whether an image is blurry using the fastest and simplest analysis method with the is_blurry function:
>>> import pyblurry
>>> pyblurry.is_blurry(image="blurry_image.jpg")
True
>>> pyblurry.is_blurry(image="non_blurry_image.png")
False
To perform an analysis using all detection methods with the analyze function:
>>> pyblurry.analyze(image="blurry_image.jpg")
{"elapsed_time": 1.17062349896878, "laplacian-simple": {"confidence": 1.0, "is_blurry": true, "resized": true, "elapsed_time": 0.08787570800632238, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 19.0}, "laplacian-local-blur": {"confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.06633887498173863, "local_laplacian_variance": 2.11518251626384, "global_laplacian_variance": 2.11518251626384, "laplacian_threshold": 70.0}, "laplacian-face-detection": {"confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.18917625001631677, "faces_detected": false, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 20.0}, "perceptual-robust": {"confidence": 0.9583333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.7872245829785243, "perceptual_mean": 0.8366243655027964, "perceptual_threshold": 0.395}, "fast-fourier-transform": {"confidence": 0.9333333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.04000808298587799, "fft_mean": -5.397502609440028, "fft_mean_threshold": 10.0}}
The analyze function can be used with the use_algorithms parameter to specify which analysis algorithms to use, or with the exclude_algorithms to specify which algorithms not to use:
>>> pyblurry.analyze(image="blurry_image.jpg", use_algorithms=("laplacian-simple", "fast-fourier-transform"))
{"elapsed_time": 0.06035354104824364, "laplacian-simple": {"confidence": 1.0, "is_blurry": true, "resized": true, "elapsed_time": 0.026116708060726523, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 19.0}, "fast-fourier-transform": {"confidence": 0.9333333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.03423683298751712, "fft_mean": -5.397502609440028, "fft_mean_threshold": 10.0}}
and it can be used with the exclude_algorithms parameter to specify which algorithms to exclude:
>>> pyblurry.analyze(image="blurry_image.jpg", exclude_algorithms=("laplacian-simple", "fast-fourier-transform"))
{"elapsed_time": 0.8824597500497475, "laplacian-local-blur": {"confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.015356042073108256, "local_laplacian_variance": 2.11518251626384, "global_laplacian_variance": 2.11518251626384, "laplacian_threshold": 70.0}, "laplacian-face-detection": {"confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.10222391597926617, "faces_detected": false, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 20.0}, "perceptual-robust": {"confidence": 0.9583333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.7648797919973731, "perceptual_mean": 0.8366243655027964, "perceptual_threshold": 0.395}}
The individual analysis classes can be found in its own modules and can be used independently:
>>> from pyblurry.fourier import FastFourierTransformAnalysis
>>> fourier_method = FastFourierTransformAnalysis(image_filepath="blurry_image.jpg")
>>> fourier_method.analyze()
{"method": "fast-fourier-transform", "confidence": 0.9333333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.049961082986555994, "fft_mean": -5.397502609440028, "fft_mean_threshold": 10.0}
>>> from pyblurry.laplacian_face_detection import LaplacianDetectingFaces
>>> laplacian_with_faces_method = LaplacianDetectingFaces(image_filepath="blurry_image.jpg")
>>> laplacian_with_faces_method.analyze()
{"method": "laplacian-face-detection", "confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.126255749957636, "faces_detected": false, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 20.0}
>>> from pyblurry.laplacian_local_blur import LaplacianDetectingLocalizedBlur
>>> laplacian_with_local_blur_method = LaplacianDetectingLocalizedBlur(image_filepath="blurry_image.jpg")
>>> laplacian_with_local_blur_method.analyze()
{"method": "laplacian-local-blur", "confidence": 0.9916666666666667, "is_blurry": true, "resized": true, "elapsed_time": 0.034303167019970715, "local_laplacian_variance": 2.11518251626384, "global_laplacian_variance": 2.11518251626384, "laplacian_threshold": 70.0}
>>> from pyblurry.laplacian_simple import LaplacianSimpleAnalysis
>>> laplacial_simple_method = LaplacianSimpleAnalysis(image_filepath="blurry_image.jpg")
>>> laplacial_simple_method.analyze()
{"method": "laplacian-simple", "confidence": 1.0, "is_blurry": true, "resized": true, "elapsed_time": 0.0004107499262318015, "laplacian_variance": 2.11518251626384, "laplacian_threshold": 19.0}
>>> from pyblurry.perceptual import PerceptualRobustAnalysis
>>> perceptual_method = PerceptualRobustAnalysis(image_filepath="blurry_image.jpg")
>>> perceptual_method.analyze()
{"method": "perceptual-robust", "confidence": 0.9583333333333333, "is_blurry": true, "resized": true, "elapsed_time": 0.8531872910680249, "perceptual_mean": 0.8366243655027964, "perceptual_threshold": 0.395}
The default threshold values for each of the analysis methods has been tuned with a sample of 60 blurry and 60 non-blurry images (also being used for unit tests). The threshold values can (and maybe should) be adjusted if the blur detection is not accurate for the images being used.
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyblurry-1.0.2.tar.gz.
File metadata
- Download URL: pyblurry-1.0.2.tar.gz
- Upload date:
- Size: 30.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
120c4053bd6e7af99ec8ac4c918a024bb21c0b6729081377250299be57dbbaf8
|
|
| MD5 |
97c9996ae4d62e776c93c7d587942462
|
|
| BLAKE2b-256 |
cc93eab2d540031b42bd66b6f837c1b11b314dfa6c05261067bdf56420794587
|
Provenance
The following attestation bundles were made for pyblurry-1.0.2.tar.gz:
Publisher:
python-publish.yml on nachocho/pyblurry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyblurry-1.0.2.tar.gz -
Subject digest:
120c4053bd6e7af99ec8ac4c918a024bb21c0b6729081377250299be57dbbaf8 - Sigstore transparency entry: 729145792
- Sigstore integration time:
-
Permalink:
nachocho/pyblurry@469241df9e493c7325bddf842e6c977275f2d7a4 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/nachocho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@469241df9e493c7325bddf842e6c977275f2d7a4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyblurry-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pyblurry-1.0.2-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
260b2fd39a6acf8806d8d9370c176c1e819ecfe6f7e971ba1efe3f1b20a40b46
|
|
| MD5 |
27a3b3aa6c529684dd836d7538353982
|
|
| BLAKE2b-256 |
41656d6d5d365c8661e5447e44637310746faa56e61bb3b1d0fea3cf1ae108e1
|
Provenance
The following attestation bundles were made for pyblurry-1.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on nachocho/pyblurry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyblurry-1.0.2-py3-none-any.whl -
Subject digest:
260b2fd39a6acf8806d8d9370c176c1e819ecfe6f7e971ba1efe3f1b20a40b46 - Sigstore transparency entry: 729145796
- Sigstore integration time:
-
Permalink:
nachocho/pyblurry@469241df9e493c7325bddf842e6c977275f2d7a4 -
Branch / Tag:
refs/tags/1.0.2 - Owner: https://github.com/nachocho
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@469241df9e493c7325bddf842e6c977275f2d7a4 -
Trigger Event:
release
-
Statement type: