5
我已經一些組成,我想在特定呈現幾個2D圖像[X,Y,Z]數據位置相對於使用彼此mayavi2 (v4.3.0)
。Mayavi的 - 設置圖像的[X,Y,Z]程度編程
From the documentation看來,我應該只可以用mlab.imshow()
做到這一點。不幸的是,當我打電話imshow
指定extent
參數(AttributeError: 'ImageActor' object has no attribute 'actor'
)Mayavi的拋出異常。
我還試圖通過修改im.mlab_source.x,y,z...
直接設置x,y和z的數據。古怪,而這正確地更改x和y的程度,它什麼都不做,即使im.mlab_source.z
清楚地改變z位置。
這裏有一個可運行的例子:
import numpy as np
from scipy.misc import lena
from mayavi import mlab
def normal_imshow(img=lena()):
return mlab.imshow(img,colormap='gray')
def set_extent(img=lena()):
return mlab.imshow(img,extent=[0,100,0,100,50,50],colormap='cool')
def set_xyz(img=lena()):
im = mlab.imshow(img,colormap='hot')
src = im.mlab_source
print 'Old z :',src.z
src.x = 100*(src.x - src.x.min())/(src.x.max() - src.x.min())
src.y = 100*(src.y - src.y.min())/(src.x.max() - src.y.min())
src.z[:] = 50
print 'New z :',src.z
return im
if __name__ == '__main__':
# this works
normal_imshow()
# # this fails (AttributeError)
# set_extent()
# weirdly, this seems to work for the x and y axes, but does not change
# the z-postion even though data.z does change
set_xyz()