VMresize

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - VM/Voxels
Introduced first in SolidGeometry 3.4, Creation date: 2017-02-17, Last change: 2025-09-14

resizes a voxel image model

Description

[V,vs]=[V,vs,vs]); returns voxels of same size 1 mm x 1mm x 1mm
[V,vs]=[V,vs); returns voxels of same size 1 mm x 1mm x 1mm


See Also: VMreaddicomdir , VMmontage , VMplot , VMintensityscale

Example Illustration

 missing image of VMresize(VM,dm,vs)

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

Output Results

Algorithm Steps

  1. Initialize default values for dm and vs. If additional arguments are provided, update dm and vs accordingly.
  2. Determine the size of the input voxel model, VM.
  3. 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.
  4. Initialize a new voxel model, NVM, with NaN values and dimensions [ns(1) ns(2) sv(3)].
  5. Calculate the scaling factor dm and adjust vs accordingly.
  6. Print a message indicating the resizing operation, including original and new dimensions and voxel sizes.
  7. 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.
  8. Initialize the final resized voxel model, FVM, with NaN values and dimensions [ns(1) ns(2) ns(3)].
  9. 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.
  10. 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