image_to_voxel (and reverse)


The image_to_voxel function converts image data into a voxel representation suitable for 3D analysis, while the voxel_to_image function reverses this process, extracting 2D image slices from a 3D voxel dataset.


Some analyses may require the extraction of voxel data contained within an hdf file and conversion to an internal python type. One extension of this application is the direct conversion of a voxel array into an image stack, which may be utilized for subsequent downscaling and meshing activities.

With recon3d installed in a virtual environment called .venv, the image_to_voxel and voxel_to_image functionality is provided as a command line interface. Providing a HDF file with voxel dataset of interest, image data can be extracted to a separate folder (and vice versa).

Contents of image_to_voxel.yml:

cli_entry_points: - image_to_voxel semantic_images_dir: tests/data/letter_f semantic_images_type: .tif semantic_imagestack_name: letter_f_test voxel_size: dx: 1.0 dy: 1.0 dz: 1.0 origin: x0: 0.0 # (float), real space units of the origin in x y0: 0.0 # (float), real space units of the origin in y z0: 0.0 # (float), real space units of the origin in z pixel_units: "voxel" out_dir: recon3d/data/temp h5_filename: letter_f_test

Contents of voxel_to_image.yml:

cli_entry_points: - voxel_to_image voxel_data_path: tests/data/machined_cylinder.h5 #input hdf file voxel_data_location: VoxelData/machined_cylinder #internal dataset path in hdf file image_parent_dir: tests/data/output/ # folder to contain folder of images image_slice_normal: Z image_output_type: .tif

image_to_voxel image_to_voxel.yml produces:

Success: database created from file: image_to_voxel.yml key, value, type ---, -----, ---- cli_entry_points, ['image_to_voxel'], <class 'list'> semantic_images_dir, tests/data/letter_f, <class 'str'> semantic_images_type, .tif, <class 'str'> semantic_imagestack_name, letter_f_test, <class 'str'> voxel_size, {'dx': 1.0, 'dy': 1.0, 'dz': 1.0}, <class 'dict'> origin, {'x0': 0.0, 'y0': 0.0, 'z0': 0.0}, <class 'dict'> pixel_units, voxel, <class 'str'> out_dir, recon3d/data/temp, <class 'str'> h5_filename, letter_f_test, <class 'str'> Processing specification file: image_to_voxel.yml Success: database created from file: image_to_voxel.yml key, value, type ---, -----, ---- cli_entry_points, ['image_to_voxel'], <class 'list'> semantic_images_dir, tests/data/letter_f, <class 'str'> semantic_images_type, .tif, <class 'str'> semantic_imagestack_name, letter_f_test, <class 'str'> voxel_size, {'dx': 1.0, 'dy': 1.0, 'dz': 1.0}, <class 'dict'> origin, {'x0': 0.0, 'y0': 0.0, 'z0': 0.0}, <class 'dict'> pixel_units, voxel, <class 'str'> out_dir, recon3d/data/temp, <class 'str'> h5_filename, letter_f_test, <class 'str'>

voxel_to_image voxel_to_image.yml produces:

Success: database created from file: voxel_to_image.yml key, value, type ---, -----, ---- cli_entry_points, ['voxel_to_image'], <class 'list'> voxel_data_path, tests/data/machined_cylinder.h5, <class 'str'> voxel_data_location, VoxelData/machined_cylinder, <class 'str'> image_parent_dir, tests/data/output/, <class 'str'> image_slice_normal, Z, <class 'str'> image_output_type, .tif, <class 'str'>