TIFFStack icon indicating copy to clipboard operation
TIFFStack copied to clipboard

Conversion to other types

Open osoyer opened this issue 5 years ago • 1 comments

I'm trying to perform some downstream analysis on tiff stacks and would like to use other functions in MATLAB image processing toolbox. Many of those require specific data types. Hence, is it possible to convert a TIFFStack object to type double, uint8, etc.? I can do this for individual slices as follow, but would be better to do on the full stack.

example on a slice; tsStack = TIFFStack(filename1); im=uint8(tsStack(:, :, 100)/256)

osoyer avatar Jul 23 '20 12:07 osoyer

Hi @osoyer

This is difficult, because it requires touching the entire stack. If you want the stack as a true Matlab double tensor, then you need to load the entire stack into memory — that's precisely what TIFFStack is trying to avoid.

Doing the analysis slice-wise is the most memory-efficient way. You could also do it chunk-wise, by looping over 3D chunks of the stack:

im = uint8(tsStack(:, :, 100:200)/256)

DylanMuir avatar Jul 27 '20 13:07 DylanMuir