我有 1000 帧的 tiff 图像堆栈,我试图在其中跟踪在布朗运动中扩散的粒子。所以我使用 trackpy 进行粒子跟踪:导入 tiff 堆栈,定位特征(粒子),然后绘制它们的轨迹。我正在使用以下代码(来自 trackpy 演练页面):
import pims
import trackpy as tp
frames = pims.open("image.tif")
f = tp.locate(frames[0], 9, invert=False)
但是最后一行(tp.locate)给出了回溯:
AttributeError Traceback (most recent call last)
<ipython-input-78-0fbce96715a7> in <module>
----> 1 f = tp.locate(frames[0], 9, invert=False)
~\anaconda3\lib\site-packages\slicerator\__init__.py in __getitem__(self, i)
186 indices, new_length = key_to_indices(i, len(self))
187 if new_length is None:
--> 188 return self._get(indices)
189 else:
190 return cls(self, indices, new_length, propagate_attrs)
~\anaconda3\lib\site-packages\pims\base_frames.py in __getitem__(self, key)
96 """__getitem__ is handled by Slicerator. In all pims readers, the data
97 returning function is get_frame."""
---> 98 return self.get_frame(key)
99
100 def __iter__(self):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in get_frame(self, j)
119 t = self._tiff[j]
120 data = t.asarray()
--> 121 return Frame(data, frame_no=j, metadata=self._read_metadata(t))
122
123 def _read_metadata(self, tiff):
~\anaconda3\lib\site-packages\pims\tiff_stack.py in _read_metadata(self, tiff)
124 """Read metadata for current frame and return as dict"""
125 # tags are only stored as a TiffTags object on the parent TiffPage now
--> 126 tags = tiff.keyframe.tags
127 md = {}
128 for name in ('ImageDescription', 'image_description'):
~\anaconda3\lib\site-packages\skimage\external\tifffile\tifffile.py in __getattr__(self, name)
2752 setattr(self, name, value)
2753 return value
-> 2754 raise AttributeError(name)
2755
2756 def __str__(self):
AttributeError: keyframe
我哪里错了?我也尝试过使用
imageio.imread("image.tif")
导入图像然后使用
f=tp.locate(frames[0], 9, invert=False)
来定位粒子。但是它的输出应该是 x 和 y 坐标的数据,就像这样
而我得到的只是x轴: