I am new to image processing and am trying to understand gaussian blur filter. I understand the meaning/idea behind using a gaussian filter and a quick google search gives a variety of different APIs to implement a gaussian filter on an image.
But what I don't understand is -> what is the difference between applying a 1D gaussian filter vs a 2D gaussian filter?
Is a 1D filter only applicable on a 1D array of input? So we need a 2D filter (or 2 1D filters) for a 2D image/signal?
Also, I am having trouble calculating the value of a gaussian filter from a given value of sigma. Assume that I have an input signal and also a value of sigma, how to go about calculating the gaussian kernel for this signal? I did come across some solutions online but I could not understand them. I know the Gaussian function but I cannot seem to understand how we would calculate the entries of the gaussian kernel given the information of input signal and sigma. Any suggestions are highly appreciated!
Related
I'am working on line scan rgb camera trying to remove to noises coming from camera due to intensity variations, to remove that i chosen gaussian filter to remove the noises and iam having 1d rgb pixels, now iam stuck in how to generate the standard deviation and kernel size for the gaussian 1d filter, iam implementing using an verilog programming language and new to the image processing can i help for this problem.
your standard deviation should be equal to kernel_size/6 .
if you choose big number for kernel size then your blurry be higher too.
so,you should test some kernel_size then pick the best one .
I know that deconvolution is basically convolution of output with flipped filters and I have implemented it for 2D data. But I am not able to generalize it for 3D data. For example consider the input of dimension 3x5x5 and the filter is of dimension 3x3x3 and stride is set to 1. SO, the output will be of the dimension 1x3x3. What I don't understand is how to calculate the deconvolution for this output. The flipped filter again will be of dimension 3x3x3 and output of convolution is of dimension 1x3x3 which are incompatible for convolution. So how can we calculate deconvolution ?
Perhaps this post will help you out a bit. You are correct in saying that a filter of the same size cannot fit the deconvolution dimensions. So in order to remedy that, the 1x3x3 gets padded throughout with zeros, mean-values, nn, etc. until it is the appropriate size that you require. Depth can be handled the same way. In your example, you want a 3x3x3 filter to 'deconvolve' the 1x3x3 to a 3x5x5. So we pad out the 1x3x3 to a 5x7x7 (with whichever method you prefer), and apply the filter. There are definite drawbacks with this process, stemming from the fact that you're trying to extrapolate more information from less.
Please, I want to get on code in Matlab to estimate derivatives of an Image (Ix, Ixy, Ixxx) using a recursive Gaussian filter.
In order to evaluate the performance impact (both computational and quality-wise) of using a box filter / mean filter vs using a gaussian filter, I an wondering if there is a proper relationship between the size of the box filter and the sigma of a gaussian filter with "equivalent" smoothing.
To be more specific, I need to compare the difference between subsampling an image by a factor of two using a 2x2 box filter vs. using an eqivalent gaussian filter which would take into account more than 4 samples.
I have two ideas on how to approach this:
finding the equivalent sigma by minimizing the squared difference between the box function and the gaussian function
doing the same in fourier space (box filter would translate to a sinc filter)
Furthermore, I am not really sure how to incorporate the discretized space we are living here. Is the corresponding gaussian filter simply the one where the weights of the four nearest samples are closest to 1/4?
The following paper by Peter Kovesi is a useful reference: http://www.peterkovesi.com/papers/FastGaussianSmoothing.pdf. I'll let you go through the mathematical derivations yourself, but essentially the relationship between the width of the average / box filter and the standard deviation of the Gaussian filter can be found by the following relationship:
This states that given a box / average filter of width w x w, the equivalent standard deviation to apply to achieve roughly the same effect when using a Gaussian blur can be found by the above mathematical relationship.
I´m trying to make an implementation of Gaussian blur for a school project.
I need to make both a CPU and a GPU implementation to compare performance.
I am not quite sure that I understand how Gaussian blur works. So one of my questions is
if I have understood it correctly?
Heres what I do now:
I use the equation from wikipedia http://en.wikipedia.org/wiki/Gaussian_blur to calculate
the filter.
For 2d I take RGB of each pixel in the image and apply the filter to it by
multiplying RGB of the pixel and the surrounding pixels with the associated filter position.
These are then summed to be the new pixel RGB values.
For 1d I apply the filter first horizontally and then vetically, which should give
the same result if I understand things correctly.
Is this result exactly the same result as when the 2d filter is applied?
Another question I have is about how the algorithm can be optimized.
I have read that the Fast Fourier Transform is applicable to Gaussian blur.
But I can't figure out how to relate it.
Can someone give me a hint in the right direction?
Thanks.
Yes, the 2D Gaussian kernel is separable so you can just apply it as two 1D kernels. Note that you can't apply these operations "in place" however - you need at least one temporary buffer to store the result of the first 1D pass.
FFT-based convolution is a useful optimisation when you have large kernels - this applies to any kind of filter, not just Gaussian. Just how big "large" is depends on your architecture, but you probably don't want to worry about using an FFT-based approach for anything smaller than, say, a 49x49 kernel. The general approach is:
FFT the image
FFT the kernel, padded to the size of the image
multiply the two in the frequency domain (equivalent to convolution in the spatial domain)
IFFT (inverse FFT) the result
Note that if you're applying the same filter to more than one image then you only need to FFT the padded kernel once. You still have at least two FFTs to perform per image though (one forward and one inverse), which is why this technique only becomes a computational win for large-ish kernels.