Export surface textures of ROI as images


my dataset is a stack of TIFF images which I imported into 3D slicer. I then enabled Volume Rendering of this dataset and toggled “Shade” off because I just want to browse through the dataset in the 3D viewport; I don’t need a volume rendering.

(Let me know if there are better ways to achieve the same).

Because the dataset is skewed and has excessive white parts, I needed to adjust the ROI into a parallelogram. Now I am able to browse through the dataset from all 6 sides by shrinking/extending the ROI.

I would now like to export the current surface texture of the ROI. Basically, 6 images for all 6 planes of the current ROI. With this 6 images I can visualize a box of my current view in another 3D program.

To be clear, the important part is that thanks to 3D Slicer, I am able to browse through the dataset “at an angle.” If I onle browsed through the dataset in normal X, Y, Z, there is lots of blank area: Screenshot-2022-05-05-114200 — ImgBB

The crucial part for me is now getting this adjusted box into another 3D program. Either by exporting 6 images and then creating the parallelogram by hand or (if 3D Slicer supports that) exporting the current ROI as a mesh with correct textures attached to it.

Have you tried to use slice views? That’s how usually we explore 3D volumes. Click on the eye icon in the slice view controller to show the slice in the 3D view.

You can rotate all the slices at arbitrary angles by enabling slice intersections and using Ctrl+Alt+Left-click-and-drag, or enabling interactive slice intersections:


If you want to export a rectangular prism then you can simply crop your volume to that using a ROI (using Crop volume module) and then use the first/last slice of the volume along each axis.

If you want to extract arbitrarily oriented slices then you probably need to write a short Python code snippet.

You can position a slice view then get the image from that get the slice views as images, as it is shown here.

Alternatively, you can create a polygonal mesh that stores voxel values as point data. You can create the polydata using vtkCubeSource, subdivide it to the desired resolution, add it to a model node, and set the point data using Probe volume with model module.

Hello Andras,

thanks for your reply and the hint about rotating slices in arbitrary angles. However, sometimes I do prefer to view the data as this “box” of planes like in my first screenshot. This way one can look “behind” the corner of the planes.

What I also like from the “volume rendering” (showing a box of the dataset) is that I do not have to worry about the dimension of the plane and therefore, the texture. Consider this screenshot where I rotated the problematic plane in the slice view:

Even if I am able to extract the current texture to an image, I would need to make up for the missing part in the bottom which might get a little bit complicated. Given that with the volume rendering, Slicer already constructs a suitable parallelogram mesh and interpolates the textures beautifully, is there no way to access this data in some way or another?

Unfortunately I’m not familiar with VTK to know its internals, but if there is some kind of API to this objects I would be able to work my way to it in Python.

As far as I understand, the script that you mention (“Extract randomly oriented slabs of given shape from a volume”) would give me the image data of each slice as if I was scrolling through it (at an angle). I would prefer to have the “parallelogram box textures,” but in any case I tried it out and so far only got a black image. Is this the correct usage?

volume = getNode('001') # my dataset
slice = randomSlices(
    1, # I only want the current slice
    [1200, 800] # dimensions of the image that I later want to save