Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract arbitrarily rotated plane of data from 3D array as 2D array

I have a 3D matrix of data in matlab, but I want to extract an arbitrarily rotated slice of data from that matrix and store it as a 2D matrix, which I can access. Similar to how the slice() function displays data sliced at any angle, except I would also like to be able to view and modify the data as if it were an array.

I have the coordinates of the pivot-point of the plane as well as the angles of rotation (in x, y and z axis), I have also calculated the equation of the plane in the form:

Ax + By + Cz = D

and can extract a 3D matrix containing only the data that fall on that plane, but I don't know how to then convert that into a simple 2D array.

Another way of doing it would be to somehow rotate the source matrix in the opposite direction of the angle of the plane, so as to line up the plane of data with the XY axis, and simply extract that portion of the matrix, but I do not know if rotating a matrix like that is possible.

I hope this hasn't been answered elsewhere, I've been googling it all day, but none of the problems seem to exactly match mine.

Thanks

like image 257
Nick Udell Avatar asked Jan 31 '12 16:01

Nick Udell


1 Answers

You can take a look at the code here. I think the function is similar to what you are trying to solve.

The function extracts an arbitrary plane from a volume given the size of the plane, the center point of the plane, and the plane normal, i.e. [A,B,C]. It also outputs the volumetric index and coordinate of each pixel on the plane.

like image 150
pangyuteng Avatar answered Oct 16 '22 13:10

pangyuteng