'Flask: Efficient on-demand delivery of selected 2D slices from 3D volumes

How can I efficiently store hundreds of 3D volumes and serve selected instance slices on-demand with Flask?

I am currently solving the issue by saving each subvolume as an image collection of its slices. Here each folder is a subvolume (cropped out object) - the image names correspond to the slices of the volume from which the subvolume was cropped.

├── 1/
│   ├── 1.png
|   ...
│   ├── 10.png
│   └── 11.png
├── 2/
│   ├── 0.png
|   ...
│   ├── 4.png
│   └── 5.png
├── 3/
│   ├── 3.png
|   ...
│   ├── 11.png
│   └── 12.png
...
|
└── 176/
    ├── 34.png
    ...
    ├── 43.png
    └── 44.png

Instead, I would like to store each subvolume, e.g., as a single tiff file and only serve the required slices.

├── 1/
│   └── image.tif
├── 2/
│   └── image.tif
├── 3/
│   └── image.tif
...
|
└── 176/
    └── image.tif

However, according to this Stackoverflow answer the only mainstream browser that supports tiff is Safari.

Is there a way where I don't have to save every single image? Especially considering that I will only need to depict the most centric slice of a subvolume in most cases and only in a few cases make the whole subvolume browsable.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source