Trying to find a way to delete level[1,...,n] from pyramidal slides and keep only level[0]

I am trying to study difference in file size for WSI images (.tiff, .svs) between pyramidal and single level[0], and estimate time / cpu resources need.
Those will be used as cold-storage / archival.

The main thinking is : obtain pyramidal file -> reduce size to only highest resolution without additional compression -> cold-storage -> reconstruct pyramids if needed.

I tried to read the slides using openslides, however, i was getting MemoryError for level[0]:
img = slide.read_slide((0,0), 0, slide.level_dimensions[0])
the ideas was to read the slides, and save them using the same compression of the original slides, but this is computationally heavy.

So, instead of reading and then saving, could we delete all levels above level[0]?
I could not figure a way to convert it to numpy array for easier manipulation.

I tried qupath: file -> export image, it was not fast, but could not figure a way to run it headless to batch process. the saved file was a single level ome.tif, about 1.5 GB, and was able to view it in qupath. This solution also applied additional compression that I do not want.

I also tried bfconvert, but it took a lot of time and CPU resources.

Thanks,

You should be able to save a single resolution using the bfconvert tool and series option, though removing the lower level resolutions is likely not going to provide significant improvement.

1 Like

I understand bfconvert (and QuPath) will both involve recompressing the image… which may be bigger or smaller, but certainly won’t be better. It may also cause a loss in specific metadata.

To simply remove layers you’d need to go to a much lower level, perhaps with libtiff (or possibly libvips, but I’m not sure).

However, I agree with @dgault and suspect you won’t see a huge improvement in terms of image size by removing the pyramidal layers (since they are both smaller and compressed anyway)… which won’t be worth it compared to the awkwardness involved in reconstructing them if you ever do need them in the future.

1 Like