import tifffile
f = 'some.tif'
img = tifffile.imread(f)
Дает ошибку:
~/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py in imread(files, **kwargs)
443 if isinstance(files, basestring) or hasattr(files, 'seek'):
444 with TiffFile(files, **kwargs_file) as tif:
--> 445 return tif.asarray(**kwargs)
446 else:
447 with TiffSequence(files, **kwargs_seq) as imseq:
~/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py in asarray(self, key, series, out, validate, maxworkers)
1900 typecode, product(series.shape), out=out, native=True)
1901 elif len(pages) == 1:
-> 1902 result = pages[0].asarray(out=out, validate=validate)
1903 else:
1904 result = stack_pages(pages, out=out, maxworkers=maxworkers)
~/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py in asarray(self, out, squeeze, lock, reopen, maxsize, validate)
3376 if self.compression not in TIFF.DECOMPESSORS:
3377 raise ValueError(
-> 3378 'cannot decompress %s' % self.compression.name)
3379 if 'SampleFormat' in tags:
3380 tag = tags['SampleFormat']
ValueError: cannot decompress JPEG
Примечание. Похоже, что я получаю ошибку только для изображений большего размера.Кроме того, версия tifffile имеет вид 0.15.1.
ОБНОВЛЕНИЕ - После использования pip для установки imagecodes>=2018.10.22
я получаю следующую ошибку:
img=tifffile.imread(f)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/somename/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py", line 581, in imread
return tif.asarray(**kwargs)
File "/home/somename/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py", line 2042, in asarray
maxworkers=maxworkers)
File "/home/somename/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py", line 3813, in asarray
strip = decompress(strip)
File "/home/somename/.conda/envs/cmap_py3/lib/python3.6/site-packages/tifffile/tifffile.py", line 3700, in decompress
out)
File "/home/somename/.conda/envs/cmap_py3/lib/python3.6/site-packages/imagecodecs/imagecodecs.py", line 678, in jpeg_decode
'JPEG tables, colorspace, and outcolorspace otions not supported')
NotImplementedError: JPEG tables, colorspace, and outcolorspace otions not supported
На компьютере с Linux накакой tifffile не может открыть большой tif в ~/.conda/envs/cmap_py3/lib/python3.6/site-packages/imagecodecs
Я вижу
__init__.py
licencses
__pycache__
imagecodecs.py
На компьютере с Windows, на котором tifffile может открыть большой tif в ls C:\\Anaconda2\\envs\\tensorflow35\\lib\\site-packages\\imagecodecs\\
Вижу
__init__.py
licenses
__pycache__
imagecodecs.py
_imagecodecs.cp35-win_amd64.pyd
_jpeg12.cp35-win_amd64.pyd