python - 使用 SciPy 进行径向采样

标签 python image-processing numpy scipy

我正在使用 scipy.ndimage 进行图像处理。给定一个环形物体,我想在其圆周上生成一个“轮廓”。轮廓可能类似于环周围不同点的厚度测量值,或者沿着环“厚度”的平均信号。

在我看来,如果我能首先获得一个好的标签图像,我可以使用ndimage.mean

如果我的戒指看起来像这样,

 A = array([[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
            [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
            [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
            [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
            [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
            [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
            [0, 0, 1, 1, 0, 0, 1, 1, 1, 0],
            [0, 0, 1, 1, 0, 0, 1, 1, 0, 0],
            [0, 0, 1, 1, 1, 1, 1, 1, 0, 0],
            [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]])

我可以使用 numpy.mean( A, labels ) 获取“均值概况”,其中 labels 是。

array([[0,  0,  0,  0,  2,  0,  0,  0,  0,  0],
       [0,  0,  1,  1,  2,  3,  4,  4,  0,  0],
       [0,  0,  1,  1,  2,  3,  4,  5,  0,  0],
       [0,  0, 16, 16,  0,  0,  5,  5,  0,  0],
       [0,  0, 15, 15,  0,  0,  6,  6,  0,  0],
       [0,  0, 14, 14,  0,  0,  7,  7,  0,  0],
       [0,  0, 13, 13,  0,  0,  8,  8,  8,  0],
       [0,  0, 13, 12,  0,  0,  9,  9,  0,  0],
       [0,  0, 12, 12, 11, 10,  9,  9,  0,  0],
       [0,  0,  0,  0, 11,  0,  0,  0,  0,  0]])

我敢打赌,有些插值的东西会被忽视,但这是我自己能想出的全部。

有没有办法生成我建议的标签图像?有更好的方法来生成我的个人资料吗?

最佳答案

圆(或球体)上的标准概率分布是 Von-Mises Fisher 分布。

Scipy 支持此发行版:http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.vonmises.html

因此,您应该能够使用拟合函数来查找数据的最大似然参数。

关于python - 使用 SciPy 进行径向采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12534029/

相关文章:

python - ModelForm 显示外键表值,而不是选择

image-processing - 如何使用 pytorch 只更新网络中的某些特定张量?

android - 我如何使用 Android EffectFactory 类?

python - 'ndarray' 类型的对象不是 JSON 可序列化的

python - 使用成对索引键连接两个数据帧

python - 稳健的 numpy.float64 相等性测试

python - Pandas 图 : scatter plot with index

Java裁剪图像?

python - 在Python中实现 Bootstrap 的内存有效方法?

python - 使用带有多个分隔符的 numpy 数组导入