scipy.convolve gives “ValueError: object too deep for desired array” with 3D array and 3D kernel

血红的双手。 提交于 2019-12-20 07:47:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!