Questions tagged [convolution]

A mathematical operation that combines two signals to generate a third signal. Convolution often arises in audio processing (e.g., filtering, reverb) and image processing (e.g., blurring, edge detection).

Convolution takes two signals and combines them to generate a third signal. For 1-D signals, the operation can be thought of as sliding the time-reverse of one signal along the other, and at each time step, taking the integral of the product of the signals (see wikipedia). The convolution operation describes the response of linear time-invariant systems to common input signals. Therefore, it commonly occurs in digital signal processing (DSP) contexts. Audio and image processing are two very common application areas for convolution.

A simple implementation for convolving two discrete time signals requires M*N multiply-add operations, where M and N are the lengths of the two signals. However, by taking advantage of the fact that convolution in the time domain is equivalent to multiplication in the frequency domain, and that transforming between domains can be implemented with O(N*log N) operations, convolution can be sped up. See here for more details.


Related tags

2052 questions
0
votes
1 answer

Replicate the TFLite model layers using python function of conv2d etc

If I want to replicate the layers in a TFLite model using python tensorflow functions for performing a few experiments on the tensor data, how do I do that? conv can be done by tf.nn.conv2d, but adding bias to it and then applying relu is not giving…
0
votes
1 answer

Pixelwise regression. How to go from Nx1xHxW to Nx3xHxW?

I have a Nx1xHxW feature maps. I need to add a second head that generates Nx3xHxW representing pixel wise regression with a triplet for each pixel . The question is: how would you go from Nx1xHxW to Nx3xHxW? A fully connected layer would be too…
Mauro Gentile
  • 1,463
  • 6
  • 26
  • 37
0
votes
0 answers

How to do FFT convolve? How to do normalization?

In Python, we can do a convolution by numpy.fft. For example, if we try to calculate gravitational lensing signal of the SIS model, we could define $\kappa$ as $\kappa = \frac{\theta_{\rm E}}{2|\theta|}$, then we can calculate deflection angle…
mimo
  • 55
  • 3
0
votes
1 answer

Convolution of 3D array with 1D kernel in Python

Is it possible to convolve 1D array with 3D array? For example: A is 8x2x2 matrix that I would like to convolve. Assume A has 2x2 sub-matrices of (A = A7 A6 A5... A0) each sub-matrix is 2x2. B is 5x1 array which contains the scalar weights (B0 B1 B2…
cyberfue
  • 16
  • 6
0
votes
1 answer

OpenCV (Python) Erase a Pixel if Any Nearby Pixels are Brighter

I have a grayscale image that has a lot of gradients. I'm only interested in the local "high spots" and want to get rid of everything that isn't the brightest nearby pixel. Specifically what I'm trying to do is erase (set to 0) any pixel where any…
Orion DeYoe
  • 102
  • 1
  • 11
0
votes
2 answers

PyTorch RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed

I'm a college student just getting into Deep Learning, trying to create my first backward propagated model. However, I keep getting the "Trying to backward through the graph a second time, but the saved intermediate results have already been freed."…
0
votes
0 answers

Keras Conv1d input shape problem, Incompatible shapes: [22,10] vs. [22,10,10]

I am trying to use a conv1d to predict time series, but I have trouble with the conv1d input shape. My data 406 samples of 10 values in temporal order. The goal is to predict sample N+1 using sample N as input. Here is a sample of my code : data_x =…
Kalahel
  • 1
  • 1
0
votes
0 answers

How to create Voigt function in Python using np.convolve()?

I'd like to plot the normalized convolution of a Gaussian with a Cauchy-Lorentzian distribution, centered at different points. I'm using the following definitions: Here is my attempt. When fwhm decreases to 0.005, np.trapz() does not return 1 in…
sunny
  • 135
  • 6
0
votes
1 answer

Group convolution in keras

I created a simple neural network for understanding how group convolutions can reduce the number of parameters. But when I use the groups parameter in the second convolution layer, I am getting an unimplemented error. However, when groups parameter…
mike d
  • 3
  • 3
0
votes
1 answer

Linear convolution in R using bandSparse & matrix multiplication

In R I can calculate a linear convolution of a vector y with a convolution kernel K using linconv = function (y,K) { K=K/sum(K) out=convolve(y, K, type="open") …
Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
0
votes
1 answer

Julia DSP: Convolution of discrete signals

Here is the problem. I want to write a convolution for two simple signals x[n]=0.2^n*u[n] and h[n]=u[n+2] for some values of n. This is how I implement it: using Plots, DSP x(n) = if n<0 0 else 0.2^n end h(n) = if n<-2 0 else 1 end n =…
Mahdiar
  • 104
  • 10
0
votes
1 answer

cross kernel 2D convolution with NAs in R

I have a matrix that has NAs. I aim to fill them in using the mean of the 4 neighboring values (a cross pattern). This is the "cross" pattern kernel: kernel [,1] [,2] [,3] [1,] 0.00 0.25 0.00 [2,] 0.25 0.00 0.25 [3,] 0.00 0.25 0.00 Here's a…
Matias Andina
  • 4,029
  • 4
  • 26
  • 58
0
votes
1 answer

Using a Roberts operator on an image

This algorithm is meant to apply a Roberts operator to an image, and store the result in a new file. Instead, this code outputs the exact same image as the input. I am new to Matlab, so your tips and feedback on my code are welcome. I know there is…
superlazyname
  • 265
  • 3
  • 7
  • 17
0
votes
1 answer

How to create a Gaussian kernel of arbitrary width?

How to create a Gaussian kernel by only specifying its width w (3,5,7,9...), and without specifying its variance sigma? In other word, how to adapt sigma so that the Gaussian distribution 'fits well' w? I would be interested in a C++…
T.L
  • 595
  • 3
  • 16
0
votes
1 answer

Understanding 2D convolution output size

I am a beginner in Convolutional DL. I saw the following architecture in paper Simultaneous Feature Learning and Hash Coding with Deep Neural Networks: For images of size 256*256, I do not understand the output size of the first 2D convolution:…