如何使用 surf 可视化 3D 场景

发布于 2024-09-30 12:01:36 字数 357 浏览 2 评论 0 原文

我有一个从磁盘加载的图像作为纹理,以及一个具有相应深度的相同大小的矩阵 d 。

如何使用 surf 将图像显示为 3D 模型?简单地拍摄

surf(depthMatrix, img);

并不能得到很好的结果,因为

  1. 相机看起来不是从 z 方向的 xy 平面
  2. 它看起来相当黑
  3. 它看起来并不那么平滑,尽管当我使用 imshow 显示它时我的深度矩阵实际上被平滑了(深度矩阵,[]);

图像看起来像什么

I have an image loaded from disk as a texture, and a same-sized matrix d which has the corresponding depths.

How can I use surf to show me the image as a 3d-model? Simply taking

surf(depthMatrix, img);

doesn't give a nice result since

  1. the camera looks not from the x-y plane in z-direction
  2. It looks fairly black
  3. It doesn't look that smooth although my depth matrix is actually smoothed out when I show it using imshow(depthMatrix, []);

image how it looks like

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如此安好 2024-10-07 12:01:36

您可以使用纹理映射在表面上显示图像,如下所示:

surf(depthMatrix,img,...           %# depthMatrix is z data, img is an image
     'FaceColor','texturemap',...  %# Use texture mapping
     'EdgeColor','none');          %# Turn off edge coloring

并解决您的 3 点:

  1. 您可以通过按 按钮,可打开交互式 3-D 旋转。您还可以使用函数 ROTATE3D 打开交互式旋转,或者您可以使用函数 VIEW 来更改相机视图,而无需使用鼠标。< /p>

  2. 你的图看起来是黑色的,因为默认情况下边缘被绘制为黑线,并且可能有很多。

  3. 您可以调整轴缩放和限制以使您的表面显得更光滑。例如,axis equal 将使所有 3 个轴的数据单位相同,因此您的 z 轴(范围从 0 到 25)将显着扁平化,因为其他两个轴的跨度范围为数百个。或者,在调用 SURF 时,您可以指定 x 和 y 数据用于这些轴上的值,这最终可以帮助您更好地调整这些轴和 z 轴之间的相对缩放比例。

You can use texture mapping to display your image on your surface like so:

surf(depthMatrix,img,...           %# depthMatrix is z data, img is an image
     'FaceColor','texturemap',...  %# Use texture mapping
     'EdgeColor','none');          %# Turn off edge coloring

And to address your 3 points:

  1. You can adjust your camera angle with the mouse by pressing the alt text button on the figure, which turns on interactive 3-D rotation. You can also turn interactive rotation on using the function ROTATE3D, or you can change the camera view without the mouse using the function VIEW.

  2. Your plot was looking black because edges are drawn as black lines by default, and there were probably a lot of them.

  3. You can adjust the axis scaling and limits to make your surface appear smoother. For example, axis equal will make data units the same for all 3 axes, so your z axis (which ranges from 0 to 25) will be flattened significantly since your other two axes span ranges in the hundreds. Alternatively, in your call to SURF you can specify x and y data to use for the values on those axes, which can ultimately help you to better adjust the relative scaling between those axes and the z axis.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文