Skip to content
Snippets Groups Projects
Commit 2c2c225c authored by Nicola Vigano's avatar Nicola Vigano
Browse files

gtRotateVolume: performance optimization thanks to affine3d

parent b8f8f092
No related branches found
No related tags found
No related merge requests found
......@@ -13,25 +13,19 @@ function vol = gtRotateVolume(vol, rot_tensor, rot_axis)
T1(4, 1:3) = -vol_center;
T2 = eye(4);
T2(1:3, 1:3) = rot_tensor;
T2(1:3, 1:3) = rot_tensor';
T3 = eye(4);
T3(4, 1:3) = +vol_center;
T = T1 * T2 * T3;
tform = maketform('affine', T);
% new_center = tformfwd(vol_center, tform)
tform = affine3d(T);
vol = imwarp(vol, tform, 'OutputView', imref3d(size(vol)));
R = makeresampler('linear', 'fill');
vol = tformarray(vol, tform, R, [1 2 3], [1 2 3], vol_size, [], 0);
% Old version. NOTE that rot_tensor should be un-transposed if this
% version was to be used.
% tform = maketform('affine', T);
% R = makeresampler('linear', 'fill');
% vol = tformarray(vol, tform, R, [1 2 3], [1 2 3], vol_size, [], 0);
end
% function vol = gtRotateVolume(vol, angle, method)
% if (~exist('method', 'var'))
% method = 'nearest';
% end
% for ii_s = 1:size(vol, 3)
% vol(:, :, ii_s) = imrotate(vol(:, :, ii_s), angle, method, 'crop');
% end
% end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment