Syntax
[FVM,vs]=VMresize(VM,[dm,vs])
Input Parameter
VM : | | voxel mode; [X x Y x Z] |
dm : | | dimension either scale [0.5 0.5 0.5] or vs |
vs : | | optional voxel size for rescaling; default is dm |
Output Parameter
FVM : | | New Voxel Model with new dimensions |
vs : | | Voxel size after resizing |
Examples
[V,vs]=VMreaddicomdir('AIM_DICOMFILES');
VMresize(V,vs,vs); % voxel size = 1 mm
VMresize(V,vs/2,vs); % voxel size = 2 mm
Copyright 2017-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, VMresize, is designed to resize a voxel image model. It takes a 3D matrix representing the voxel model and resizes it according to specified dimensions or voxel sizes.
Input Parameters
- VM: A 3D matrix representing the voxel model with dimensions [X x Y x Z].
- dm: A vector specifying the scale or new dimensions. It can be a scale factor like [0.5 0.5 0.5] or a direct specification of voxel size.
- vs: An optional parameter specifying the voxel size for rescaling. If not provided, it defaults to the value of dm.
Output Results
- FVM: The resized voxel model with new dimensions.
- vs: The voxel size after resizing.
Algorithm Steps
- Initialize default values for dm and vs. If additional arguments are provided, update dm and vs accordingly.
- Determine the size of the input voxel model, VM.
- Check if dm specifies absolute dimensions (all elements greater than 1). If so, set ns to dm. Otherwise, calculate ns by scaling the original size sv by dm.
- Initialize a new voxel model, NVM, with NaN values and dimensions [ns(1) ns(2) sv(3)].
- Calculate the scaling factor dm and adjust vs accordingly.
- Print a message indicating the resizing operation, including original and new dimensions and voxel sizes.
- For each slice in the Z dimension of VM, resize the 2D slice to the new dimensions [ns(1) ns(2)] and store it in NVM.
- Initialize the final resized voxel model, FVM, with NaN values and dimensions [ns(1) ns(2) ns(3)].
- For each slice in the X dimension of NVM, resize the 2D slice to the new dimensions [ns(2) ns(3)] and store it in FVM.
- If no output arguments are specified, plot the resized voxel model using the VMplot function.
Algorithm explaination created using ChatGPT on 2025-08-19 07:48. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21