Code covered by the BSD License  

Highlights from
Transform a 3d volume by using an affine transformation matrix

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.9 KB File ID: #25596

Transform a 3d volume by using an affine transformation matrix

by Martijn Steenwijk

 

17 Oct 2009

This function transforms a volume by using an affine transformation matrix.

| Watch this File

File Information
Description

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')

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
transformation Martijn Steenwijk 19 Oct 2009 10:14:44
geometry Martijn Steenwijk 19 Oct 2009 10:14:44
affine Martijn Steenwijk 19 Oct 2009 10:14:44
interpolation Martijn Steenwijk 19 Oct 2009 10:14:44
3d Martijn Steenwijk 19 Oct 2009 10:14:44
volume Martijn Steenwijk 19 Oct 2009 10:14:44
3d Norbert 19 Oct 2011 10:42:06

Contact us at files@mathworks.com