问题
I am using Python 3 on Anacona Spyder on CentOS 7.
The following call
scipy.convolve(nda, box)
gives the following error message.
ValueError: object too deep for desired array
nda and box have the same type and dimensions.
np.shape(nda)
Out[51]: (70, 70, 70)
np.shape(box)
Out[52]: (3, 3, 3)
type(nda)
Out[53]: numpy.ndarray
type(box)
Out[54]: numpy.ndarray
It is my understanding that scipy.convolve can handles multidimensional objects. I cannot understand this error message.
回答1:
The name scipy.convolve is an alias for numpy.convolve, and the NumPy version accepts only one-dimensional input. (This potential confusion is one of the reasons SciPy is deprecating the use of the NumPy names in the scipy namespace.)
You probably want scipy.ndimage.convolve or scipy.signal.convolve. (Why SciPy has independent implementations of convolve in two subpackages is a whole 'nother topic.)
来源:https://stackoverflow.com/questions/59135007/convolution-or-gaussian-filter-difference