imgutils.metrics.laplacian

Overview:

Laplacian operator-based blur check algorithm.

Default recommended threshold is 100, lower than 100 means blur.

Note

This algorithm seems work not well on anime blur cases, so this function is just for a reference. We are exploring better algorithm for anime blur detection.

../../_images/laplacian_full.plot.py.svg

This is an overall benchmark of all the operations in laplacian algorithm:

../../_images/laplacian_benchmark.plot.py.svg

laplacian_score

imgutils.metrics.laplacian.laplacian_score(image: str | PathLike | bytes | bytearray | BinaryIO | Image) float[source]

Calculate the Laplacian score for the given image.

The Laplacian score is a measure of image bluriness.

Parameters:

image (ImageTyping) – The input image.

Returns:

The Laplacian score.

Return type:

float

Examples::
>>> from imgutils.metrics import laplacian_score
>>>
>>> laplacian_score('laplacian/hutao.jpg')
156.68285005210006
>>> laplacian_score('laplacian/text_blur.png')
2276.66629157129
>>> laplacian_score('laplacian/real2.png')
15.908745781486806
>>> laplacian_score('laplacian/mmd.png')
1072.8372572065527