Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

python - Is it possible to directly apply an affine transformation matrix to a Mayavi ImageActor object?

I'm using Mayavi to render some imaging data that consists of multiple 2D planes within a 3D volume, the position, orientation and scale of which are defined by 4x4 rigid body affine transformation matrices. Each plane consists of:

  • An array of 2D image data, which I display using mayavi.mlab.imshow
  • A set of ROIs consisting of lines and points that I draw using mayavi.mlab.points3d and mayavi.mlab.plot3d respectively.

I transform my points and line vertices from a 2D reference plane into the 3D space by dotting their coordinates with my affine matrix. Based on my previous question/answer here, I figured out that I could set the positions and orientations of the ImageActor objects individually, using:

obj = mlab.imshow(img)
obj.actor.orientation = [pitch, roll, yaw] # the required orientation (deg)
obj.actor.position = [dx, dy, dz] # the required position 
obj.actor.scale = [sx, sy, sz] # the required scale

Now the plot looks like this:

enter image description here

Everything lines up nicely, but it's very difficult to interpret because the planes are so densely spaced in z. What I'd now like to be able to do is 'stretch out' the z-axis by some scaling factor. In the case of the points and lines this is very easy to do - all I do is multiply all of the transformed z-coordinates by a scaling factor.

However, I can't figure out how to apply the same transformation to the images. If I just scale the z-position, the rotation and scaling of the images will of course be wrong, and my plotted points/lines will no longer fall on the same plane as the image:

enter image description here

What I need to do is apply a non-rigid affine transformation that incorporates shear as well as rotation, translation and scaling to my images.

Is there any way I can manually apply shear to an ImageActor, or even better just directly apply an arbitrary 4x4 affine matrix that I've precomputed?

question from:https://stackoverflow.com/questions/17406954/is-it-possible-to-directly-apply-an-affine-transformation-matrix-to-a-mayavi-ima

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...