girder / large_image

Python modules to work with large multiresolution images.
http://girder.github.io/large_image/
Apache License 2.0
190 stars 41 forks source link

Tifffile _biggestSeries() bug for large images #1547

Open Dany546 opened 2 months ago

Dany546 commented 2 months ago

The _biggestSeries() method used to read tifffile sources rely on np.prod(shape) to find the biggest series in the file (macro image > image). This leads to an overflow for big images and the macro image is wrongly selected as the main content of the file. Simple fix is done with np.sqrt(), though a better solution could be found.

manthey commented 2 months ago

Do you have an example image where it fails? If it can't be shared, can the output of tifftools dump <image> be shared?

I don't understand why the sqrt of the shape product would be desirable. The intent is that the main series would be the series with the most total pixels. If it is overflowing do to data types, a better choice might be to samples = np.prod(float(x) for x in s.shape) to cast the values to float values before multiplication.