我正在尝试分析灰度TIFF堆栈,其中给定的帧看起来像这样。我对其进行过滤(使用高斯模糊),然后对其进行二值化(使用Otsu的阈值方法)。
MATLAB代码,效果很好:
image_conncomp = bwconncomp(image_binary); # entire stack is held in image_binary
for i=1:image_conncomp.NumObjects
object_size = length(image_conncomp.PixelIdxList{i});
end
示例图像中的每个白点都被拾取,其体积(以像素为单位)非常精确地由给出object_size。
Python代码:
from skimage import measure
labels = measure.label(image_binary, background=1) # same image_binary as above
propsa = measure.regionprops(labels)
for label in propsa:
object_size = len(label.coords)
Python代码似乎运行得很好...除了大多数检测到的对象将具有object_size1-200,然后一对夫妇将具有几千个像素的大小。
这些功能有何不同之处?我很乐意尝试使用Python中的另一种方法来计算对象的大小,但是我很难找到另一种方法。如果我可以找到Matlabbwconncomp函数的不错替代品,那么拥有此代码的Python版本将是很棒的。
相关分类