문제

I'm trying to open a tiff stack using gdal in python. It is a single file, within which are mutliple tiff files. When I open it in ImageJ, I can scroll through the stack. But doing "gdal.Open(file).ReadAsArray() only loads the first tiff file. Is there a way I can load the whole stack?

도움이 되었습니까?

해결책

Iterate over GetSubDatasets and (in case all TIFF pages have the same dimensions) create a single numpy array:

import numpy, gdal, gdalconst
dataset = gdal.Open("multipage.tiff", gdalconst.GA_ReadOnly)
data = numpy.array([gdal.Open(name, gdalconst.GA_ReadOnly).ReadAsArray()
                    for name, descr in dataset.GetSubDatasets()])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top