how to distinguish two surfaces in 3D surface plotting?
11 views (last 30 days)
Show older comments
Hello all,
Please needs help in plotting two sets of 3D data (data 1 from experiment and data 2 simulation). I am thinking in using surface or mesh functions with hold on, but at the same time i want to distinguish one surface from the other since they are overlapping at some instances (for example, the mesh line for one surface are thicker and darker or one surface is more transparent than the other or ...). My other question is if there is a function gives surface difference or surface error between the two surfaces.
I really appreciate your suggestions. Thanks Aziz
0 Comments
Answers (2)
Walter Roberson
on 14 Nov 2015
2 Comments
Walter Roberson
on 15 Nov 2015
data1 = rand(40,60);
data2 = randn(40,60);
surf(data1, 'FaceAlpha', 0.8, 'EdgeColor', 'b', 'LineWidth', 2.0);
hold on
surf(data2, 'FaceAlpha', 0.2, 'EdgeColor', 'k', 'LineWidth', 0.2);
hold off
Image Analyst
on 15 Nov 2015
MATLAB does not have good 3D data visualization tools. About all you can do is cutaway views with slice() or isosurface renderings with isosurface().
If your third dimension has 3 planes/slices/channels, then you can treat it as an image and use imfuse() or imshowpair().
surf() is used for 2D data, not 3D data. In other words, you'd use it when you have an array like data(row, column), not a 3D array like data(i,j,k) where you have three indexes (dimensions). surf() produces a 2.5 D surface rendering where the value at each (row,column) location is plotted as a height above a flat plane. Note: this does not mean that the data is now magically 3D - it's still 2D and has two indexes.
If you want true 3D rendering and volume visualization, way more sophisticated than MATLAB, see Avizo
3 Comments
Walter Roberson
on 15 Nov 2015
surf() takes a 2D array of Z data, along with optional X and Y values, and creates a 3D plot from it. You indicated that you have 3D data: if that takes the form of a 3D array, a Value for each X, Y, Z combination, then surf() is not appropriate.
Image Analyst
on 16 Nov 2015
I guess it's a matter of semantics or definition. I deal with 3-D image data sometimes. Now there are varying degrees of what you'd call 3-D plotting or imaging. There is a whole SPIE conference on 3-D imaging and displays, with prototype system exhibited. I have seen true 3D images there like holograms and virtual images created with mirrors and scanning or multiple reflections off layered device. (Think Princess Leia). The image actually (or virtually) exists in 3D.
A step down from that is a pseudo 3D effect like you can get from a stereoscopic system, which usually require polarized glasses (sometimes with shutters) but I've seen some glasses-free stereoscopic system that use lenticular panels with multiple lens sets. These are not really 3D because the image is actually flat but since each eye sees a different view, it's perceived as 3D. Another well known method of turning 2D into perceived 3D is SIRDS or panoramic photography, or this and many others that you can find on YouTube or Google.
A step down from there is a volumetric rendering like you see on the Avizo size, where you have a flat 2D image of a rendered 3D volume or surface. It's not 3D but since your brain knows what it's seeing, it believes that it's 3D particularly if you're able to grab the object and rotate it around. (By the way, Avizo can do either flat screen perspective renderings or can do stereoscopic "3D" if you specify the right options.)
And a further step down, which is why I call it 2.5-D, is something like surf() where you're plotting a z value (which may be an image intensity or something else) as a height above a plane. It's a 2D image because it's on your flat 2D monitor and you don't even have any stereoscopic capabilities. No point of that image is out of a plane - it's just rendered to make you think so. You can't literally wrap your arms or hands around it. But you perceive it as 3D because you understand your underlying data and what it represents.
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!