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

skimage.transform.resize #6047

Closed
page200 opened this issue Nov 20, 2021 · 6 comments
Closed

skimage.transform.resize #6047

page200 opened this issue Nov 20, 2021 · 6 comments
Labels
🫂 Support User help and QA

Comments

@page200
Copy link

page200 commented Nov 20, 2021

Description

It seems that skimage.transform.resize with anti_aliasing=True smoothes too much. For example, if we want to resize a 100×100 image to 100×17, it should smoothen only the second dimension before downsampling, but it smoothes both dimensions.

Version information

# Paste the output of the following python commands
from __future__ import print_function
import sys; print(sys.version)
import platform; print(platform.platform())
import skimage; print(f'scikit-image version: {skimage.__version__}')
import numpy; print(f'numpy version: {numpy.__version__}')
>>> from __future__ import print_function
>>> import sys; print(sys.version)
2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]
>>> import platform; print(platform.platform())
Windows-10-10.0.19041
>>> import skimage; print(f'scikit-image version: {skimage.__version__}')
  File "<stdin>", line 1
    import skimage; print(f'scikit-image version: {skimage.__version__}')
                                                                       ^
SyntaxError: invalid syntax
>>> import numpy; print(f'numpy version: {numpy.__version__}')
  File "<stdin>", line 1
    import numpy; print(f'numpy version: {numpy.__version__}')
                                                            ^
SyntaxError: invalid syntax
@mkcor
Copy link
Member

mkcor commented Nov 22, 2021

Hi @page200,

Are you running Python 2.7 on purpose? 😱

Best,
Marianne

@page200
Copy link
Author

page200 commented Nov 22, 2021

@mkcor My setup is dictated by attempts to get some other projects to run (not related to skimage). The attempts succeeded and then there was no need to "change the running system". Anyway, the bug seems unrelated to the Python version.

@grlee77
Copy link
Contributor

grlee77 commented Nov 22, 2021

Can you specify what version of scikit-image you are having problems with? Apparently the commands suggested above don't work on whatever version it is, but if had installed it using pip you can check with pip list.

It looks like since scikit-image v0.14.x, the default standard deviation for the smoothing is related to the downsampling factors:

if anti_aliasing_sigma is None:
anti_aliasing_sigma = np.maximum(0, (factors - 1) / 2)

It also possible to specify anti_aliasing_sigma as a sequence of floats to set specific user-defined values on a per-axis basis.

@page200
Copy link
Author

page200 commented Nov 22, 2021

@grlee77

scikit-image version is 0.14.5 according to pip list.

When not manually specifying per-axis values, the automatically chosen values should be appropriate rather than too large. For example, for dimensions along which the image size doesn't change, sigma should be zero.

@grlee77
Copy link
Contributor

grlee77 commented Nov 22, 2021

I agree, but it looks like that is what the code is doing even in v0.14.5? In your case:
factors = (100/100, 100/17) = (1.0, 5.88) so anti_aliasing_sigma should end up being ((1 - 1)/2, (5.882 - 1)/2) which is (0.0, 2.441)

@page200
Copy link
Author

page200 commented Nov 22, 2021

Maybe I misinterpreted from which dimension the blurredness comes from in the results. I'll further test with toy data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🫂 Support User help and QA
Projects
None yet
Development

No branches or pull requests

4 participants