skimage 中或一般 python 中对象凹度的度量

Metric for concavity of objects in skimage or in general in python

我有一个代码,在某个时候我得到一组二维二进制 numpy 数组来表示主要是椭圆和圆(细胞核)的对象

我需要一个关于边缘粗糙度(锯齿状)程度的指标。病理学文献中有核轮廓指数:它是周长/平方(面积),但在我们的例子中,我们特别需要查看周长如何 "rough"。椭圆和圆形的核轮廓指数是不同的,即使它们都有光滑的边缘。 在我们的例子中,边缘粗糙的圆比边缘光滑的椭圆更重要

我考虑过使用凸包解释here: I think in this case if the metric will be the same of for many minor concavities (which is the significant case for us) and one major concavity (which is not as significant) like in the pictures below.

我也尝试过 openCV,但是我发现很难从数学上理解那里实际发生的事情,它看起来非常像 skimage 凸包,我更愿意坚持使用 skimage

我认为 solidity(即对象中的像素与凸包像素的比率)可能是开始测试的良好指标。它可以通过函数 skimage.measure.regionprops 以直接的方式计算。我使用这种方法获得的结果如下所示:

如果该指标不适合您的应用程序,您可以尝试 紧凑性 圆方差 。看一看here形态特征综合整理

这是我用来生成上面的玩具示例的代码:

import numpy as np
from skimage import io, draw, transform, measure
import matplotlib.pyplot as plt

N = 512
rr, cc = draw.circle(r=N/2, c=N/2, radius=N/3, shape=(N, N))
steps = [4, 16, 32]
smooth = np.zeros(shape=(N, N), dtype=np.uint8)
smooth[rr, cc] = 255

fig, ax = plt.subplots(1, len(steps), figsize=(12, 5))

for i, s in enumerate(steps):
    jagged = transform.resize(smooth[::s, ::s], (N, N))
    jagged[jagged>0] = 1
    props = measure.regionprops(measure.label(jagged))
    ax[i].imshow(img)
    ax[i].set_title('Solidity={}'.format(props[0].solidity))

plt.show(fig)