-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
restoration.wiener doc example gives poor result #6018
Comments
Thanks for reporting this @elena-pascal. I can reproduce the same issue on the current development branch as well. I think the problem is in the value of 1100 in this line:
I think at some point this function must have changed how the data was rescaled internally and the value of 1100 for |
Oh I see. The test is also written for a |
Dear @elena-pascal (and @grlee77 😉), Looking at the history, I don't think that I guess this was simply never caught because there is neither a visual check (as in plotting, like you've done) nor a quantitative test (as in Indeed, the only recent changes that this function and its docstring have undergone recently (a few months ago vs. 7 or 8 years ago) are:
Neither change can account for a value of So, I would say, please go ahead and update the docstring! To determine an optimal Thanks again for reporting! PS: This link https://pro.orieux.fr/files/papers/OGR-JOSA10.pdf (provided in the references) is now broken. 🙁 |
Some time passed. Sorry to reopen this, I finally got around to do the recommended changes to the documentation. Thank you @mkcor for detailed response. I did have a look at the blur metric tool and it does indeed quantify what the eye can see. Unfortunately, for looking at the balance value in deconvolution is not entirely useful, unless I didn't understand how to use it, since with smaller and smaller balance values the blur metric gets infinitely smaller and smaller. Which makes sense. At some point the deconvolution edge effects are becoming worse than the deblur we get and that is not accounted in the blur metric. That is to say I ended up eyeballing a value of 0.1 for the balance in the example since it looked the best compromise to me. |
Dear @elena-pascal, Thank you so much for working on this! Eyeballing a balance value of 0.1 looks reasonable; for future reference: import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import convolve2d
from skimage import color, data, measure, restoration
img = color.rgb2gray(data.astronaut())
psf = np.ones((5, 5)) / 25
conv = convolve2d(img, psf, 'same')
rng = np.random.default_rng()
noised = conv + 0.1 * conv.std() * rng.standard_normal(conv.shape)
# Try different balance values for image restoration using Wiener-Hunt deconvolution
balance_values = [1100, 1, 0.1, 0.01, 0.001]
restored_images = [restoration.wiener(noised, psf, balance=b) for b in balance_values]
fig, ax = plt.subplots(nrows=2, ncols=3, figsize=(8, 8))
plt.gray()
ax[0, 0].imshow(img)
ax[0, 0].set_title('Original')
ax[0, 0].axis('off')
ax[0, 1].imshow(restored_images[0])
ax[0, 1].set_title('Restoration w/ balance = 1100')
ax[0, 1].axis('off')
ax[0, 2].imshow(restored_images[1])
ax[0, 2].set_title('Restoration w/ balance = 1')
ax[0, 2].axis('off')
ax[1, 0].imshow(restored_images[2])
ax[1, 0].set_title('Restoration w/ balance = 0.1')
ax[1, 0].axis('off')
ax[1, 1].imshow(restored_images[3])
ax[1, 1].set_title('Restoration w/ balance = 0.01')
ax[1, 1].axis('off')
ax[1, 2].imshow(restored_images[4])
ax[1, 2].set_title('Restoration w/ balance = 0.001')
ax[1, 2].axis('off')
fig.subplots_adjust(wspace=0.02, hspace=0.01,
top=0.9, bottom=0.05, left=0, right=1)
plt.show() The blur metric measures the blur effect (or blur annoyance) which is associated with a loss of details (i.e., loss of high-frequency content). The lower the balance value, the more high-frequency content, which looks 'sharper' to the blur metric... It makes sense, indeed, but clearly we are not moving towards better and better restoration quality as the blur metric simply tends to 0. [measure.blur_effect(im) for im in restored_images] outputs this sequence of decreasing values for the blur metric: [0.9271564699373505,
0.5667472924590226,
0.4533045608494091,
0.32612928916395323,
0.2085498573057157] So my suggestion about "determining an optimal balance value" doesn't work in an absolute sense... Not giving up on using the blur metric as "a means to compare the quality of restoration methods or scaling methods," I checked its value for the original image: measure.blur_effect(img) which turns out to be 0.39957512013087865 so that's how 'blurry' it is to begin with. The restored image with balance = 0.1 has (among the five Let me poke @ladretp who authored this blur metric and might have some feedback for us... I'll review your PR now. Thanks again! |
Thank you for documenting what I was trying to explain. I do like your idea of how to use the blur metric as a way to find an optimal value that is not necessary the smallest value. |
Hello
Le 27/02/2022 à 13:14, Marianne Corvellec a écrit :
The blur metric measures the blur effect (or blur annoyance) which is
associated with a loss of details (i.e., loss of high-frequency
content). The lower the balance value, the more high-frequency
content, which looks 'sharper' to the blur metric... It makes sense,
indeed, but clearly we are not moving towards better and better
restoration quality as the blur metric simply tends to 0.
Yes it's clear that blur metric cannot be the only criterion for the
quality of an image restoration, as bounce effects are often much more
annoying than blur from a perceptual point of view. I don't think that
this measure can be used to find the right parameters for a restoration
algorithm, or possibly combined with other criteria.
Patricia
|
Dear @ladretp, Thank you for your precious feedback! Sure, in real-world problems, we don't have the ground truth... |
* Fix small typos. * Fix for #6018 * Replace broken link * Attempt consistent spelling * Update doc/examples/filters/plot_restoration.py, skimage/restoration/deconvolution.py Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
It is unchanged on this page: https://scikit-image.org/docs/stable/api/skimage.restoration.html#wiener |
* Fix small typos. * Fix for scikit-image#6018 * Replace broken link * Attempt consistent spelling * Update doc/examples/filters/plot_restoration.py, skimage/restoration/deconvolution.py Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
Description
I had a look at the Example code for Wiener-Hunt deconvolution and the result I get looks blurrier than the image it starts with. Is this the expected behavior? I played around with the balance parameter but it didn't help. I am trying to understand if this is the deconvolution that would be applicable to my problem.
Way to reproduce
Version information
The text was updated successfully, but these errors were encountered: