Hi,
I have 2D initial values for a model and I am trying to smooth it. I would say the easiest way is the apply a gaussian filter on it. My problem is that I don’t have the same resolution in y and in x. I would like to know if there is a way to have an isotropic blurring regardless of the initial resolution?
Here is a MRE to make it clearer:
using Plots
incircle(;x₀,y₀, r) = (y, x) -> hypot(y - y₀, x - x₀) <= r
nx = 100
ny = 200
Lx = 100
Ly = 50
x = range(1, Lx, nx)
y = range(1, Ly, ny)
model = zeros(ny, nx)
incircle(;x₀=25, y₀=50, r=20)(1,1)
for (j, y) in enumerate(y), (i, x) in enumerate(x)
if incircle(;x₀=50, y₀=25, r=20)(y, x) == true
model[j,i] = 1
else
model[j,i] = 0
end
end
heatmap(x, y, model, aspect_ratio=:equal)
which produces:
So I have a circle with a different resolution in x and y.
I have tried to blurred using ImageFiltering that way:
blur = imfilter(model, Kernel.gaussian(1));
heatmap(x, y,blur, aspect_ratio=:equal)
with the result:
So you can see that it’s smoother in the x direction because there is less points
I am not an expert at all on kernels and convolutions but reading the docs, I see that I can change the size of the kernel in the x or y direction. Should I play with that? Or is what I am trying to do not achievable because I can’t get over the difference in resolution and hence precision in 1 axis?