i tried to understand the 2D & 3D plotting function in Matlab, regarding to the image processing filters, like box-plots, gauss, mexican hats and so on…
I only got the kernel for the filters, e.g. a 5×5 matrix with the coefficents of each cell.
ezsurfc won’t work and I don’t understand it.
surf instead works, but I got no clue about the grids and how to make it more granular and smooth?
My understanding of surf is, that I need the same dimensions for each param, so how should I do it without making my kernel a 20×20 or even larger?
The idea is, that I get an output like the examples, i’ve posted. I mentioned the 20×20 grid mask of the filter, because it looks like that the smoothness and the flattening needs more coefficients than just 5×5… am I right or totally wrong?
I already tried the following matlab code, example for a laplace filter:
[x,y] = meshgrid(1:1:5); %create a 5x5 matrix for x and y (meshes)
z = [0 1 2 1 0; 1 3 5 3 1;2 5 9 5 2; 1 3 5 3 1;0 1 2 1 0]; % kernel 5x5
surf(x,y,z);
That gives me that output:

So how do I generate a fine and granular 2D and a 3D plot out of that 5×5 kernel information?
Big thanks in advance!
P.S.: Hopefully my code indentions aren’t messed up… otherwise feel free to edit – it’s my first post on StackOverflow. 🙂
What I want to get, is like these two examples:


You can use interp2 to find intermediate values on the same grid size for visualization purposes
Note that you will obtain the closest approximation to your original kernel using the default linear interpolation method, i.e.
interp2(x,y,z,xn,yn,'linear'). Using other methods will result in smoother kernels to use, but their 3D shape will differ. So it depends on your use and application.Update:
You can by-pass the ill-posed problem of up-sampling to a much higher resolution (the inverse reconstruction is possible only if the hypothetical “downsampling respects the Nyquist sampling rate) by trying to approximate your data with a known kernel, which then you can tune.
For example, since you are give an example of a symmetric kernel, that decays isotropicaly around a maximum value, you can use a Gaussian function. MATLAB does so through
fspecialfunction.Assume the underlying function (e.g. Gaussian) and use parameters defined from your current kernel (i.e. fitting a function to your data)
This way you respect the parameters of the kernel in the Gaussian lobe, but control the grid-size and resolution of the final Gaussian kernel.
Some examples: