Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a 1D Gaussian filter in Julia?

Tags:

julia

I have an array which I want to filter using a Gaussian filter, similarly to scipy.ndimage.filter.gaussian_filter1d in Python.

What package would work best for this, and how would I use it?

like image 840
Anshul Singhvi Avatar asked Sep 20 '19 13:09

Anshul Singhvi


People also ask

What is a 1d Gaussian filter?

1. Gaussian Filtering. Gaussian filtering is used to blur images and remove noise and detail. g.

What is a 2D Gaussian filter?

The Gaussian smoothing operator is a 2-D convolution operator that is used to `blur' images and remove detail and noise. In this sense it is similar to the mean filter, but it uses a different kernel that represents the shape of a Gaussian (`bell-shaped') hump.

What is Gaussian filter algorithm?

Gaussian Filtering is widely used in the field of image processing. It is used to reduce the noise of an image. In this article we will generate a 2D Gaussian Kernel. The 2D Gaussian Kernel follows the below given Gaussian Distribution.


2 Answers

In Julia, the ImageFiltering.jl package can help you do this.

You can construct a 1D Gaussian kernel by ker = ImageFiltering.Kernel.gaussian((3,)) (the tuple is passed to represent the dimension of the desired output).

Then, if you have an array of data in data, you can perform the filtering operation by:

newdata = imfilter(data, ker)

If you want to do in-place filtering, there is also imfilter!.

like image 92
Anshul Singhvi Avatar answered Oct 25 '22 02:10

Anshul Singhvi


In addition to Kernel.gaussian((σ,)), there is also KernelFactors.IIRGaussian((σ,)), which constructs an infinite-impulse response approximation to the Gaussian. This can be useful for very fast approximate-Gaussian filtering when σ is fairly large.

like image 23
tholy Avatar answered Oct 25 '22 02:10

tholy