How can I make contour lines smoother?
Mostrar comentarios más antiguos
How can I make contour lines smoother?
Respuestas (3)
Kelly Kearney
el 20 de Jun. de 2013
The easiest way to do this is to interpolate your data to a higher resolution using an interpolation scheme that will result in smoother transitions between points, such as a spline.
[x,y,z] = peaks(10);
[xnew, ynew] = meshgrid(linspace(-3,3,100));
znew = interp2(x,y,z,xnew,ynew, 'spline');
subplot(2,1,1);
hold on;
scatter(x(:), y(:), [], z(:), 'filled');
contour(x,y,z, -6:7);
subplot(2,1,2);
hold on;
scatter(x(:), y(:), [], z(:), 'filled');
contour(xnew, ynew, znew, -6:7);
Be careful with this, though, since it might introduce some artifacts. Even though it may not be as visually pleasing, the low-res, less-smooth version is a more accurate depiction of the underlying data.
1 comentario
Konstantin
el 3 de Abr. de 2017
Thanks. Very useful example.
Image Analyst
el 20 de Jun. de 2013
0 votos
Please post an image or screenshot. For example, one way could be to blur your image with conv2() or imfilter() before you call contour().
Categorías
Más información sobre Surface and Mesh Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!