Transform a 3d volume by using an affine transformation matrix

This function transforms a volume by using an affine transformation matrix.
1,9K descargas
Actualizado 17 oct 2009

Ver licencia

This function transforms volume 'old_im' by means of affine transformation matrix 'M'. The output volume can be sub- and oversampled. The function makes use of interp3, so 'nearest', 'linear', 'spline', 'cubic' and fast ( * ) interpolation is possible.

% Usage example - simple translation
load mri.mat
D = squeeze(D(:,:,1,:));
% Create affine transformation matrix, simply shift (x,y) = (50,25)
M = [1 0 0 50; 0 1 0 25; 0 0 1 0; 0 0 0 1];
% Invert M, since the interpolation is backward. Meanwhile subsample the output volume x-direction by a factor of two.
D_new = affine3d(D,inv(M),1:2:128,1:128,1:27);
figure
subplot(1,2,1)
imagesc(D(:,:,10))
title('Original volume')
subplot(1,2,2)
imagesc(D_new(:,:,10))
title('Shifted volume')

Citar como

Martijn Steenwijk (2024). Transform a 3d volume by using an affine transformation matrix (https://www.mathworks.com/matlabcentral/fileexchange/25596-transform-a-3d-volume-by-using-an-affine-transformation-matrix), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2008b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0