Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image enhancement measure (EME) #3776

Open
wants to merge 57 commits into
base: main
Choose a base branch
from
Open
Changes from 13 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8bec6b0
Proposition to add the following image quality assessment function
iliailmer Feb 27, 2019
d2b7135
Proposition to add the following image quality assessment function
iliailmer Feb 27, 2019
130d912
modified examples
iliailmer Mar 1, 2019
9bfe66e
pep8 corrections
iliailmer Mar 1, 2019
a798d36
pep8 corrections
iliailmer Mar 1, 2019
4c3fa15
changed name to 'enhancement_measure', placed the funciton into measu…
iliailmer Mar 1, 2019
6f02d9b
some pep8 corrections
iliailmer Mar 1, 2019
f9c5b69
change to examples
iliailmer Mar 9, 2019
d266205
added name to __all__, fixed examples"
iliailmer Mar 9, 2019
651d332
removed unnecessary files
iliailmer Mar 27, 2019
268d0e2
filter parameter is used instead of
iliailmer Mar 28, 2019
ac8e9ab
added epsilon instead of +1 to avoid division by zero.
iliailmer Mar 28, 2019
4fd9f8d
added intensity rescaling to account for images with negative intensi…
iliailmer Mar 28, 2019
86e0bed
doctest fixes
iliailmer Apr 1, 2019
f41fa48
added unit tests and fixed some numerial stability issues
Apr 9, 2019
47a73ee
some identation
Apr 10, 2019
81d8022
added explanations in doc
iliailmer Apr 17, 2019
c5300cc
gallery example for enhancement measure
iliailmer Apr 18, 2019
9dc5646
Update skimage/measure/simple_metrics.py
sciunto Apr 22, 2019
d6e30cf
added DOI, fixed name typo, improved consistency in parameter order
iliailmer Apr 23, 2019
996b73e
Update skimage/measure/simple_metrics.py
stefanv Apr 25, 2019
6676cb1
Update doc/examples/filters/plot_enhancement_measure.py
stefanv Apr 25, 2019
0a53d2e
Update doc/examples/filters/plot_enhancement_measure.py
stefanv Apr 25, 2019
755e276
Update doc/examples/filters/plot_enhancement_measure.py
stefanv Apr 25, 2019
e223b0b
Update doc/examples/filters/plot_enhancement_measure.py
stefanv Apr 25, 2019
42b4cb0
doc file corrections, reference reformatting
iliailmer Apr 25, 2019
b511c3a
doc example corrections
iliailmer Apr 25, 2019
8e6b65c
doc example corrections
iliailmer Apr 25, 2019
b6c78e4
Update doc/examples/filters/plot_enhancement_measure.py
stefanv Apr 29, 2019
40f89ee
small changes to citation format
iliailmer Apr 30, 2019
79b15d6
fixed critical error in example
iliailmer May 1, 2019
3eb1b94
plt.show -> fig.show
iliailmer May 2, 2019
ae7110e
fixed artifacts in docs and comments
iliailmer May 3, 2019
82be96e
added blank line to docs
iliailmer May 3, 2019
6b22824
Merge pull request #1 from scikit-image/master
iliailmer Jun 28, 2019
e68c091
edited formatting for the example
iliailmer Aug 22, 2019
6c90991
Merge branch 'master' into image-quality
iliailmer Aug 22, 2019
8bfe430
PEP8 corrections
iliailmer Aug 22, 2019
cf6028a
Merge remote-tracking branch 'upstream/master'
iliailmer Oct 4, 2019
085a0f7
Merge remote-tracking branch 'upstream/master'
iliailmer Nov 4, 2019
fa922a2
fixed conflict in test_simple_metrics.py
iliailmer Nov 8, 2019
cd4c3dc
added '_' to name 'correct_mesh_orientation'
iliailmer Nov 8, 2019
7077399
fixed deprecation warnings
iliailmer Nov 8, 2019
aba255c
remove unnecessary function call, changed args to call for normalized…
iliailmer Nov 8, 2019
3654f92
one more fix for normalized_root_mse
iliailmer Nov 8, 2019
91404f9
pep8 fix
iliailmer Nov 8, 2019
2cdad14
docstring fix: blank line
iliailmer Nov 8, 2019
470a87d
docstring fix: blank line
iliailmer Nov 8, 2019
4ab00af
docstring fix: blank line
iliailmer Nov 8, 2019
fd61c0c
docstring fix: blank line
iliailmer Nov 8, 2019
3d7dd31
docstring fix
iliailmer Nov 9, 2019
208c641
doi backquotes
iliailmer Nov 10, 2019
de9345a
removed doi
iliailmer Nov 11, 2019
ed4f7cf
Merge branch 'main' into pr3776-image-quality
lagru Jan 6, 2023
73a95e9
Re-add enhancement_measure after merge
lagru Jan 6, 2023
0872877
Remove type hints and improve docstring
lagru Jan 7, 2023
8fcdc8c
Add a link to the reference paper
lagru Jan 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions skimage/measure/simple_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
import numpy as np
from ..util.dtype import dtype_range
from .._shared.utils import skimage_deprecation, warn
from ..util import img_as_float
from ..exposure import rescale_intensity
from scipy.ndimage import maximum_filter, minimum_filter


__all__ = ['compare_mse',
lagru marked this conversation as resolved.
Show resolved Hide resolved
'compare_nrmse',
'compare_psnr',
'enhancement_measure'
]


Expand Down Expand Up @@ -142,3 +147,51 @@ def compare_psnr(im_true, im_test, data_range=None):

err = compare_mse(im_true, im_test)
return 10 * np.log10((data_range ** 2) / err)


def enhancement_measure(image: np.ndarray,
eps: float = 1e-7,
size: int = 3) -> float:
iliailmer marked this conversation as resolved.
Show resolved Hide resolved
"""
The image enhancement measure called EME based on [1]_.
lagru marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
image : array
Input image of which the quality should be assessed.
Can be either 3-channel RGB or 1-channel grayscale.
The function converts pixel intensities into floats by default.
size : int
iliailmer marked this conversation as resolved.
Show resolved Hide resolved
Size of the window. Default value is 3.
eps : float
iliailmer marked this conversation as resolved.
Show resolved Hide resolved
iliailmer marked this conversation as resolved.
Show resolved Hide resolved
Parameter to avoid division by zero. Default value is 1e-7.
lagru marked this conversation as resolved.
Show resolved Hide resolved
Returns
-------
eme : float
The number describing image quality.

References
----------
.. [1] Agaian, Sos S., Karen Panetta, and Artyom M. Grigoryan.
"A new measure of image enhancement."
IASTED International Conference on Signal Processing
& Communication. Citeseer, 2000.
iliailmer marked this conversation as resolved.
Show resolved Hide resolved
Examples
emmanuelle marked this conversation as resolved.
Show resolved Hide resolved
--------
>>> from skimage.data import camera
>>> from skimage.exposure import equalize_hist
>>> img = camera()
>>> quality(img) # before
lagru marked this conversation as resolved.
Show resolved Hide resolved
0.9096745071475523
>>> quality(equalize_hist(img))
1.299327371881219

"""

image = img_as_float(image)
image = rescale_intensity(image, out_range=(0., 1.))
eme = np.zeros_like(image)
lagru marked this conversation as resolved.
Show resolved Hide resolved
eme = np.divide(maximum_filter(image, size=size),
minimum_filter(image, size=size) + eps)
eme = np.mean(20 * np.log(eme))
return eme