pythonimportscipythresholdscipy.stats

Cannot import name 'threshold' from scipy.stats


I am trying to use function threshold from scipy package.

from scipy.stats import threshold
I_t=threshold(I, threshmin=2, threshmax=400, newval=-1) # I is an array containing image data

However, i am getting an error message saying

cannot import name 'threshold' from 'scipy.stats'


Solution

  • The function threshold was deprecated in SciPy 0.17.0 and removed from SciPy 1.0.0. Use numpy.clip (with arguments adjusted appropriately) instead.