python通过视频生成三维图像_使用python的3​​D绘图影像合成

1586010002-jmsa.png

I have a 3d plot of lines generated by matplotlib. I want to overlay an image at a specific xy (or yz, xz) slice. How do I do that using python? Thanks.

I have a simple 3d plot code as:

fig = plt.figure(1),

ax = Axes3D(fig)

ax.plot(f[:,0], f[:,1], f[:,2], color='r')

I also have an image "Im" (a 2d array), so I need something like:

ax.overlay(Im, slice='xy', sliceNo=10)

解决方案

I did a 3d surface plot overlay on top of a background image once:

oyl6c.jpg

If this is similar to what you want, I could try to make a working example out of it.

Alternatively, if you just want to display an image in 3d space, you can use a surface plot:

from pylab import *

from mpl_toolkits.mplot3d import Axes3D

from matplotlib.cbook import get_sample_data

from matplotlib._png import read_png

fn = get_sample_data("lena.png", asfileobj=False)

img = read_png(fn)

x, y = ogrid[0:img.shape[0], 0:img.shape[1]]

ax = gca(projection='3d')

ax.plot_surface(x, y, 10, rstride=5, cstride=5, facecolors=img)

show()

Of course, the stride values can be decreased to 1 for better image quality, but then drawing will take loooong =)

Resulting image from above code:

R4ar1.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值