Voxelization with image data

Hello, we are using the VTK JS library and we need to get voxel representations of images stored in vti files. Something like what is done here but with the vtk cpp and python:
https://kitware.github.io/vtk-examples/site/Cxx/Medical/GenerateCubesFromLabels/
https://kitware.github.io/vtk-examples/site/Python/Medical/GenerateCubesFromLabels/

Is something like that possible?

Thank you.