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

Convolutional neural network is a continous function?

The question is: is convolutional neural network architecture a continuous function? By convolutional I mean made of only convolutional layers. Intuitively I would say yes, since as far as I know the operation of convolution is continuous, but am I…
0
votes
1 answer

Converting a color image into grayscale using a 3x3 convolution kernel

I am writing a python script that would use a 3x3 kernel to convert an image from color to grayscale. I created a function that takes an 'image' and a 'kernel' as parameters, and returns the grayscale version of the image. Inside of the function I…
0
votes
0 answers

Convolution that uniquely identifies all possible spatial patterns

I'm working on a problem that requires searching for some unique 3x3 patterns in binary images. My current method is to do a convolution with a kernel where each value is a different power of two, essentially producing a 9-bit number for each pixel.…
Ted
  • 1
0
votes
1 answer

Find max and min of convolution without doing convolution

Is it possible to find the max and min of both the horizontal and vertical convolution axis without going through and performing the actual convolution?
icelov
  • 1
  • 2
0
votes
0 answers

how to access weights of 4-bit QAT model

I have a toy example of CNN mnist digit keras tensorflow model , I have quantized the 2 Conv2D layers and 2 dense layers in it to 4-bit , now I want to access the weights of Conv2D layer. But if I try that using get_weights() it returns a list of…
0
votes
1 answer

Numpy sum messing up adding negative numbers

I'm trying to code a simple convolution loop for image processing. It seems to work fine when the kernel adds up to 1 i.e smoothing filter. But when using an edge detection filter, weird values appear: for i in range(img.shape[1]): index = [] …
0
votes
0 answers

Speeding up groupby rolling calculations

At first I was using a really slow approach: df.groupby("name")["P"].transform(lambda x: x.rolling(5, min_periods=).mean()) So I started looking into how to speed this up. I read about convolution and learned how to use it. This was the function I…
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
0
votes
2 answers

How to write a kernel for pytorch convolution function?

I want to make convolution of matrix np.random.seed(0) m_numpy = np.random.choice([0,1],p=(0.5,0.5),size=(6,6)) m = torch.from_numpy(Z_numpy).type(torch.FloatTensor) tensor([[1., 1., 1., 1., 0., 1.], [0., 1., 1., 0., 1., 1.], [1.,…
user13467695
0
votes
1 answer

Custom loss function in tensorflow involving convolution

I'm trying to implement a custom loss function using convolution of an image with a kernel, very similar to what this question is doing. I have prepared my data to be in the format of (batch_size, height, width, channels). Specifically for my case,…
Bio
  • 113
  • 5
0
votes
0 answers

Performing deconvolution to solve for x given y and h where y = h*x (all column vectors)

The Matlab has its built-in function deconv() which performs deconvolution perfectly. However, I was trying to make another simple implementation using the property of Toeplitz matrix in calculating convolution, but it seems to be not universal. Can…
WilliamW
  • 17
  • 6
0
votes
1 answer

understanding pytorch conv2d internally

I'm trying to understand what does the nn.conv2d do internally. so lets assume we are applying Conv2d to a 32*32 RGB image. torch.nn.Conv2d(3, 49, 4, bias=True) so : when we initialize the conv layer how many weights and in which shapes would it…
Farhang Amaji
  • 742
  • 11
  • 24
0
votes
1 answer

Processing 4D input with 2D Convolution in Tensorflow

I am having trouble understanding how 2D Conv calculations are done on 4D inputs. Basically, this is the situation, I have an image of height, width, channels = 128, 128, 103. I want each of these 103 channels to be processed individually as if I'm…
Nour
  • 197
  • 1
  • 3
  • 13
0
votes
1 answer

How can I implement non-linear kernel convolution?

I want to detect circles in black-white images without morphology or hough transform. Example if images: They represent irices. In order to do that I want to use convolution with a kernel. Currently I am using the kernel of the following…
Nourless
  • 729
  • 1
  • 5
  • 18
0
votes
1 answer

Image processing convolution: Why do I slide my kernel from np.arange(pad, imgWidth+pad)?

I am trying to learn kernel convolution for image processing. Now, I understand the concept of kernel convolution, but I am a bit confused about code that I have found for it at…