convolution

Small value artifacts from applying scipy.signal.convolve

Small value artifacts from applying scipy.signal.convolve Question: This Python 3.11.5 script: import numpy as np from skimage.io import imread from scipy.signal import convolve image = np.flipud(imread(‘conv-test.bmp’).astype(np.float32)) con = convolve(image, np.ones((3, 3))/9, mode=’valid’) print(image.min()) print(np.logical_and(image > 0, image < 1).any()) print(np.logical_and(con > 0, con < 0.00001).any()) produces: 0.0 False True How is it possible to get …

Total answers: 1

Convolution of a Gaussian with an asymmetrical Gaussian

Convolution of a Gaussian with an asymmetrical Gaussian Question: I’m looking to convolve a Gaussian with an asymmetric Gaussian. My attempt at this is below. import numpy as np import matplotlib.pyplot as plt x=np.linspace(0,5,500) dx=x[1]-x[0] # Gaussian sigma1=0.1 peak1=1 gauss1=np.exp(-(x-peak1)**2/(2*sigma1**2)) # Asymmetric Gaussian gauss2=0.5*np.exp(-(x-1.5)**2/(-0.2+x*0.4)**2) # convolution conv=np.convolve(gauss1,gauss2,mode=’same’)*dx plt.plot(x,gauss1,label=’Gaussian’) plt.plot(x,gauss2,label=’Asymmetric Gaussian’) plt.plot(x,conv,label=’Convolution’) plt.xlim(0,5) plt.legend() plt.show() I …

Total answers: 2

How to convolution integration(Duhamel Integration) by python?

How to convolution integration(Duhamel Integration) by python? Question: Hi~ I’m studying about structural dynamics. I want to make a code about Duhamel Integration which is kind of Convoution Integration. If the initial conditions are y(0)=0 and y'(0)=0, Duhamel Integration is like this. enter image description here Using Ti Nspire I solved this problem with my …

Total answers: 1

Convolution of 2D arrays

1D Convolution of 2D arrays Question: I have 2 arrays of sets of signals, both 16×90000 arrays. In other words, 2 arrays with 16 signals in each. I want to perform matched filtering on the signals, row by row, correlating row 1 of array 1 with row 1 of array 2, and so forth. I’ve …

Total answers: 1

What happens in a convolution when the stride is larger than the kernel?

What happens in a convolution when the stride is larger than the kernel? Question: I recently was experiment with convolutions and transposed convolutions in Pytorch. I noticed with the nn.ConvTranspose2d API (I haven’t tried with the normal convolution API yet), you can specify a stride that is larger than the kernel size and the convolution …

Total answers: 2

Is there a function in Python similar to Matlab's deconvblind?

Is there a function in Python similar to Matlab's deconvblind? Question: I’m working on blind deconvoltuion. In iterating L2norm reguralization, I want to update the PSF at the same time, and when I looked it up, I found a function called deconvblind in Matlab: l[J,PSF] = deconvblind(I,INITPSF) deconvolves image I using the maximum likelihood algorithm, …

Total answers: 2

Why does nn.Conv1d work on 2d feature [b, c, h, w]?

Why does nn.Conv1d work on 2d feature [b, c, h, w]? Question: I am wondering why conv1d works on 2d feature(batch, channel, height, width). An nn.Conv1d(channel, channel, kernel_size=(1,1)) works when I put 2d feature, but gives different result from nn.Conv2d(channel, channel, kernel_size=1). I want to know why conv1d works and what it mean by 2d …

Total answers: 2