Is there anyway to do gaussian filtering for an image(2D,3D) in pytorch?

I totally agree with everything you said. I completely understand the issue with clarity vs. implementation. I probably would have written it the same way just to make sure everything was right. In actuality since these numbers are only calculated once and then propagated to the rest of the tensor it’s also not that much of a savings either. I only caught it because I’m in the middle of doing Gaussian smoothing and normalizing the smoothing in different ways so this was on my mind!
By the way - there is a site that calculated Gaussian filters - http://dev.theomader.com/gaussian-kernel-calculator/
I am not sure how they normalize because I was never able to get exactly their numbers. I have a little script I wrote in Octave just to make sure the calculation in your code agree with what I believed to be true. We are in agreement :slight_smile: If you understand how that site calculates the normalization - tell me please!

I got an unexpected result, did you get similar looking stuff? attached are input noise image and the unexpected output

Hey, I havent actually used this code in like 2 years. I did test it once on some random image and made sure it looked reasonable.

What settings did you use? i.e. kernel_size and sigma

Hey, sorry I missed your reply! I actually have no idea how they do it, I kind of just played around until I found something that looked like a smoothing filter.

Just took a look at https://github.com/kornia/kornia/blob/master/kornia/filters/kernels.py#L497 and seems like they calculate the 1d gaussian and normalize it by the sum, then do a matmul to make it 2d.