You are here : matlabImage Processingimtranslate

imtranslate() - Image Processing

B = imtranslate(A,translation) translates
image A according to the translation specified
by the translation vector translation. The function
returns B, the translated image. If A has
more than two dimensions and translation is a
two-element vector, imtranslate applies a 2-D translation
to A, one plane at a time.[B,RB] =
imtranslate(A,RA,translation) translates
the spatially referenced image A with its associated
spatial referencing object RA. The translation
vector, translation, is in the world coordinate
system. The function returns the translated spatially referenced image B,
with its associated spatially referencing object, RB.___ = imtranslate(___,method) specifies
the interpolation method to use.example___ = imtranslate(___,Name,Value) translates
the input image using name-value pairs to control various aspects
of the translation.Code Generation support:
Yes.MATLAB Function Block support:
Yes.


Syntax

B = imtranslate(A,translation) example[B,RB] =
imtranslate(A,RA,translation)___ = imtranslate(___,method)___ = imtranslate(___,Name,Value) example


Example

Translate 2-D ImageOpen This Example
Read image into the workspace.I = imread('pout.tif');
Translate the image.J = imtranslate(I,[25.3, -10.1],'FillValues',255);
Display the original image and the translated image.figure
imshow(I);
title('Original Image');
set(gca,'Visible','on');
figure
imshow(J);
title('Translated Image');
set(gca,'Visible','on');


Translate 2-D Image and View Entire Translated ImageOpen This Example
Read image into the workspace.I = imread('pout.tif');
Translate the image. Use the OutputView parameter to specify that you want the entire translated image to be visible.J = imtranslate(I,[25.3, -10.1],'FillValues',255,'OutputView','full');
Display the original image and the translated image.figure
imshow(I);
title('Original Image');
set(gca,'Visible','on');
figure
imshow(J);
title('Full Translated Image');
set(gca,'Visible','on');


Translate 3-D MRI DatasetOpen This Example
Load MRI data into the workspace and display it.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')

Related ExamplesTranslate an Image


Output / Return Value


Limitations


Alternatives / See Also


Reference