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