This function rotates a 3D image based on angle and axis to rotate a round to.
interpolation methods include: nearest neighbor and linear interpolation.
The rest of the image that is out of bound is marked with nan.
the output image will be padded with nan or can be cropped depend on the parameters.
Full Syntax example:
rotatedImg = rotImg3( img, teta, ax, method )
img is the 3D image, teta is the angle in radians, ax is the
axis of rotation for exmple [1 0 0], method can be nearest for nearest
neighbor of linear interpolation. pad =(true|false) is wheter or not to pad the object
with nan or to crop the image after the rotation and leave it same size.
example use for rotating a cylinder:
nS = 30; % cylynder size
cylBlock = repmat([1 zeros(1,nS-2) 1], nS,1);
cyl = zeros(nS,nS,nS);
cyl(:,:,1) = ones(nS,nS);
cyl(:,:,end) = ones(nS,nS);
cyl(:,:,2:end-1) = repmat( cylBlock, [1 1 nS-2]);
rotatedCyl = rotImg3(double(cyl), 1*pi/4 , [0 1 0 ]);
isosurface(rotatedCyl);
Cite As
Alon Lanyado (2024). 3D rotation of 3D image (https://www.mathworks.com/matlabcentral/fileexchange/44990-3d-rotation-of-3d-image), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Image Processing and Computer Vision > Image Processing Toolbox > Geometric Transformation and Image Registration >
- MATLAB > Graphics > Formatting and Annotation > 3-D Scene Control >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.