www.gusucode.com > images 案例代码 matlab源码程序 > images/Translate3DMRIDatasetExample.m

    %% Translate 3-D MRI Dataset
% 
%%
% Load MRI data into the workspace and display it.

% Copyright 2015 The MathWorks, Inc.

s = load('mri');
mriVolume = squeeze(s.D);
sizeIn = size(mriVolume);
hFigOriginal = figure;
hAxOriginal  = axes;
slice(double(mriVolume),sizeIn(2)/2,sizeIn(1)/2,sizeIn(3)/2);
grid on, shading interp, colormap gray
%%
% Apply a translation in the X,Y direction.
mriVolumeTranslated = imtranslate(mriVolume,[40,30,0],'OutputView','full');
%% 
% Visualize axial slice plane taken through center of volume.
sliceIndex = round(sizeIn(3)/2);
axialSliceOriginal   = mriVolume(:,:,sliceIndex);
axialSliceTranslated = mriVolumeTranslated(:,:,sliceIndex);
imshowpair(axialSliceOriginal,axialSliceTranslated,'montage');
set(gca,'Visible','on')