New solution attempt:
After the tutorial http://blogs.mathworks.com/steve/2006/08/17/spatial-transformations-three-dimensional-rotation/ and making minor changes, I might have something that could help you. Keep in mind that I have little or no experience with bulk data in MATLAB, so the implementation is pretty hacky.
In the code below, I use tformarray () to rotate the structure in space. First, the data is centered and then rotated using rotationmat3D to create a spatial transformation before the data is returned to its original position.
Like I never used tformarray before, I carried datapoints that went beyond a certain area after rotation, just filling the data matrix (NxMxP) with zeros around. If someone knows a better way, let us know :)
Code:
%Synthetic dataset, 25x50x25 blob = flow(); %Pad to allow for rotations in space. Bad solution, %something better might be possible to better understanding %of tformarray() blob = padarray(blob,size(blob)); f1 = figure(1);clf; s1=subplot(1,2,1); p = patch(isosurface(blob,1)); set(p, 'FaceColor', 'red', 'EdgeColor', 'none'); daspect([1 1 1]); view([1 1 1]) camlight lighting gouraud %Calculate center blob_center = (size(blob) + 1) / 2; %Translate to origin transformation T1 = [1 0 0 0 0 1 0 0 0 0 1 0 -blob_center 1]; %Rotation around [0 0 1] rot = -pi/3; Rot = rotationmat3D(rot,[0 1 1]); T2 = [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1]; T2(1:3,1:3) = Rot; %Translation back T3 = [1 0 0 0 0 1 0 0 0 0 1 0 blob_center 1]; %Total transform T = T1 * T2 * T3; %See http://blogs.mathworks.com/steve/2006/08/17/spatial-transformations-three-dimensional-rotation/ tform = maketform('affine', T); R = makeresampler('linear', 'fill'); TDIMS_A = [1 2 3]; TDIMS_B = [1 2 3]; TSIZE_B = size(blob); TMAP_B = []; F = 0; blob2 = ... tformarray(blob, tform, R, TDIMS_A, TDIMS_B, TSIZE_B, TMAP_B, F); s2=subplot(1,2,2); p2 = patch(isosurface(blob2,1)); set(p2, 'FaceColor', 'red', 'EdgeColor', 'none'); daspect([1 1 1]); view([1 1 1]) camlight lighting gouraud
The arbitrary visualization below is just a confirmation that the data rotates as expected and builds a closed surface when the data passes the value “1”. With blob2 you should know that you can design using simple sums.
figure(2) subplot(1,2,1);imagesc(sum(blob,3)); subplot(1,2,2);imagesc(sum(blob2,3));
