Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

imrotate3

Rotate 3-D volumetric grayscale image

Syntax

B = imrotate3(V,angle,W)
B = imrotate3(V,angle,W,method)
B = imrotate3(V,angle,W,method,bbox)
B = imrotate3(___,Name,Value)

Description

example

B = imrotate3(V,angle,W) rotates the 3-D volumetric grayscale image V (referred to as a volume) by angle degrees counterclockwise around an axis passing through the origin [0 0 0]. W is a 1-by-3 vector which specifies the direction of the axis of rotation in 3-D space. By default, imrotate3 uses nearest neighbor interpolation and sets the values of voxels in B that are outside the boundaries of the rotated volume to 0.

B = imrotate3(V,angle,W,method) rotates the volume V, where method specifies the interpolation method.

B = imrotate3(V,angle,W,method,bbox) rotates the volume V, where bbox specifies the size of the output volume. If you specify 'cropped', imrotate3 makes the output volume the same size as the input volume. If you specify 'loose', imrotate3 makes the output volume large enough to include the entirety of the rotated volume.

B = imrotate3(___,Name,Value) specifies additional parameters that control various aspects of the geometric transformation. Parameter names can be abbreviated.

Examples

collapse all

Load a 3-D volumetric grayscale image 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

Rotate the volume 90 degress around the Z axis.

B = imrotate3(mriVolume,90,[0 0 1],'nearest','loose','FillValues',0);

Display the rotated output. You can also display the result in the Volume Viewer app.

figure
slice(double(B),sizeIn(2)/2,sizeIn(1)/2,sizeIn(3)/2);
grid on, shading interp, colormap gray

Input Arguments

collapse all

Volume to be rotated, specified as a 3-D volumetric grayscale image.

imrotate3 assumes that the input volume V is centered on the origin [0 0 0]. If your volume is not centered on the origin, use imtranslate to translate the volume to [0 0 0] before using imrotate3. You can translate the output volume B back to the original position with the opposite translation vector.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Rotation angle in degrees, specified as numeric scalar. To rotate the volume clockwise, specify a negative value for angle. imrotate3 makes the output volume B large enough to contain the entire rotated 3-D volume.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Direction of the axis of rotation in 3-D space in Cartesian coordinates, specified as a 1-by-3 vector of numeric values.

If you want to specify the direction of the axis of rotation in spherical coordinates, use sph2cart to convert values to Cartesian coordinates before passing it to imrotate3.

Example: [ 0 0 1] rotate the volume around the Z axis

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Interpolation method, specified as one of the following character vectors.

MethodDescription
'cubic'

Tricubic interpolation

Note

Tricubic interpolation can produce pixel values outside the original range.

'linear'

Trilinear interpolation

'nearest'

Nearest neighbor interpolation

Data Types: char

Size of the output volume, specified as either of the following character vectors.

MethodDescription
'crop'

Make the output volume the same size as the input volume, cropping the rotated volume to fit.

'loose'

Make the output volume large enough to contain the entire rotated volume. Usually, the rotated volume is larger than the input volume.

Data Types: char

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: B = imrotate3(V,angle,W,'nearest','loose','FillValues',5);

collapse all

Value used to fill voxels in the output volume that are outside the limits of the rotated volume, specified as the comma-separated pair consisting of 'FillValues' and a numeric scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Rotated volume, returned as a numeric array the same class as the input volume.

Introduced in R2017a

Was this topic helpful?