admin管理员组文章数量:1386656
I have an array img_data
of shape (x, x, n_channels) and I want to convolve / smooth along the axis=2.
Specifically, I would like the output shape to be (x,x,n_channels//3), after convolving the frequency channels. I want to use a Lorentzian as a kernel for convolving.
I build the kernel as:
def lorentzian_kernel(x, center, gamma):
norm = 1 / np.pi
kernel = norm * (gamma / ((x - center) ** 2 + gamma ** 2))
return kernel
So img_data
is 3D array with n_channels depth and each channel is a square image. Each channel has a center frequency central_freq
and FWHM
which I shall use to make the kernels:
gamma = FWHM / 2
,
center = central_freq
and
x = np.linspace(central_freq_channel1, central_freq_channeln, 1000)
What operation should I use for smoothing along the channel axis? Do I have to do a dot product or convolution along axis=2 ? I am bit confused, so I would appreciate some comments. Thanks
本文标签: pythonHow to convolve a 3D array with Lorentzian kernel along axis2Stack Overflow
版权声明:本文标题:python - How to convolve a 3D array with Lorentzian kernel along axis=2? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744493357a2608869.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论