convolution

Image convolution with even-sized kernel

隐身守侯 提交于 2019-12-05 04:56:51
I want to perform a simple 2D image convolution but my kernel is even-sized. Which indices I should pick for my kernel center? I tried googling for an answer and looking existing codes. People usually center their kernel so there would be one sample more before the new 0. So, if we have a 4x4 kernel the centered indices should be -2 -1 0 +1 . Is that correct? And if it is, why is that so? Can someone explain why -2 -1 0 +1 is correct while -1 0 +1 +2 is not? Keep in mind that I want to perform the convolution without using FFT. If I understand your question correctly, then for even sized

2D convolution by 1D convolution using separable properties

半城伤御伤魂 提交于 2019-12-05 04:17:20
问题 I am writing a program in which I am doing lots of 2D convolution. So i thought that a more efficient approach may be that to use 1D convolution. But I seem to be stuck on this . Till now, I have referred to this links : check this 1) http://blogs.mathworks.com/steve/2006/10/04/separable-convolution/ check this 2) http://blogs.mathworks.com/steve/2006/11/28/separable-convolution-part-2/ I have a gaussian kernel(K) of size 5X5. I need to convolve this kernel function with the image. My image

The different with the image convolve with the conv2D of keras

徘徊边缘 提交于 2019-12-04 19:33:27
The goal is trying to using a customize weight on the first layer of model to full fill the function of highpass filter---make the first layer of Model is the same as the high pass filter to the image. 1.first, the similar solution will be: using a high pass filter in the image processing, and generate a new image, and use it in the model. ---this is have to use the image processing, which is cost of time. 2.I want to set the a layer of Conv2D , which is also able to high pass the image. with a custom filter( as a intializer). the basic is that the filter and the conv2D is both using

How correctly calculate tf.nn.weighted_cross_entropy_with_logits pos_weight variable

别等时光非礼了梦想. 提交于 2019-12-04 18:22:28
I am using convolution neural network. My data is quite imbalanced, I have two classes. My first class contains: 551,462 image files My second class contains: 52,377 image files I want to use weighted_cross_entropy_with_logits , but I'm not sure I'm calculating pos_weight variable correctly. Right now I'm using classes_weights = tf.constant([0.0949784, 1.0]) cross_entropy = tf.reduce_mean(tf.nn.weighted_cross_entropy_with_logits(logits=logits, targets=y_, pos_weight=classes_weights)) train_step = tf.train.AdamOptimizer(LEARNING_RATE, epsilon=1e-03).minimize( cross_entropy , global_step=global

2D circular convolution Vs convolution FFT [Matlab/Octave/Python]

好久不见. 提交于 2019-12-04 14:21:42
问题 I am trying to understand the FTT and convolution (cross-correlation) theory and for that reason I have created the following code to understand it. The code is Matlab/Octave, however I could also do it in Python. In 1D: x = [5 6 8 2 5]; y = [6 -1 3 5 1]; x1 = [x zeros(1,4)]; y1 = [y zeros(1,4)]; c1 = ifft(fft(x1).*fft(y1)); c2 = conv(x,y); c1 = 30 31 57 47 87 47 33 27 5 c2 = 30 31 57 47 87 47 33 27 5 In 2D: X=[1 2 3;4 5 6; 7 8 9] y=[-1 1]; conv1 = conv2(x,y) conv1 = 24 53 89 29 21 96 140 197

Understanding and evaluating template matching methods

倾然丶 夕夏残阳落幕 提交于 2019-12-04 13:11:12
OpenCV has the matchTemplate() function, which operates by sliding the template input across the output, and generating an array output corresponding to the match. Where can I learn more about how to interpret the six TemplateMatchModes ? I've read through and implemented code based on the tutorial , but other than understanding that one looks for minimum results for TM_SQDIFF for a match and maximums for the rest, I don't know how to interpret the different approaches, and the situations where one would choose one over another. For example (taken from the tutorial) res = cv.matchTemplate(img

Gaussian Blur with FFT Questions

回眸只為那壹抹淺笑 提交于 2019-12-04 13:08:04
问题 I have a current implementation of Gaussian Blur using regular convolution. It is efficient enough for small kernels, but once the kernels size gets a little bigger, the performance takes a hit. So, I am thinking to implement the convolution using FFT. I've never had any experience with FFT related image processing so I have a few questions. Is a 2D FFT based convolution also separable into two 1D convolutions ? If true, does it go like this - 1D FFT on every row, and then 1D FFT on every

PHP sharpness convolution martix

谁都会走 提交于 2019-12-04 13:02:14
I'm using a convolution matrix for sharpness in PHP GD and I want to change the sharpness "level" . Where would I make changes to this if I want to make it more or less sharp ? $image = imagecreatefromjpeg('pic.jpg'); $matrix = array( array(0, -1, 0), array(-1, 5, -1), array(0, -1, 0) ); imageconvolution($image, $matrix, 1, 0.001); header("Content-type: image/jpeg"); imagejpeg($image); try looking on http://www.gamedev.net/reference/programming/features/imageproc/page2.asp There are lots of examples on the web, but as a rule of thumb you may try these params first in GIMP or PS or any other

How is using im2col operation in convolutional nets more efficient?

自古美人都是妖i 提交于 2019-12-04 12:07:34
问题 I am trying to implement a convolutional neural netwrok and I don't understand why using im2col operation is more efficient. It basically stores the input to be multiplied by filter in separate columns. But why shouldn't loops be used directly to calculate convolution instead of first performing im2col ? 回答1: Well, you are thinking in the right way, In Alex Net almost 95% of the GPU time and 89% on CPU time is spent on the Convolutional Layer and Fully Connected Layer. The Convolutional Layer

Calculating the blur kernel between 2 images

让人想犯罪 __ 提交于 2019-12-04 10:01:20
问题 Unlike the standard (and more challenging) de-blurring and super resolution scenarios, I have access to both the original (sharp) image G and it's blurred version B . I'm simply looking for the blur kernel h . So because B is taken using a real camera the relation is: B=G*h+N (where * denotes convolution and N is some additive noise) Naturally, this is an over-constrained problem since h is small in size compared to G and B and so every few pixels in the pair of images generate an equation on