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

Convolution output gets flipped after convolution operation?

I am trying to implement an emboss filter in SparkAR. It works, but the final output is flipped. The code below is what I modified from https://www.shadertoy.com/view/ld3XW4 so it would work within the software, but idk what I could have done that…
0
votes
1 answer

if and else in Convolution function

I have a problem with use if and else statement in convolution function. this code return error: use any() or all() import matplotlib.pyplot as plt import numpy as np def name(y): if y<300 : print("if") fun2=y-6 return fun2 …
shahram
  • 11
  • 3
0
votes
0 answers

How to obtain the filter kernel matrix for a 2d gaussian convolution

Consider a 64 x 64 pixel image (2d matrix), where each pixel represents 100nm in size. Say most of these pixels have a value of 0, and some have a positive value (1,2,...). I want to convolve these pixels with a 2d gaussian that will transform the…
hexaquark
  • 883
  • 4
  • 16
0
votes
1 answer

Numerical Convolution of Two Signals in MATLAB and Plotting the Output

without using conv() command, I want to convolve two signals: This is the code I write: syms n k i f= @(n) 2.*(0<=n<=9); h(n)=((8/9)^n).*heaviside(n-3); L = length(f); M = length(h(n)); out=L+M-1; y=zeros(1,out); for i = 1:L for k = 1:M …
blit
  • 75
  • 1
  • 8
0
votes
0 answers

Python: Confidence intervall for arbitrary probability distribution function

Is there a method in python to calculate the mean and confidence interval of an array of data points with an arbitrary probability distribution function? I need to calculate the mean and confidence interval for the convolution of a discrete Gaussian…
0
votes
1 answer

explication of the function scipy.ndimage.convolve1d

when I have two array x1, x2 and I write this code : n=len(x1) p=len(x2) S=convolve1d(x1,x2,mode=‘constant’) mathematically S is equal to what using x1,x2,n,p ? and thank you
0
votes
0 answers

PyTorch simple ConvNet diverge so easly

So I'm studiying pytorch coming from a background with tensorflow. I'm trying to replicate a simple convnet, that I've developed with success in tensorflow, to classify cat vs dogs images. In pytorch I see some strange behaviors: Using a Learning…
0
votes
1 answer

Image Convolution with callback function in python

I want to loop over the pixels of a binary image in python and set the value of a pixel depending on a surrounding neighborhood of pixels. Similar to convolution but I want create a method that sets the value of the center pixel using a custom…
0
votes
0 answers

Failed to match cmsis-nn convolution function outputs with hand calculation for IN-channels greater than 1

I am new to ML/AI as a start I am trying to run a convolution layer on M4 by using CMSIS-NN function calls and comparing the output results with a hand calculated outputs for the same inputs and kernel. I am using an arm_convolve_HWC_q7_basic…
0
votes
1 answer

How to apply convolution in-place on GPU (in Python)

I need to perform a convolution on an image in-place, and by in-place I mean such that as the structuring element gets applied to different pixels, I want the result of the previous steps to overwrite the image. To put it in context, this is useful…
Blademaster
  • 324
  • 2
  • 15
0
votes
0 answers

Can't call numpy() on Tensor that requires grad while defining convolute method

I am using the following snippet while defining the convolution method in python I am trying to implement the convolution code which is implicitly defined by the library in python. def conv(x, in_channels, out_channels, kernel_size, stride, padding,…
0
votes
1 answer

int object has no attribute shape while defining convolutions

I am using the following snippet for implementing convolution function in CNN. def conv(x, in_channels, out_channels, kernel_size, stride, padding, weight, bias): """ Args: x: torch tensor with size (N, C_in, H_in, W_in), in_channels: number…
Steamer
  • 19
  • 1
0
votes
0 answers

How to reduce the number of for loops I used for convolution of a 2D gray scale Image?

Constraints: can not call on convolve, correlate, fftconvolve, or any other similar functions. Query: Is there a way to get rid of the for loops I used to perform the convolution because for larger sized images the efficiency of the program would…
0
votes
1 answer

Convolution filter returns partly black image, where am I going wrong here? Need to build a blurring filter from a numpy array

I have the following function: def convolve(image, kernel): image_copy=image.copy() row=0 column=0 while column
liatkatz
  • 51
  • 5
0
votes
1 answer

How to re-use a single weight per group across all channels in pytorch?

Let's suppose I have the following 2D convolution layer: nn.Conv2d(kernel_size=(1,20), stride=1, groups=5, out_channels=30, in_channels=30, bias=False), What it does is that it creates a weight of 30x6x1x20 dimension, and in my model it results in…
Anonymous
  • 4,692
  • 8
  • 61
  • 91