MATLAB: Help – Smoothing surf plot, reduce surf detail and speed up performance

interpolationMATLABsurf

Hi everyone
I've got a large 3000×2000 matrix (Z) that represents the depth values for a topogrpahical surface plot. Because of the blurring between colour depth I get a very pixelated, sharp ridge line (see image 1 below). I've applied a medfilt2 and then interp2 to try and smooth out the ridges on the plot. This seems to work, but it's a lot of data points and it's running very slow. Is there a way to reduce the points and smooth the plot?
Z_med = medfilt2(Z, [5 5]);
Z_int = interp2(Z_med);
figure
s = surf(Z_int);
% This gets the best results, but is slow and hard to work with
I've tried plotting less points (every 10th point), but this just resulting in really jagged edges (see image 2), and I'm not sure if the way I did this is right (it doesn't look right)? I've also tried plotting a courser grid, but the way I am doing it is wrong?
% Method 1 - Jagged ridges - Failure
step_plot = filt_plot(1:10:end,1:10:end);
Z_int = interp2(step_plot);
figure
s = surf(Z_int);
% Method 2 - Trying to interp2 for a coarser grid - Doing something wrong here - Fails
X = size(Z_med,1);
Y = size(Z_med,2);
[Xq,Yq] = meshgrid(1:2:X,1:2:Y);
Vq = interp2(X,Y,Z_med,Xq,Yq,'cubic');
figure
surf(Xq,Yq,Vq);
I was hoping to get a smooth plot between depth layers, and plot less points, but not getting the jaggered spikes like below…
Any help would be greatly appreciated!
surf_detail.PNG
surf_detail_02.PNG

Best Answer

Have you tried taking a look at the shading function?
Specifically, it sounds like you are looking for the interpolation feature which is set by
shading interp