Skip to main content

create_sphere_mask

Function create_sphere_mask 

Source
pub fn create_sphere_mask(
    nx: usize,
    ny: usize,
    nz: usize,
    center_x: f64,
    center_y: f64,
    center_z: f64,
    radius: f64,
) -> Vec<u8> 
Expand description

Create a binary sphere mask on a 3D volume

Generates a mask where voxels within the specified radius of the center are set to 1, and all others are 0. Uses Fortran (column-major) ordering to match NIfTI convention: index = x + ynx + znx*ny.

§Arguments

  • nx, ny, nz - Volume dimensions
  • center_x, center_y, center_z - Sphere center in voxel coordinates
  • radius - Sphere radius in voxels

§Returns

Flattened binary mask of length nxnynz