convolution

1D Fast Convolution without FFT

不羁岁月 提交于 2019-12-18 03:39:21
问题 I need an 1D Convolution against 2 big arrays. I'm using this code in C# but it takes a loooong time to run. I know, i know! FFT convolutions is very fast. But in this project i CAN'T use it. It is a constraint of the project to not use FFT (please don't ask why :/). This is my code in C# (ported from matlab, by the way): var result = new double[input.Length + filter.Length - 1]; for (var i = 0; i < input.Length; i++) { for (var j = 0; j < filter.Length; j++) { result[i + j] += input[i] *

2d convolution using python and numpy

十年热恋 提交于 2019-12-18 02:27:14
问题 I am trying to perform a 2d convolution in python using numpy I have a 2d array as follows with kernel H_r for the rows and H_c for the columns data = np.zeros((nr, nc), dtype=np.float32) #fill array with some data here then convolve for r in range(nr): data[r,:] = np.convolve(data[r,:], H_r, 'same') for c in range(nc): data[:,c] = np.convolve(data[:,c], H_c, 'same') data = data.astype(np.uint8); It does not produce the output that I was expecting, does this code look OK, I think the problem

An elegant way to get the output of `normxcorr2` in a manner similar to 'conv2' - (removing the unwanted edges)

故事扮演 提交于 2019-12-17 21:11:35
问题 Is there an elegant way in Matlab to get the output of normxcorr2 cropped to the size of the image or cropped only to the part of the matrix that does not use zero padded edges in computation? To understand what I mean, consider the conv2 command. There is an optional parameter called shape that can be set to same or valid . C = conv2(A,B,'same'); C = conv2(A,B,'valid'); For example: size( conv2( rand(50,50) , rand(6,6), 'valid') ) ans = 45 45 size( conv2( rand(50,50) , rand(6,6), 'same') )

Tensorflow + Keras + Convolution2d: ValueError: Filter must not be larger than the input: Filter: (5, 5) Input: (3, 350)

与世无争的帅哥 提交于 2019-12-17 20:51:51
问题 I have been trying to run the code below which I got from here and even though I have changed almost nothing other than the image size (350,350 instead of 150, 150) is still cannot get it to work. I am getting the above filter error (in title) which I do comprehend but I am not doing it wrong so I don't understand this. It basically says that I cannot have more nodes than inputs, correct? I was able to eventually hack my way to a solution by changing this line: model.add(Convolution2D(32, 5,

How to write a convolution multiplication in Android Renderscript?

陌路散爱 提交于 2019-12-17 18:44:06
问题 I am new to Android Renderscript. I need to write a convolution multiplication in RenderScript since the final application is going to run on Android. Data stream is going to be an image. More specifically, I am not able to write the core logic using forEach functionality, though I can do it in Java, but speed it too slow! Please help! Steve 回答1: During the rsForEach call (or other Renderscript function), you can access the neighbouring pixels of the original image (or whatever type of data

Linear convolution of two images in Matlab using fft2

混江龙づ霸主 提交于 2019-12-17 17:59:27
问题 I would like to take two images and convolve them together in Matlab using the 2D FFT without recourse to the conv2 function. However, I am uncertain with respect to how the matrices should be properly padded and prepared for the convolution. The mathematical operation is the following: A * B = C In the above, * is the convolution operator (Wikipedia link). The following Matlab program shows the difference between padding and not padding the matrices. I suspect that not padding the matrices

2D Deconvolution using FFT in Matlab Problems

核能气质少年 提交于 2019-12-17 16:29:31
问题 I have convoluted an image I created in matlab with a 2D Gaussian function which I have also defined in matlab and now I am trying to deconvolve the resultant matrix to see if I get the 2D Gaussian function back using the fft2 and ifft2 commands. However the matrix I get as a result is incorrect (to my knowledge). Here is the code for what I have done thus far: % Code for input image (img) [300x300 array] N = 100; t = linspace(0,2*pi,50); r = (N-10)/2; circle = poly2mask(r*cos(t)+N/2+0.5, r

Is there any implementation of deconvolution?

左心房为你撑大大i 提交于 2019-12-13 23:30:27
问题 Some one may prefer to call it the transposed convolution, as introduced here. I'm looking forward to an implementation of the transposed convolution, in Python or C/C++. Thank you all for helping me! 回答1: Even I am searching for an implementation of transposed convolution. I could only find one in tensorflow module. I am trying to get this working for my problem. Link to Tensor flow API for transposed convolution If it helps, you can also use the regular 2d convolution to do transposed

My function's output differs from conv2() output

感情迁移 提交于 2019-12-13 18:38:42
问题 Below is the code I have written to convolve an image with a x-direction Sobel mask. The function inputs a gray-scale image along with a kernel to be convolved with. However, the result I am getting is different compared to the result I get from the built-in conv2() function. Why is that? What am I doing wrong? Here's my function's output: Here's conv2() output: 回答1: You are computing the correlation. The 2D convolution is a 180 degree rotation (flip both axes) of the kernel. h = rot90(h,2);

Keras beginner: what is supposed to be the output shape of the last layer?

亡梦爱人 提交于 2019-12-13 15:23:26
问题 I'm having a hard time wrapping my head around the math behind CNN's and how exactly I should modify the output shape in between layers of my neural network. I am trying to do the carvana image masking challenge on kaggle https://www.kaggle.com/c/carvana-image-masking-challenge . So in other words, I'm trying to create a neural network that, given a picture of a car, can identify the boundaries of the car within that image and crop it out from the rest of the background. So my inputs are all