Transform a 3d volume by using an affine transformation matrix
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 (2025). 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
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
- Image Processing and Computer Vision > Image Processing Toolbox > Geometric Transformation and Image Registration >
- Image Processing and Computer Vision > Image Processing Toolbox > 3-D Volumetric Image Processing >
Etiquetas
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0.0 |