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

Wiener filter divide by zero errors if uniform patch in image #9015

Open
OisinMoran opened this issue Jul 10, 2018 · 0 comments
Open

Wiener filter divide by zero errors if uniform patch in image #9015

OisinMoran opened this issue Jul 10, 2018 · 0 comments

Comments

@OisinMoran
Copy link

The wiener filter from scipy.signal is encountering divide by zero errors/warnings for images that have a patch of uniform colour. Any help in fixing this or working around it would be greatly appreciated!

Reproducing code example:

import numpy as np
import scipy.signal

image = np.random.randint(0, 256, size=(8, 8, 3))
image[2:6, 2:6, :] = 137 # can be any number
wiener_filtered = scipy.signal.wiener(image.astype('float32'), mysize=(3, 3, 1))

Error message:

/home/paperspace/anaconda3/lib/python3.6/site-packages/scipy/signal/signaltools.py:950: RuntimeWarning: divide by zero encountered in true_divide
  res *= (1 - noise / lVar)
/home/paperspace/anaconda3/lib/python3.6/site-packages/scipy/signal/signaltools.py:950: RuntimeWarning: invalid value encountered in multiply
  res *= (1 - noise / lVar)

Scipy/Numpy/Python version information:

0.19.1 1.13.1 sys.version_info(major=3, minor=6, micro=2, releaselevel='final', serial=0)

Image of error and example problem image:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants