How to resolve TiffFileError: Not a Tiff File and Byte Problem with KeyError: b'\x89P'
How to resolve TiffFileError: Not a Tiff File and Byte Problem with KeyError: b'\x89P'
我正在建立一个计算机视觉项目来检测和处理 GFP 蛋白。我不断收到关于我的文件不是 Tiff 图像和字节错误的错误。我不太明白他们的意思,也没有在网上找到任何相关信息。
我已经确定文件路径是正确的,并尝试将文件更改为Tiff格式。现在在 Finder 上,它说它是一个 TIFF 图像,但仍然给出错误。
import tifffile
from colicoords import Data, Cell, CellPlot
import matplotlib.pyplot as plt
binary_img = tifffile.imread('organoid_images/gfp/cells1.tif')
data = Data()
data.add_data(binary_img, 'binary')
cell = Cell(data)
cell.optimize()
cp = CellPlot(cell)
plt.figure()
cp.imshow('flu_514', cmap='viridis', interpolation='nearest')
cp.plot_outline()
cp.plot_midline()
plt.show()
错误信息:
Traceback (most recent call last):
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 2236, in __init__
byteorder = {b'II': '<', b'MM': '>'}[header[:2]]
KeyError: b'\x89P'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gfp.py", line 6, in <module>
binary_img = tifffile.imread('organoid_images/gfp/cells1.tif')
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 715, in imread
with TiffFile(files, **kwargs_file) as tif:
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 2238, in __init__
raise TiffFileError('not a TIFF file')
tifffile.tifffile.TiffFileError: not a TIFF file
我正在建立一个计算机视觉项目来检测和处理 GFP 蛋白。我不断收到关于我的文件不是 Tiff 图像和字节错误的错误。我不太明白他们的意思,也没有在网上找到任何相关信息。
我已经确定文件路径是正确的,并尝试将文件更改为Tiff格式。现在在 Finder 上,它说它是一个 TIFF 图像,但仍然给出错误。
import tifffile
from colicoords import Data, Cell, CellPlot
import matplotlib.pyplot as plt
binary_img = tifffile.imread('organoid_images/gfp/cells1.tif')
data = Data()
data.add_data(binary_img, 'binary')
cell = Cell(data)
cell.optimize()
cp = CellPlot(cell)
plt.figure()
cp.imshow('flu_514', cmap='viridis', interpolation='nearest')
cp.plot_outline()
cp.plot_midline()
plt.show()
错误信息:
Traceback (most recent call last):
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 2236, in __init__
byteorder = {b'II': '<', b'MM': '>'}[header[:2]]
KeyError: b'\x89P'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "gfp.py", line 6, in <module>
binary_img = tifffile.imread('organoid_images/gfp/cells1.tif')
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 715, in imread
with TiffFile(files, **kwargs_file) as tif:
File "/Users/CosmoCrash/opencvblobs/lib/python3.7/site-packages/tifffile/tifffile.py", line 2238, in __init__
raise TiffFileError('not a TIFF file')
tifffile.tifffile.TiffFileError: not a TIFF file