convolution

Converting 2d mask to 1d in Gaussian blur

冷暖自知 提交于 2019-11-29 15:22:22
问题 I am trying to implement the Gaussian blur. I have already computed the mask using the 2d function provided on wikipedia. I currently have a 2d matrix. I understand that in order to improve the running time, one can avoid using standard convolution methods due to the seperability of the Gaussian. In other words, as this This answer says, "In the Gaussian blur case it breaks down to two one dimensional operations". This page has been helpful, however, I do not understand how to obtain a 1d

Tensorflow's asymmetric padding assumptions

时间秒杀一切 提交于 2019-11-29 14:16:46
问题 Why has TensorFlow chosen to prefer padding on the bottom right? With SAME padding, to me it would feel logical to start the kernel's center anchor at the first real pixel. Due to the use of asymmetric padding, this results in a discrepancy with some other frameworks. I do understand that asymmetric padding in principle is good because otherwise one would be left with an unused padding row/column. If TensorFlow would have given presedence to padding on the left and top, it would do

Compute mean squared, absolute deviation and custom similarity measure - Python/NumPy

时间秒杀一切 提交于 2019-11-29 10:57:44
I have a large image as an 2D array (let's assume that it is a 500 by 1000 pixels gray scale image). And I have one small image (let's say is it 15 by 15 pixels). I would like to slide the small image over the large one and for a given position of the small image I would like to calculate a measure of similarity between the small image and the underling part of the big image. I would like to be flexible in choosing a measure of similarity. For example I might want to calculate mean squared deviation or mean absolute deviation or something else (just some operation that takes two matrices of

scipy convolve2d outputs wrong values

微笑、不失礼 提交于 2019-11-29 08:05:12
Here is my code which I used for checking the correctness of convolve2d import numpy as np from scipy.signal import convolve2d X = np.random.randint(5, size=(10,10)) K = np.random.randint(5, size=(3,3)) print "Input's top-left corner:" print X[:3,:3] print 'Kernel:' print K print 'Hardcording the calculation of a valid convolution (top-left)' print (X[:3,:3]*K) print 'Sums to' print (X[:3,:3]*K).sum() print 'However the top-left value of the convolve2d result' Y = convolve2d(X, K, 'valid') print Y[0,0] On my computer this results in the following: Input's top-left (3x3) corner: [[0 0 0] [1 1 2

1D Fast Convolution without FFT

﹥>﹥吖頭↗ 提交于 2019-11-29 02:18:47
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] * filter[j]; } } So, anyone knows any fast convolution algorithm widthout FFT? Convolution is numerically

2d convolution using python and numpy

霸气de小男生 提交于 2019-11-28 23:27:57
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 is with the casting from float32 to 8bit. Whats the best way to do this Thanks Since you already have

Convolutional Neural Network (CNN) for Audio [closed]

雨燕双飞 提交于 2019-11-28 15:48:50
I have been following the tutorials on DeepLearning.net to learn how to implement a convolutional neural network that extracts features from images. The tutorial are well explained, easy to understand and follow. I want to extend the same CNN to extract multi-modal features from videos (images + audio) at the same time. I understand that video input is nothing but a sequence of images (pixel intensities) displayed in a period of time (ex. 30 FPS) associated with audio. However, I don't really understand what audio is, how it works, or how it is broken down to be feed into the network. I have

Understanding NumPy's Convolve

谁都会走 提交于 2019-11-28 15:38:34
When calculating a simple moving average, numpy.convolve appears to do the job. Question: How is the calculation done when you use np.convolve(values, weights, 'valid') ? When the docs mentioned convolution product is only given for points where the signals overlap completely , what are the 2 signals referring to? If any explanations can include examples and illustrations, it will be extremely useful. window = 10 weights = np.repeat(1.0, window)/window smas = np.convolve(values, weights, 'valid') Convolution is a mathematical operator primarily used in signal processing. Numpy simply uses this

Tensorflow Strides Argument

允我心安 提交于 2019-11-28 14:59:51
I am trying to understand the strides argument in tf.nn.avg_pool, tf.nn.max_pool, tf.nn.conv2d. The documentation repeatedly says strides: A list of ints that has length >= 4. The stride of the sliding window for each dimension of the input tensor. My questions are: What do each of the 4+ integers represent? Why must they have strides[0] = strides[3] = 1 for convnets? In this example we see tf.reshape(_X,shape=[-1, 28, 28, 1]) . Why -1? Sadly the examples in the docs for reshape using -1 don't translate too well to this scenario. dga The pooling and convolutional ops slide a "window" across

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

柔情痞子 提交于 2019-11-28 14:19:49
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') ) ans = 50 50 size( conv2( rand(50,50) , rand(6,6)) ) ans = 55 55 Currently I wrote my own function, that