convolution

Finding for convolution kernel if many 0's for FFT?

独自空忆成欢 提交于 2019-12-13 13:44:47
问题 I know that original_image * filter = blur_image , where * is the convolution. Thus, filter = ifft(fft(blur)/fft(original)) I have an original image, the known filter, and the known blurred image. I tried the following code. I just want to compare the computed filter using fft and ifft and compare it with the known filter. I tried in Matlab: orig = imread("orig.png") blur = imread("blur.png") fftorig = fft(orig) fftblur = fft(blur) div = fftblur/fftorig conv = ifft(div) The result doesn't

Different image dimensions during training and testing time for FCNs

早过忘川 提交于 2019-12-13 13:36:53
问题 I am reading multiple conflicting Stackoverflow posts and I'm really confused on what the reality is. My question is the following. If I trained an FCN on 128x128x3 images, is it possible to feed an image of size 256x256x3 , or B) 128x128 , or C) neither since the inputs have to be the same during training and testing? Consider SO post #1. In this post, it suggests that the images have to be the same dimensions during input and output. This makes sense to me. SO post #2: In this post, it

Nvidia NPP nppiFilter produces garbage when convolving with 2d kernel

a 夏天 提交于 2019-12-13 13:11:00
问题 Nvidia Performance Primitives (NPP) provides the nppiFilter function for convolving a user-provided image with a user-provided kernel. For 1D convolution kernels, nppiFilter works properly. However, nppiFilter is producing a garbage image for 2D kernels. I used the typical Lena image as input: Here's my experiment with a 1D convolution kernel, which produces good output. #include <npp.h> // provided in CUDA SDK #include <ImagesCPU.h> // these image libraries are also in CUDA SDK #include

Filtering image with fft

旧巷老猫 提交于 2019-12-13 06:29:57
问题 I am trying to apply filter to image using 2D FFT. I have filter matrix (convolution kernel etc), but if I want to use fft I need to expand filter and picture matrix to power of 2 square matrix. First I expand it with zeros (so matrix of picture and filter would be in top left corner of big power of 2 matrix) and I got this result Then I tried what I did with picture matrix when I was applying convolution without fft, padded picture matrix with filter dimension/2 from each side, and than that

how to optimize convolution matrix in android

别等时光非礼了梦想. 提交于 2019-12-12 20:57:49
问题 I am using Convolution Matrix for my android app for making image Emboss. i have defined the class for it as: public class ConvolutionMatrix { public static final int SIZE = 3; public double[][] Matrix; public double Factor = 1; public double Offset = 1; public ConvolutionMatrix(int size) { Matrix = new double[size][size]; } public void setAll(double value) { for (int x = 0; x < SIZE; ++x) { for (int y = 0; y < SIZE; ++y) { Matrix[x][y] = value; } } } public void applyConfig(double[][] config

How do you handle negative pixel values after filtering?

爱⌒轻易说出口 提交于 2019-12-12 17:02:48
问题 I have a 8-bit image and I want to filter it with a matrix for edge detection. My kernel matrix is 0 1 0 1 -4 1 0 1 0 For some indices it gives me a negative value. What am I supposed to with them? 回答1: Your kernel is a Laplace filter. Applying it to an image yields a finite difference approximation to the Laplacian operator. The Laplace operator is not an edge detector by itself. But you can use it as a building block for an edge detector: you need to detect the zero crossings to find edges

1D Convolution without if-else statements (non-FFT)?

做~自己de王妃 提交于 2019-12-12 17:01:53
问题 I've written a simple serial 1D convolution function (below). I'm also experimenting with GPU convolution implementations. This is mostly for my own curiosity; I'm trying to learn the performance tradeoffs among various non-FFT implementation strategies. Avoiding branching will be important for my GPU convolution experiments, since branching is expensive on Nvidia GPUs. One of my friends mentioned that there's a way to implement the code below without if/else statements, but he couldn't

In OpenCV, what data types does cv2.filter2D() expect?

北城以北 提交于 2019-12-12 15:02:26
问题 I'm teaching myself about edge detectors, and I'm trying to use OpenCV's filter2D to implement my own gradient calculator, similar to cv2.Sobel() . In the Python interface to OpenCV, cv2.filter2D() allows users to convolve an image with a custom filter. In OpenCV nomenclature, this filter is called a "kernel." Using an image (per00001.png) from the MIT pedestrian dataset, I find that cv2.Sobel() produces a reasonable looking output. (Code is below, output image is here.) #OpenCV's Sobel code

Numpy filter to smooth out zero-regions

僤鯓⒐⒋嵵緔 提交于 2019-12-12 14:29:37
问题 I have a 2D numpy array of ints 0 and greater, where the values represent region labels. For example, array([[9, 9, 9, 0, 0, 0, 0, 1, 1, 1], [9, 9, 9, 9, 0, 7, 1, 1, 1, 1], [9, 9, 9, 9, 0, 2, 2, 1, 1, 1], [9, 9, 9, 8, 0, 2, 2, 1, 1, 1], [9, 9, 9, 8, 0, 2, 2, 2, 1, 1], [4, 4, 4, 4, 0, 2, 2, 2, 1, 1], [4, 6, 6, 4, 0, 0, 0, 0, 0, 0], [4, 6, 6, 4, 0, 0, 0, 0, 0, 0], [4, 4, 4, 4, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 5, 5, 5, 5, 5, 5]]) I would like the indices equal to 0 (i.e. zero-regions) to take on

Convolutional neural networks vs downsampling?

点点圈 提交于 2019-12-12 10:25:36
问题 After reading up on the subject I don't fully understand: Is the 'convolution' in neural networks comparable to a simple downsampling or 'sharpening' function? Can you break this term down into a simple, understandable image/analogy? edit: Rephrase after 1st answer: Can pooling be understood as downsampling of weight matrices? 回答1: Convolutional neural network is a family of models which are proved empirically to work great when it comes to image recognition. From this point of view - CNN is