How to do 3D Gaussian filtering in OpenCV?

I have a multidimensional matrix and I want to smooth Gaussian smoothing not only in 2D along x and y , but also want to smooth over the channels in 3D. How can I do this in OpenCV?

I know there is a function called GaussianBlur that can apply a Gaussian filter in 2D, but what about 3D? What you can call it looks something like this:

 GaussianBlur(frame, frame2, Size(sigma, sigma), 0, 0); 
+7
c ++ image-processing opencv filtering
source share
1 answer

It is not supported by OpenCV natively. However, since Gaussian filtering is separable, you can filter each size separately.

Use a combination of BaseRowFilter : http://docs.opencv.org/modules/imgproc/doc/filtering.html#BaseRowFilter and BaseColumnFilter : http://docs.opencv.org/modules/imgproc/doc/filtering.html#BaseColumnFilter and specify the gaussian kernels as 1D.

Use getGaussianKernel : http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=gauss#getgaussiankernel to help you compute a one-dimensional Gaussian kernel without having to do it yourself.

Now, for the third dimension, it will be difficult. You will need to apply separate row / column filters to each 3D fragment at a specific spatial location. For example, if you had a volume of 5 fragments, and the size of one image was 10 x 10, the final result of filtering in 3D is to extract 100 1D signals of size 5, and then apply the core to each of these 1D signals separately.

Take a look at this post for a deeper understanding: How to do Gaussian filtering in 3D . Someone else tried to do this in the past.

Good luck

+2
source share

All Articles